Skip to content

Commit

Permalink
build(converter): use nodenext for TypeScript modules (#4490)
Browse files Browse the repository at this point in the history
Refs #4385
  • Loading branch information
glowcloud authored Nov 14, 2024
1 parent 32c1253 commit 271b337
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 39 deletions.
22 changes: 22 additions & 0 deletions packages/apidom-converter/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"settings": {
"import/resolver": {
"typescript": {
"project": ["./tsconfig.json"]
}
}
},
"rules": {
"import/extensions": [
"error",
"always",
{
"ts": "always",
"tsx": "always",
"js": "always",
"jsx": "never",
"ignorePackages": true
}
]
}
}
4 changes: 2 additions & 2 deletions packages/apidom-converter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"lint": "eslint ./",
"lint:fix": "eslint ./ --fix",
"clean": "rimraf --glob 'src/**/*.mjs' 'src/**/*.cjs' 'test/**/*.mjs' ./dist ./types",
"typescript:check-types": "tsc --noEmit",
"typescript:declaration": "tsc -p declaration.tsconfig.json && rollup -c config/rollup/types.dist.js",
"typescript:check-types": "tsc --noEmit && tsc -p ./test/tsconfig.json --noEmit",
"typescript:declaration": "tsc -p tsconfig.declaration.json && rollup -c config/rollup/types.dist.js",
"test": "npm run build:es && cross-env BABEL_ENV=es babel test --out-dir test --extensions '.ts' --out-file-extension '.mjs' --root-mode 'upward' && cross-env NODE_ENV=test mocha",
"test:update-snapshots": "cross-env UPDATE_SNAPSHOT=1 mocha",
"prepack": "copyfiles -u 3 ../../LICENSES/* LICENSES && copyfiles -u 2 ../../NOTICE .",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ConvertError from './ConvertError';
import ConvertError from './ConvertError.ts';

class UnmatchedConvertStrategyError extends ConvertError {}

Expand Down
6 changes: 3 additions & 3 deletions packages/apidom-converter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ParseResultElement } from '@swagger-api/apidom-core';
import { mergeOptions, bundle, File } from '@swagger-api/apidom-reference';

import defaultOptions, { ConverterOptions } from './options';
import ConvertError from './errors/ConvertError';
import UnmatchedConvertStrategyError from './errors/UnmatchedConvertStrategyError';
import defaultOptions, { ConverterOptions } from './options/index.ts';
import ConvertError from './errors/ConvertError.ts';
import UnmatchedConvertStrategyError from './errors/UnmatchedConvertStrategyError.ts';

export { ConvertError, UnmatchedConvertStrategyError };

Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-converter/src/options/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { options as referenceOptions } from '@swagger-api/apidom-reference';

import ConvertStrategy from '../strategies/ConvertStrategy';
import OpenAPI31ToOpenAPI30ConvertStrategy from '../strategies/openapi-3-1-to-openapi-3-0-3';
import ConvertStrategy from '../strategies/ConvertStrategy.ts';
import OpenAPI31ToOpenAPI30ConvertStrategy from '../strategies/openapi-3-1-to-openapi-3-0-3/index.ts';

type ReferenceOptions = typeof referenceOptions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ParseResultElement } from '@swagger-api/apidom-core';
import { File } from '@swagger-api/apidom-reference';

import type { ConverterOptions } from '../options';
import type { ConverterOptions } from '../options/index.ts';

