2021-07-17 14:16:00 +03:00
|
|
|
import swc from "../..";
|
2021-09-10 15:29:26 +03:00
|
|
|
import { dirname } from 'path';
|
|
|
|
import { fileURLToPath } from 'url';
|
|
|
|
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
2021-07-17 14:16:00 +03:00
|
|
|
|
|
|
|
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: {
|
|
|
|
|
|
|
|
},
|
2021-09-10 15:29:26 +03:00
|
|
|
baseUrl: __dirname,
|
2021-07-17 14:16:00 +03:00
|
|
|
paths: {
|
|
|
|
'@src/*': ['bar/*']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
type: 'commonjs'
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(code).toContain(`bar/app`);
|
|
|
|
})
|