Skip to content

Commit

Permalink
add .js ext for esm module
Browse files Browse the repository at this point in the history
  • Loading branch information
zzcwoshizz committed Apr 13, 2023
1 parent 04695fa commit 275bdd2
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .changeset/tough-keys-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@zcloak/lint": patch
"@zcloak/dev": patch
---

add .js ext for esm module
2 changes: 1 addition & 1 deletion packages/dev/config/babel-config-cjs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
2 changes: 1 addition & 1 deletion packages/dev/config/babel-config-esm.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
2 changes: 1 addition & 1 deletion packages/dev/config/babel-config-webpack.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
11 changes: 9 additions & 2 deletions packages/dev/config/babel-plugins.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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']
}
]
]);
};
2 changes: 1 addition & 1 deletion packages/dev/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/dev/src/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/src/test1/circ1.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/src/test1/circ2.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/src/test1/index.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/dev/src/test1/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/src/test2/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
2 changes: 1 addition & 1 deletion packages/dev/src/tester.ts
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
2 changes: 1 addition & 1 deletion packages/lint/src/lintDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "@zcloak/dev/config/tsconfig.json",
"compilerOptions": {
"composite": true,
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"skipLibCheck": true,
"paths": {
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 275bdd2

Please sign in to comment.