mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 10:12:42 +03:00
37 lines
890 B
JavaScript
37 lines
890 B
JavaScript
import swc from "../..";
|
|
import { dirname } from "path";
|
|
import { platform } from "os";
|
|
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",
|
|
},
|
|
}
|
|
);
|
|
if (platform() === "win32") {
|
|
expect(code).toContain(`bar\\\\app`);
|
|
} else {
|
|
expect(code).toContain(`bar/app`);
|
|
}
|
|
});
|