diff --git a/crates/swc/tests/fixture/issues-7xxx/7417/input/.swcrc b/crates/swc/tests/fixture/issues-7xxx/7417/input/.swcrc new file mode 100644 index 000000000000..c44552f64f39 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7417/input/.swcrc @@ -0,0 +1,24 @@ +{ + "$schema": "https://json.schemastore.org/swcrc", + "jsc": { + "target": "es2022", + "parser": { + "dynamicImport": true, + "syntax": "typescript", + "tsx": false, + "decorators": false + }, + "baseUrl": ".", + "paths": { + "@/*": [ + "src/*" + ] + } + }, + "exclude": [ + "\\btest\\b" + ], + "module": { + "type": "commonjs" + } +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7417/input/src/index.ts b/crates/swc/tests/fixture/issues-7xxx/7417/input/src/index.ts new file mode 100644 index 000000000000..25fbb8656f16 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7417/input/src/index.ts @@ -0,0 +1,5 @@ +async function main() { + import('./lib/foo') +} + +main() \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7417/input/src/lib/foo.ts b/crates/swc/tests/fixture/issues-7xxx/7417/input/src/lib/foo.ts new file mode 100644 index 000000000000..da7f11f2e0b7 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7417/input/src/lib/foo.ts @@ -0,0 +1,5 @@ +import o from '.' + +export default function bar() { + console.log(o) +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7417/input/src/lib/index.ts b/crates/swc/tests/fixture/issues-7xxx/7417/input/src/lib/index.ts new file mode 100644 index 000000000000..4833a02bc124 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7417/input/src/lib/index.ts @@ -0,0 +1,2 @@ + +export default {} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7417/output/src/index.ts b/crates/swc/tests/fixture/issues-7xxx/7417/output/src/index.ts new file mode 100644 index 000000000000..4c7825fa4304 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7417/output/src/index.ts @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard"); +async function main() { + Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard._(require("./lib/foo"))); +} +main(); diff --git a/crates/swc/tests/fixture/issues-7xxx/7417/output/src/lib/foo.ts b/crates/swc/tests/fixture/issues-7xxx/7417/output/src/lib/foo.ts new file mode 100644 index 000000000000..2d1c5d3da714 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7417/output/src/lib/foo.ts @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "default", { + enumerable: true, + get: function() { + return bar; + } +}); +const _interop_require_default = require("@swc/helpers/_/_interop_require_default"); +const _ = /*#__PURE__*/ _interop_require_default._(require("./index")); +function bar() { + console.log(_.default); +} diff --git a/crates/swc/tests/fixture/issues-7xxx/7417/output/src/lib/index.ts b/crates/swc/tests/fixture/issues-7xxx/7417/output/src/lib/index.ts new file mode 100644 index 000000000000..9e31df6a036b --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7417/output/src/lib/index.ts @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "default", { + enumerable: true, + get: function() { + return _default; + } +}); +const _default = {}; diff --git a/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/config.json b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/config.json new file mode 100644 index 000000000000..b55fe7f5aea1 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/config.json @@ -0,0 +1,7 @@ +{ + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + }, + "inputFile": "src/lib/foo.ts" +} diff --git a/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/index.ts b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/index.ts new file mode 100644 index 000000000000..3e3a328cfb69 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/index.ts @@ -0,0 +1,5 @@ +async function main() { + import('./lib/foo') +} + +main() diff --git a/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/lib/foo.ts b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/lib/foo.ts new file mode 100644 index 000000000000..da7f11f2e0b7 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/lib/foo.ts @@ -0,0 +1,5 @@ +import o from '.' + +export default function bar() { + console.log(o) +} \ No newline at end of file diff --git a/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/lib/index.ts b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/lib/index.ts new file mode 100644 index 000000000000..b1c6ea436a54 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/input/src/lib/index.ts @@ -0,0 +1 @@ +export default {} diff --git a/crates/swc_ecma_transforms_module/tests/paths/issue-7417/output/index.ts b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/output/index.ts new file mode 100644 index 000000000000..656d040c8500 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/paths/issue-7417/output/index.ts @@ -0,0 +1,4 @@ +import o from "./index"; +export default function bar() { + console.log(o); +}