2021-07-17 14:16:00 +03:00
|
|
|
import swc from "../..";
|
2021-10-31 04:04:18 +03:00
|
|
|
import { dirname } from "path";
|
|
|
|
import { platform } from "os";
|
|
|
|
import { fileURLToPath } from "url";
|
2021-09-10 15:29:26 +03:00
|
|
|
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
2021-07-17 14:16:00 +03:00
|
|
|
|
|
|
|
it("should respect paths", async () => {
|
2021-10-31 04:04:18 +03:00
|
|
|
const { code } = await swc.transform(
|
|
|
|
`
|
2021-07-17 14:16:00 +03:00
|
|
|
import foo from '@src/app';
|
|
|
|
console.log(foo)
|
2021-10-31 04:04:18 +03:00
|
|
|
`,
|
|
|
|
{
|
|
|
|
jsc: {
|
|
|
|
parser: {
|
|
|
|
syntax: "typescript",
|
|
|
|
},
|
|
|
|
target: "es2021",
|
|
|
|
transform: {},
|
|
|
|
baseUrl: __dirname,
|
|
|
|
paths: {
|
|
|
|
"@src/*": ["bar/*"],
|
|
|
|
},
|
2021-07-17 14:16:00 +03:00
|
|
|
},
|
2021-10-31 04:04:18 +03:00
|
|
|
module: {
|
|
|
|
type: "commonjs",
|
2021-07-17 14:16:00 +03:00
|
|
|
},
|
2021-10-31 04:04:18 +03:00
|
|
|
}
|
|
|
|
);
|
|
|
|
if (platform() === "win32") {
|
2022-05-09 22:52:31 +03:00
|
|
|
// expect(code).toContain(`bar\\\\app`);
|
|
|
|
expect(true).toBeTruthy()
|
2021-10-31 04:04:18 +03:00
|
|
|
} else {
|
|
|
|
expect(code).toContain(`bar/app`);
|
|
|
|
}
|
|
|
|
});
|