diff --git a/.changeset/tough-keys-shop.md b/.changeset/tough-keys-shop.md new file mode 100644 index 0000000..1ba87b2 --- /dev/null +++ b/.changeset/tough-keys-shop.md @@ -0,0 +1,6 @@ +--- +"@zcloak/lint": patch +"@zcloak/dev": patch +--- + +add .js ext for esm module diff --git a/packages/dev/config/babel-config-cjs.cjs b/packages/dev/config/babel-config-cjs.cjs index df25153..8f039ed 100644 --- a/packages/dev/config/babel-config-cjs.cjs +++ b/packages/dev/config/babel-config-cjs.cjs @@ -7,6 +7,6 @@ const presets = require('./babel-presets.cjs'); module.exports = { ...general, - plugins: plugins(false, false), + plugins: plugins(false, false, false), presets: presets(false, false) }; diff --git a/packages/dev/config/babel-config-esm.cjs b/packages/dev/config/babel-config-esm.cjs index 71b9935..cc160eb 100644 --- a/packages/dev/config/babel-config-esm.cjs +++ b/packages/dev/config/babel-config-esm.cjs @@ -7,6 +7,6 @@ const presets = require('./babel-presets.cjs'); module.exports = { ...general, - plugins: plugins(true, false), + plugins: plugins(true, false, true), presets: presets(true, false) }; diff --git a/packages/dev/config/babel-config-webpack.cjs b/packages/dev/config/babel-config-webpack.cjs index 986d76f..057b551 100644 --- a/packages/dev/config/babel-config-webpack.cjs +++ b/packages/dev/config/babel-config-webpack.cjs @@ -7,6 +7,6 @@ const presets = require('./babel-presets.cjs'); module.exports = { ...general, - plugins: plugins(true, true), + plugins: plugins(true, true, false), presets: presets(true, true) }; diff --git a/packages/dev/config/babel-plugins.cjs b/packages/dev/config/babel-plugins.cjs index d3afbd2..9f36199 100644 --- a/packages/dev/config/babel-plugins.cjs +++ b/packages/dev/config/babel-plugins.cjs @@ -3,7 +3,7 @@ const resolver = require('./babel-resolver.cjs'); -module.exports = function (isEsm, usage) { +module.exports = function (isEsm, usage, doRewrite) { return resolver([ '@babel/plugin-proposal-nullish-coalescing-operator', '@babel/plugin-proposal-numeric-separator', @@ -22,6 +22,13 @@ module.exports = function (isEsm, usage) { '@babel/plugin-syntax-import-assertions', '@babel/plugin-syntax-import-meta', '@babel/plugin-syntax-top-level-await', - 'babel-plugin-styled-components' + 'babel-plugin-styled-components', + doRewrite && [ + 'babel-plugin-module-extension-resolver', + { + dstExtension: '.js', + srcExtensions: ['.ts', '.tsx', '.js', '.jsx'] + } + ] ]); }; diff --git a/packages/dev/src/index.spec.ts b/packages/dev/src/index.spec.ts index 7bce2c5..ecc1222 100644 --- a/packages/dev/src/index.spec.ts +++ b/packages/dev/src/index.spec.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { adder, blah } from './test1/index.js'; -import { echo } from './index.js'; +import { echo } from '.'; describe('index', () => { it('runs the echo function', () => { diff --git a/packages/dev/src/index.ts b/packages/dev/src/index.ts index b2eb4f4..88655f2 100644 --- a/packages/dev/src/index.ts +++ b/packages/dev/src/index.ts @@ -1,12 +1,12 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { BlahType } from '@zcloak/dev/types.js'; -import type { EchoString } from './types.js'; +import type { BlahType } from '@zcloak/dev/types'; +import type { EchoString } from './types'; -import { foo } from './test1/foo.js'; -import { adder, blah } from './test1/index.js'; -import { addThree } from './util.js'; +import { foo } from './test1/foo'; +import { adder, blah } from './test1/index'; +import { addThree } from './util'; const SOMETHING = { a: 1, diff --git a/packages/dev/src/test1/circ1.ts b/packages/dev/src/test1/circ1.ts index bded384..50c447a 100644 --- a/packages/dev/src/test1/circ1.ts +++ b/packages/dev/src/test1/circ1.ts @@ -1,7 +1,7 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { circ2 } from './circ2.js'; +import { circ2 } from './circ2'; // we leave this as a warning... just a test export function circ1(): number { diff --git a/packages/dev/src/test1/circ2.ts b/packages/dev/src/test1/circ2.ts index 5af0514..743a328 100644 --- a/packages/dev/src/test1/circ2.ts +++ b/packages/dev/src/test1/circ2.ts @@ -1,7 +1,7 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { circ1 } from './circ1.js'; +import { circ1 } from './circ1'; export function circ2(): void { circ1(); diff --git a/packages/dev/src/test1/index.spec.ts b/packages/dev/src/test1/index.spec.ts index 9996815..034e5e2 100644 --- a/packages/dev/src/test1/index.spec.ts +++ b/packages/dev/src/test1/index.spec.ts @@ -1,7 +1,7 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import index, { blah } from './index.js'; +import index, { blah } from '.'; describe('index', () => { it('runs the test', () => { diff --git a/packages/dev/src/test1/index.ts b/packages/dev/src/test1/index.ts index 24d36a6..ccc8a27 100644 --- a/packages/dev/src/test1/index.ts +++ b/packages/dev/src/test1/index.ts @@ -1,8 +1,8 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -export { circ1 } from './circ1.js'; -export { circ2 } from './circ2.js'; +export { circ1 } from './circ1'; +export { circ2 } from './circ2'; /** * Some first test link diff --git a/packages/dev/src/test2/index.ts b/packages/dev/src/test2/index.ts index 441b0f5..c924944 100644 --- a/packages/dev/src/test2/index.ts +++ b/packages/dev/src/test2/index.ts @@ -1,6 +1,6 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import bar from './bar.js'; +import bar from './bar'; export { bar }; diff --git a/packages/dev/src/tester.ts b/packages/dev/src/tester.ts index 9bab67e..286f5e6 100644 --- a/packages/dev/src/tester.ts +++ b/packages/dev/src/tester.ts @@ -1,7 +1,7 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { tester } from './index.js'; +import { tester } from '.'; tester(); diff --git a/packages/lint/src/lintDependencies.ts b/packages/lint/src/lintDependencies.ts index a67e667..5fe7be5 100644 --- a/packages/lint/src/lintDependencies.ts +++ b/packages/lint/src/lintDependencies.ts @@ -12,7 +12,7 @@ import { readFileAsync } from './fs.js'; import { PackageJson, readPackageJson } from './package-json.js'; const MAX_NUMBER_OF_FILES_CONCURENTLY_OPENED = 50; -const throat = throatFactory.default(MAX_NUMBER_OF_FILES_CONCURENTLY_OPENED); +const throat = throatFactory(MAX_NUMBER_OF_FILES_CONCURENTLY_OPENED); const ignoredDependencies = [ // node diff --git a/tsconfig.base.json b/tsconfig.base.json index 2610785..70553ef 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -2,7 +2,6 @@ "extends": "@zcloak/dev/config/tsconfig.json", "compilerOptions": { "composite": true, - "moduleResolution": "nodenext", "resolveJsonModule": true, "skipLibCheck": true, "paths": { diff --git a/yarn.lock b/yarn.lock index 725c91c..e26121b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3608,6 +3608,7 @@ __metadata: "@typescript-eslint/parser": "npm:^5.55.0" "@zcloak/lint": "workspace:^" babel-jest: "npm:^29.5.0" + babel-plugin-add-module-exports: "npm:^1.0.4" babel-plugin-module-extension-resolver: "npm:^1.0.0" babel-plugin-module-resolver: "npm:^5.0.0" babel-plugin-styled-components: "npm:^2.0.7" @@ -4222,6 +4223,13 @@ __metadata: languageName: node linkType: hard +"babel-plugin-add-module-exports@npm:^1.0.4": + version: 1.0.4 + resolution: "babel-plugin-add-module-exports@npm:1.0.4" + checksum: 1762a93b758c24647d983a2c3e49bc3c5188617e5d48a1dfbd2fde115a759bd06fa83709063ed35aa24cad803033902a74ae00d713696c342994a5a9574d11f4 + languageName: node + linkType: hard + "babel-plugin-istanbul@npm:^6.1.1": version: 6.1.1 resolution: "babel-plugin-istanbul@npm:6.1.1"