@nasti-toolchain/nasti 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +55 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +55 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +54 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +54 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -443,6 +443,19 @@ var init_module_graph = __esm({
|
|
|
443
443
|
}
|
|
444
444
|
mods.add(mod);
|
|
445
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Reindex a module under a plugin-provided canonical id (e.g. a `\0virtual:foo`
|
|
448
|
+
* id returned from `resolveId`). Plugins look up their own virtual modules via
|
|
449
|
+
* `getModuleById(RESOLVED_ID)` to invalidate them on watcher events; without
|
|
450
|
+
* this remap they'd never find the node because `ensureEntryFromUrl` keys by
|
|
451
|
+
* the public URL only.
|
|
452
|
+
*/
|
|
453
|
+
setModuleId(mod, id) {
|
|
454
|
+
if (mod.id === id) return;
|
|
455
|
+
this.idToModuleMap.delete(mod.id);
|
|
456
|
+
mod.id = id;
|
|
457
|
+
this.idToModuleMap.set(id, mod);
|
|
458
|
+
}
|
|
446
459
|
/** 更新模块依赖关系 */
|
|
447
460
|
updateModuleImports(mod, importedIds) {
|
|
448
461
|
for (const imported of mod.importedModules) {
|
|
@@ -894,6 +907,16 @@ async function transformRequest(url, ctx) {
|
|
|
894
907
|
if (cleanReqUrl === "/@react-refresh") {
|
|
895
908
|
return { code: getReactRefreshRuntimeEsm() };
|
|
896
909
|
}
|
|
910
|
+
if (cleanReqUrl.startsWith("/@modules/")) {
|
|
911
|
+
const spec = cleanReqUrl.slice("/@modules/".length);
|
|
912
|
+
const virtual = await loadVirtualModule(spec, ctx);
|
|
913
|
+
if (virtual) {
|
|
914
|
+
const mod2 = await moduleGraph.ensureEntryFromUrl(url);
|
|
915
|
+
moduleGraph.setModuleId(mod2, virtual.id);
|
|
916
|
+
mod2.transformResult = virtual.result;
|
|
917
|
+
return virtual.result;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
897
920
|
const filePath = resolveUrlToFile(url, config.root);
|
|
898
921
|
if (!filePath || !fs4.existsSync(filePath)) return null;
|
|
899
922
|
const mod = await moduleGraph.ensureEntryFromUrl(url);
|
|
@@ -940,6 +963,28 @@ async function transformRequest(url, ctx) {
|
|
|
940
963
|
mod.transformResult = transformResult;
|
|
941
964
|
return transformResult;
|
|
942
965
|
}
|
|
966
|
+
async function loadVirtualModule(spec, ctx) {
|
|
967
|
+
const { config, pluginContainer } = ctx;
|
|
968
|
+
const resolved = await pluginContainer.resolveId(spec);
|
|
969
|
+
if (resolved == null) return null;
|
|
970
|
+
const resolvedId = typeof resolved === "string" ? resolved : resolved.id;
|
|
971
|
+
const looksVirtual = resolvedId.startsWith("\0") || !fs4.existsSync(resolvedId);
|
|
972
|
+
if (!looksVirtual) return null;
|
|
973
|
+
const loadResult = await pluginContainer.load(resolvedId);
|
|
974
|
+
if (loadResult == null) return null;
|
|
975
|
+
let code = typeof loadResult === "string" ? loadResult : loadResult.code;
|
|
976
|
+
const transformed = await pluginContainer.transform(code, resolvedId);
|
|
977
|
+
if (transformed != null) {
|
|
978
|
+
code = typeof transformed === "string" ? transformed : transformed.code;
|
|
979
|
+
}
|
|
980
|
+
code = replaceEnvInCode(code, ctx.envDefine ?? buildEnvDefine(
|
|
981
|
+
loadEnv(config.mode, config.root, config.envPrefix),
|
|
982
|
+
config.mode
|
|
983
|
+
));
|
|
984
|
+
const anchor = path4.join(config.root, "__nasti_virtual__.ts");
|
|
985
|
+
code = rewriteImports(code, config, anchor);
|
|
986
|
+
return { id: resolvedId, result: { code } };
|
|
987
|
+
}
|
|
943
988
|
async function bundlePackageAsEsm(entryFile) {
|
|
944
989
|
if (!esmBundleCache.has(entryFile)) {
|
|
945
990
|
esmBundleCache.set(entryFile, doBundlePackage(entryFile));
|
|
@@ -1790,7 +1835,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1790
1835
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1791
1836
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1792
1837
|
console.log();
|
|
1793
|
-
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.6.
|
|
1838
|
+
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.6.3"}`));
|
|
1794
1839
|
console.log();
|
|
1795
1840
|
console.log(` ${pc.green(">")} Local: ${pc.cyan(localUrl)}`);
|
|
1796
1841
|
if (networkUrl) {
|
|
@@ -1913,7 +1958,7 @@ import pc2 from "picocolors";
|
|
|
1913
1958
|
async function build(inlineConfig = {}) {
|
|
1914
1959
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1915
1960
|
const startTime = performance.now();
|
|
1916
|
-
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.6.
|
|
1961
|
+
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.6.3"}`));
|
|
1917
1962
|
console.log(pc2.dim(` root: ${config.root}`));
|
|
1918
1963
|
console.log(pc2.dim(` mode: ${config.mode}`));
|
|
1919
1964
|
const outDir = path10.resolve(config.root, config.build.outDir);
|
|
@@ -1979,7 +2024,11 @@ async function build(inlineConfig = {}) {
|
|
|
1979
2024
|
load: p.load,
|
|
1980
2025
|
transform: p.transform,
|
|
1981
2026
|
buildStart: p.buildStart,
|
|
1982
|
-
buildEnd: p.buildEnd
|
|
2027
|
+
buildEnd: p.buildEnd,
|
|
2028
|
+
// Forward `closeBundle` to Rolldown — it invokes the hook during
|
|
2029
|
+
// `bundle.close()` below. This is the hook Vite plugins (e.g. PWA
|
|
2030
|
+
// manifest/SW writers) rely on for final-stage artifact emission.
|
|
2031
|
+
closeBundle: p.closeBundle
|
|
1983
2032
|
}))
|
|
1984
2033
|
],
|
|
1985
2034
|
...config.build.rolldownOptions
|
|
@@ -2073,7 +2122,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2073
2122
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
2074
2123
|
const startTime = performance.now();
|
|
2075
2124
|
assertElectronVersion(config);
|
|
2076
|
-
console.log(pc3.cyan("\n\u26A1 nasti build (electron)") + pc3.dim(` v${"1.6.
|
|
2125
|
+
console.log(pc3.cyan("\n\u26A1 nasti build (electron)") + pc3.dim(` v${"1.6.3"}`));
|
|
2077
2126
|
console.log(pc3.dim(` root: ${config.root}`));
|
|
2078
2127
|
console.log(pc3.dim(` mode: ${config.mode}`));
|
|
2079
2128
|
console.log(pc3.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -2227,7 +2276,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2227
2276
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2228
2277
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2229
2278
|
warnElectronVersion(config);
|
|
2230
|
-
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.6.
|
|
2279
|
+
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.6.3"}`));
|
|
2231
2280
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2232
2281
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2233
2282
|
await server.listen();
|
|
@@ -2554,6 +2603,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
2554
2603
|
}
|
|
2555
2604
|
});
|
|
2556
2605
|
cli.help();
|
|
2557
|
-
cli.version("1.6.
|
|
2606
|
+
cli.version("1.6.3");
|
|
2558
2607
|
cli.parse();
|
|
2559
2608
|
//# sourceMappingURL=cli.js.map
|