From 452f6c01e3cfe2eda3cefd3884192b28462d80aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Tue, 6 May 2025 16:55:17 +0200 Subject: [PATCH] test custom .swcrc and aliases --- tools/tests/apps/modern/.swcrc | 8 +++++ tools/tests/apps/modern/server/alias.js | 1 + tools/tests/apps/modern/swcAlias/main.js | 1 + tools/tests/modern.js | 43 ++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 tools/tests/apps/modern/.swcrc create mode 100644 tools/tests/apps/modern/server/alias.js create mode 100644 tools/tests/apps/modern/swcAlias/main.js diff --git a/tools/tests/apps/modern/.swcrc b/tools/tests/apps/modern/.swcrc new file mode 100644 index 0000000000..e859928b67 --- /dev/null +++ b/tools/tests/apps/modern/.swcrc @@ -0,0 +1,8 @@ +{ + "jsc": { + "baseUrl": "./", + "paths": { + "@swcAlias/*": ["swcAlias/*"] + } + } +} diff --git a/tools/tests/apps/modern/server/alias.js b/tools/tests/apps/modern/server/alias.js new file mode 100644 index 0000000000..acf0a92d2a --- /dev/null +++ b/tools/tests/apps/modern/server/alias.js @@ -0,0 +1 @@ +import '@swcAlias/main'; diff --git a/tools/tests/apps/modern/swcAlias/main.js b/tools/tests/apps/modern/swcAlias/main.js new file mode 100644 index 0000000000..65ebe218b3 --- /dev/null +++ b/tools/tests/apps/modern/swcAlias/main.js @@ -0,0 +1 @@ +console.log('swcAlias/main.js alias resolved'); diff --git a/tools/tests/modern.js b/tools/tests/modern.js index 189b1d01df..6781d9cf85 100644 --- a/tools/tests/modern.js +++ b/tools/tests/modern.js @@ -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(); +});