Skip to content

Commit 544fd7c

Browse files
authored
Merge pull request #688 from swc-project/fix-paths
fix(register): paths option
2 parents 06d4802 + c51be25 commit 544fd7c

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { FIXTURE } from '@integrate/fixture'
2+
import test from 'ava'
3+
4+
test('should transpile paths', (t) => {
5+
t.is(FIXTURE, 'fixture')
6+
})

packages/integrate/src/fixture.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const FIXTURE = 'fixture'

packages/register/read-default-tsconfig.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,23 @@ export function tsCompilerOptionsToSwcConfig(options: ts.CompilerOptions, filena
114114
sourcemap: createSourcemapOption(options),
115115
experimentalDecorators: options.experimentalDecorators ?? false,
116116
emitDecoratorMetadata: options.emitDecoratorMetadata ?? false,
117-
dynamicImport: true,
118117
esModuleInterop: options.esModuleInterop ?? false,
119-
keepClassNames: true,
120-
paths: Object.fromEntries(
121-
Object.entries(options.paths ?? {}).map(([aliasKey, aliasPaths]) => [
122-
aliasKey,
123-
((aliasPaths as string[]) ?? []).map((path) => resolve(options.baseUrl ?? './', path)),
124-
]),
125-
) as Options['paths'],
126118
swc: {
127119
filename,
128120
jsc: {
129121
externalHelpers: Boolean(options.importHelpers),
130122
parser: {
131123
syntax: 'typescript',
132124
tsx: isJsx,
125+
dynamicImport: true,
133126
},
127+
paths: Object.fromEntries(
128+
Object.entries(options.paths ?? {}).map(([aliasKey, aliasPaths]) => [
129+
aliasKey,
130+
((aliasPaths as string[]) ?? []).map((path) => resolve(options.baseUrl ?? './', path)),
131+
]),
132+
) as Options['paths'],
133+
keepClassNames: true,
134134
transform: {
135135
react:
136136
options.jsxFactory || options.jsxFragmentFactory || options.jsx || options.jsxImportSource

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"baseUrl": "./packages",
3030
"paths": {
3131
"@swc-node/core": ["@swc-node/core/index.ts"],
32-
"@swc-node/register/*": ["./register/*"]
32+
"@swc-node/register/*": ["./register/*"],
33+
"@integrate/*": ["./integrate/src/*"]
3334
}
3435
},
3536
"include": ["./packages", "bench", "./jest.config.js"],

0 commit comments

Comments
 (0)