@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.cjs
CHANGED
|
@@ -464,6 +464,19 @@ var init_module_graph = __esm({
|
|
|
464
464
|
}
|
|
465
465
|
mods.add(mod);
|
|
466
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* Reindex a module under a plugin-provided canonical id (e.g. a `\0virtual:foo`
|
|
469
|
+
* id returned from `resolveId`). Plugins look up their own virtual modules via
|
|
470
|
+
* `getModuleById(RESOLVED_ID)` to invalidate them on watcher events; without
|
|
471
|
+
* this remap they'd never find the node because `ensureEntryFromUrl` keys by
|
|
472
|
+
* the public URL only.
|
|
473
|
+
*/
|
|
474
|
+
setModuleId(mod, id) {
|
|
475
|
+
if (mod.id === id) return;
|
|
476
|
+
this.idToModuleMap.delete(mod.id);
|
|
477
|
+
mod.id = id;
|
|
478
|
+
this.idToModuleMap.set(id, mod);
|
|
479
|
+
}
|
|
467
480
|
/** 更新模块依赖关系 */
|
|
468
481
|
updateModuleImports(mod, importedIds) {
|
|
469
482
|
for (const imported of mod.importedModules) {
|
|
@@ -913,6 +926,16 @@ async function transformRequest(url, ctx) {
|
|
|
913
926
|
if (cleanReqUrl === "/@react-refresh") {
|
|
914
927
|
return { code: getReactRefreshRuntimeEsm() };
|
|
915
928
|
}
|
|
929
|
+
if (cleanReqUrl.startsWith("/@modules/")) {
|
|
930
|
+
const spec = cleanReqUrl.slice("/@modules/".length);
|
|
931
|
+
const virtual = await loadVirtualModule(spec, ctx);
|
|
932
|
+
if (virtual) {
|
|
933
|
+
const mod2 = await moduleGraph.ensureEntryFromUrl(url);
|
|
934
|
+
moduleGraph.setModuleId(mod2, virtual.id);
|
|
935
|
+
mod2.transformResult = virtual.result;
|
|
936
|
+
return virtual.result;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
916
939
|
const filePath = resolveUrlToFile(url, config.root);
|
|
917
940
|
if (!filePath || !import_node_fs4.default.existsSync(filePath)) return null;
|
|
918
941
|
const mod = await moduleGraph.ensureEntryFromUrl(url);
|
|
@@ -959,6 +982,28 @@ async function transformRequest(url, ctx) {
|
|
|
959
982
|
mod.transformResult = transformResult;
|
|
960
983
|
return transformResult;
|
|
961
984
|
}
|
|
985
|
+
async function loadVirtualModule(spec, ctx) {
|
|
986
|
+
const { config, pluginContainer } = ctx;
|
|
987
|
+
const resolved = await pluginContainer.resolveId(spec);
|
|
988
|
+
if (resolved == null) return null;
|
|
989
|
+
const resolvedId = typeof resolved === "string" ? resolved : resolved.id;
|
|
990
|
+
const looksVirtual = resolvedId.startsWith("\0") || !import_node_fs4.default.existsSync(resolvedId);
|
|
991
|
+
if (!looksVirtual) return null;
|
|
992
|
+
const loadResult = await pluginContainer.load(resolvedId);
|
|
993
|
+
if (loadResult == null) return null;
|
|
994
|
+
let code = typeof loadResult === "string" ? loadResult : loadResult.code;
|
|
995
|
+
const transformed = await pluginContainer.transform(code, resolvedId);
|
|
996
|
+
if (transformed != null) {
|
|
997
|
+
code = typeof transformed === "string" ? transformed : transformed.code;
|
|
998
|
+
}
|
|
999
|
+
code = replaceEnvInCode(code, ctx.envDefine ?? buildEnvDefine(
|
|
1000
|
+
loadEnv(config.mode, config.root, config.envPrefix),
|
|
1001
|
+
config.mode
|
|
1002
|
+
));
|
|
1003
|
+
const anchor = import_node_path4.default.join(config.root, "__nasti_virtual__.ts");
|
|
1004
|
+
code = rewriteImports(code, config, anchor);
|
|
1005
|
+
return { id: resolvedId, result: { code } };
|
|
1006
|
+
}
|
|
962
1007
|
async function bundlePackageAsEsm(entryFile) {
|
|
963
1008
|
if (!esmBundleCache.has(entryFile)) {
|
|
964
1009
|
esmBundleCache.set(entryFile, doBundlePackage(entryFile));
|
|
@@ -1810,7 +1855,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1810
1855
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1811
1856
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1812
1857
|
console.log();
|
|
1813
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.6.
|
|
1858
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.6.3"}`));
|
|
1814
1859
|
console.log();
|
|
1815
1860
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1816
1861
|
if (networkUrl) {
|
|
@@ -1937,7 +1982,7 @@ __export(build_exports, {
|
|
|
1937
1982
|
async function build(inlineConfig = {}) {
|
|
1938
1983
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1939
1984
|
const startTime = performance.now();
|
|
1940
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.6.
|
|
1985
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.6.3"}`));
|
|
1941
1986
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1942
1987
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1943
1988
|
const outDir = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
@@ -2003,7 +2048,11 @@ async function build(inlineConfig = {}) {
|
|
|
2003
2048
|
load: p.load,
|
|
2004
2049
|
transform: p.transform,
|
|
2005
2050
|
buildStart: p.buildStart,
|
|
2006
|
-
buildEnd: p.buildEnd
|
|
2051
|
+
buildEnd: p.buildEnd,
|
|
2052
|
+
// Forward `closeBundle` to Rolldown — it invokes the hook during
|
|
2053
|
+
// `bundle.close()` below. This is the hook Vite plugins (e.g. PWA
|
|
2054
|
+
// manifest/SW writers) rely on for final-stage artifact emission.
|
|
2055
|
+
closeBundle: p.closeBundle
|
|
2007
2056
|
}))
|
|
2008
2057
|
],
|
|
2009
2058
|
...config.build.rolldownOptions
|
|
@@ -2098,7 +2147,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2098
2147
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
2099
2148
|
const startTime = performance.now();
|
|
2100
2149
|
assertElectronVersion(config);
|
|
2101
|
-
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.6.
|
|
2150
|
+
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.6.3"}`));
|
|
2102
2151
|
console.log(import_picocolors3.default.dim(` root: ${config.root}`));
|
|
2103
2152
|
console.log(import_picocolors3.default.dim(` mode: ${config.mode}`));
|
|
2104
2153
|
console.log(import_picocolors3.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -2250,7 +2299,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2250
2299
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2251
2300
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2252
2301
|
warnElectronVersion(config);
|
|
2253
|
-
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.6.
|
|
2302
|
+
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.6.3"}`));
|
|
2254
2303
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2255
2304
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2256
2305
|
await server.listen();
|
|
@@ -2585,6 +2634,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
2585
2634
|
}
|
|
2586
2635
|
});
|
|
2587
2636
|
cli.help();
|
|
2588
|
-
cli.version("1.6.
|
|
2637
|
+
cli.version("1.6.3");
|
|
2589
2638
|
cli.parse();
|
|
2590
2639
|
//# sourceMappingURL=cli.cjs.map
|