export interface ConvertStrategyOptions {
readonly name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ import {
} from '@swagger-api/apidom-core';
import { File } from '@swagger-api/apidom-reference';

import ConvertStrategy from '../ConvertStrategy';
import openAPIVersionRefractorPlugin from './refractor-plugins/openapi-version';
import webhooksRefractorPlugin from './refractor-plugins/webhooks';
import securitySchemeTypeRefractorPlugin from './refractor-plugins/security-scheme-type';
import securityRequirementsEmptyRolesRefractorPlugin from './refractor-plugins/security-requirements-empty-roles';
import type { ConverterOptions } from '../../options';
import createToolbox from './toolbox';
import infoSummaryRefractorPlugin from './refractor-plugins/info-summary';
import licenseIdentifierRefractorPlugin from './refractor-plugins/license-identifier';
import referenceDescriptionRefractorPlugin from './refractor-plugins/reference-description';
import referenceSummaryRefractorPlugin from './refractor-plugins/reference-summary';
import ConvertStrategy from '../ConvertStrategy.ts';
import openAPIVersionRefractorPlugin from './refractor-plugins/openapi-version.ts';
import webhooksRefractorPlugin from './refractor-plugins/webhooks.ts';
import securitySchemeTypeRefractorPlugin from './refractor-plugins/security-scheme-type.ts';
import securityRequirementsEmptyRolesRefractorPlugin from './refractor-plugins/security-requirements-empty-roles.ts';
import type { ConverterOptions } from '../../options/index.ts';
import createToolbox from './toolbox.ts';
import infoSummaryRefractorPlugin from './refractor-plugins/info-summary.ts';
import licenseIdentifierRefractorPlugin from './refractor-plugins/license-identifier.ts';
import referenceDescriptionRefractorPlugin from './refractor-plugins/reference-description.ts';
import referenceSummaryRefractorPlugin from './refractor-plugins/reference-summary.ts';

const dispatchPluginsAsync = dispatchPlugins[Symbol.for('nodejs.util.promisify.custom')];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@swagger-api/apidom-ns-openapi-3-1';
import { AnnotationElement, toValue, isObjectElement, Element } from '@swagger-api/apidom-core';

import type { Toolbox } from '../toolbox';
import type { Toolbox } from '../toolbox.ts';

type SecurityRequirementsArrayPluginOptions = {
annotations: AnnotationElement[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@swagger-api/apidom-core';
import { dereferenceApiDOM, ReferenceSet, Reference, url } from '@swagger-api/apidom-reference';

import type { Toolbox } from '../toolbox';
import type { Toolbox } from '../toolbox.ts';

type SecuritySchemeTypePluginOptions = {
annotations: AnnotationElement[];
Expand Down
2 changes: 1 addition & 1 deletion packages/apidom-converter/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-ad
import { mediaTypes as openAPI31MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-1';
import { parse } from '@swagger-api/apidom-reference';

import convert, { convertApiDOM, ConvertError } from '../src';
import convert, { convertApiDOM, ConvertError } from '../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-converter/test/mocha-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import * as chai from 'chai';
import { jestSnapshotPlugin, addSerializer } from 'mocha-chai-jest-snapshot';

// @ts-ignore
import * as jestApiDOMSerializer from '../../../scripts/jest-serializer-apidom';
import * as jestApiDOMSerializer from '../../../scripts/jest-serializer-apidom.mjs';
// @ts-ignore
import * as jestStringSerializer from '../../../scripts/jest-serializer-string';
import * as jestStringSerializer from '../../../scripts/jest-serializer-string.mjs';

chai.use(jestSnapshotPlugin());
addSerializer(jestApiDOMSerializer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { mediaTypes as openAPI31MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-1';
import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-0';

import convert from '../../../src';
import convert from '../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
includesClasses,
} from '@swagger-api/apidom-core';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
includesClasses,
} from '@swagger-api/apidom-core';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mediaTypes as openAPI31MediaTypes } from '@swagger-api/apidom-parser-ad
import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-adapter-openapi-json-3-0';
import { toJSON } from '@swagger-api/apidom-core';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
includesClasses,
} from '@swagger-api/apidom-core';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
includesClasses,
} from '@swagger-api/apidom-core';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-ad
import { AnnotationElement, includesClasses, toJSON, toValue } from '@swagger-api/apidom-core';
import { assert, expect } from 'chai';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mediaTypes as openAPI30MediaTypes } from '@swagger-api/apidom-parser-ad
import { AnnotationElement, includesClasses, toJSON, toValue } from '@swagger-api/apidom-core';
import { assert, expect } from 'chai';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
includesClasses,
} from '@swagger-api/apidom-core';

import convert from '../../../../../src';
import convert from '../../../../../src/index.ts';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand Down
10 changes: 10 additions & 0 deletions packages/apidom-converter/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node"
},
"include": [
"."
]
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": "./tsconfig.json",
"exclude": [
"test/**/*"
],
"compilerOptions": {
"declaration": true,
"declarationDir": "types",
Expand Down
8 changes: 6 additions & 2 deletions packages/apidom-converter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"allowImportingTsExtensions": true
},
"include": [
"src/**/*",
"test/**/*"
"src/**/*"
]
}

0 comments on commit 271b337

Please sign in to comment.