test custom .swcrc and aliases

This commit is contained in:
Nacho Codoñer
2025-05-06 16:55:17 +02:00
parent e2ed9426f2
commit 452f6c01e3
4 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
{
"jsc": {
"baseUrl": "./",
"paths": {
"@swcAlias/*": ["swcAlias/*"]
}
}
}

View File

@@ -0,0 +1 @@
import '@swcAlias/main';

View File

@@ -0,0 +1 @@
console.log('swcAlias/main.js alias resolved');

View File

@@ -70,6 +70,9 @@ selftest.define("modern build stack", async function () {
/* check debug stack */
await run.match(/server\/main\.js:6:22/, false, true);
// /* custom .swcrc and alias resolution */
// await run.match(/alias resolved/, false, true);
await run.stop();
});
@@ -219,6 +222,9 @@ selftest.define("modern build stack - transpiler string-like options", async fun
run.waitSecs(waitToStart);
await run.match("App running at");
/* custom .swcrc and alias resolution */
await run.match(/alias resolved/, false, true);
/* check transpiler options */
await run.match(/\[Transpiler] Used SWC.*\(app\)/, false, true);
await run.match(/\[Transpiler] Used SWC.*\(package\)/, false, true);
@@ -241,3 +247,40 @@ selftest.define("modern build stack - transpiler string-like options", async fun
await run.stop();
});
async function writConfig(s, config) {
const json = JSON.parse(s.read("package.json"));
json.meteor = {
...json.meteor,
...config,
};
s.write("package.json", JSON.stringify(json, null, 2) + "\n");
}
selftest.define("modern build stack - transpiler custom .swcrc", async function () {
const s = new Sandbox();
await s.init();
await s.createApp("modern", "modern");
await s.cd("modern");
await writConfig(s, {
modern: true,
mainModule: {
client: 'client/main.js',
server: 'server/alias.js',
},
});
const run = s.run();
run.waitSecs(waitToStart);
await run.match("App running at");
/* custom .swcrc and alias resolution */
await run.match(/alias resolved/, false, true);
await run.stop();
});