mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 22:22:34 +03:00
9eafd0c6c4
swc_ecma_loader: - `TsConfigResolver`: Use `baseUrl`. (#2050) swc: - Change type of `JscConfig.base_url` to `PathBuf`. testing: - Improve `NormalizedOutput::compare_to_file`.
32 lines
685 B
JavaScript
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`);
|
|
})
|