swc/node-swc/__tests__/paths_test.mjs
강동윤 9eafd0c6c4
fix(es/loader): Fix support for jsc.paths. (#2227)
swc_ecma_loader:
 - `TsConfigResolver`: Use `baseUrl`. (#2050)

swc:
 - Change type of `JscConfig.base_url` to `PathBuf`.

testing:
 - Improve `NormalizedOutput::compare_to_file`.
2021-09-10 12:29:26 +00:00

32 lines
685 B
JavaScript

import swc from "../..";
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
it("should respect paths", async () => {
const { code } = await swc.transform(`
import foo from '@src/app';
console.log(foo)
`, {
jsc: {
parser: {
syntax: 'typescript',
},
target: 'es2021',
transform: {
},
baseUrl: __dirname,
paths: {
'@src/*': ['bar/*']
}
},
module: {
type: 'commonjs'
},
});
expect(code).toContain(`bar/app`);
})