@nasti-toolchain/nasti 1.3.7 → 1.3.9
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 +46 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +46 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +45 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -269,15 +269,18 @@ function transformMiddleware(ctx) {
|
|
|
269
269
|
}
|
|
270
270
|
async function transformRequest(url, ctx) {
|
|
271
271
|
const { config, pluginContainer, moduleGraph } = ctx;
|
|
272
|
+
const cleanReqUrl = url.split("?")[0];
|
|
272
273
|
const cached = moduleGraph.getModuleByUrl(url);
|
|
273
274
|
if (cached?.transformResult) {
|
|
274
275
|
return cached.transformResult;
|
|
275
276
|
}
|
|
277
|
+
if (cleanReqUrl === "/@react-refresh") {
|
|
278
|
+
return { code: REACT_REFRESH_RUNTIME };
|
|
279
|
+
}
|
|
276
280
|
const filePath = resolveUrlToFile(url, config.root);
|
|
277
281
|
if (!filePath || !import_node_fs7.default.existsSync(filePath)) return null;
|
|
278
282
|
const mod = await moduleGraph.ensureEntryFromUrl(url);
|
|
279
283
|
moduleGraph.registerModule(mod, filePath);
|
|
280
|
-
const cleanReqUrl = url.split("?")[0];
|
|
281
284
|
if (cleanReqUrl.startsWith("/@modules/")) {
|
|
282
285
|
const code2 = await bundlePackageAsEsm(filePath);
|
|
283
286
|
const transformResult2 = { code: code2 };
|
|
@@ -290,13 +293,18 @@ async function transformRequest(url, ctx) {
|
|
|
290
293
|
code = typeof pluginResult === "string" ? pluginResult : pluginResult.code;
|
|
291
294
|
}
|
|
292
295
|
if (shouldTransform(filePath)) {
|
|
296
|
+
const isJsx = /\.[jt]sx$/.test(filePath);
|
|
297
|
+
const useRefresh = isJsx && config.framework !== "vue";
|
|
293
298
|
const result = transformCode(filePath, code, {
|
|
294
299
|
sourcemap: true,
|
|
295
300
|
jsxRuntime: "automatic",
|
|
296
301
|
jsxImportSource: config.framework === "vue" ? "vue" : "react",
|
|
297
|
-
reactRefresh:
|
|
302
|
+
reactRefresh: useRefresh
|
|
298
303
|
});
|
|
299
304
|
code = result.code;
|
|
305
|
+
if (useRefresh) {
|
|
306
|
+
code = REACT_REFRESH_PREAMBLE + code + REACT_REFRESH_FOOTER;
|
|
307
|
+
}
|
|
300
308
|
}
|
|
301
309
|
const envDefine = ctx.envDefine ?? buildEnvDefine(
|
|
302
310
|
loadEnv(config.mode, config.root, config.envPrefix),
|
|
@@ -443,10 +451,19 @@ function resolveNodeModule(root, moduleName) {
|
|
|
443
451
|
if (resolved) return resolved;
|
|
444
452
|
}
|
|
445
453
|
if (subpath) {
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
454
|
+
const subDirs = [""];
|
|
455
|
+
for (const field of ["module", "main"]) {
|
|
456
|
+
if (typeof pkg[field] === "string") {
|
|
457
|
+
const dir2 = import_node_path8.default.dirname(pkg[field]);
|
|
458
|
+
if (dir2 && dir2 !== "." && !subDirs.includes(dir2)) subDirs.push(dir2);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
for (const dir2 of subDirs) {
|
|
462
|
+
const direct = import_node_path8.default.join(pkgDir, dir2, subpath);
|
|
463
|
+
if (import_node_fs7.default.existsSync(direct) && import_node_fs7.default.statSync(direct).isFile()) return direct;
|
|
464
|
+
for (const ext of RESOLVE_EXTENSIONS) {
|
|
465
|
+
if (import_node_fs7.default.existsSync(direct + ext)) return direct + ext;
|
|
466
|
+
}
|
|
450
467
|
}
|
|
451
468
|
return null;
|
|
452
469
|
}
|
|
@@ -612,7 +629,7 @@ if (!window.__nasti_hot_map) window.__nasti_hot_map = new Map();
|
|
|
612
629
|
window.__NASTI_HMR__ = { createHotContext };
|
|
613
630
|
`;
|
|
614
631
|
}
|
|
615
|
-
var import_node_path8, import_node_fs7, esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
632
|
+
var import_node_path8, import_node_fs7, REACT_REFRESH_RUNTIME, REACT_REFRESH_PREAMBLE, REACT_REFRESH_FOOTER, esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
616
633
|
var init_middleware = __esm({
|
|
617
634
|
"src/server/middleware.ts"() {
|
|
618
635
|
"use strict";
|
|
@@ -621,6 +638,25 @@ var init_middleware = __esm({
|
|
|
621
638
|
init_transformer();
|
|
622
639
|
init_html();
|
|
623
640
|
init_env();
|
|
641
|
+
REACT_REFRESH_RUNTIME = `
|
|
642
|
+
export function createSignatureFunctionForTransform() {
|
|
643
|
+
return function(type, key, forceReset, getCustomHooks) { return type; };
|
|
644
|
+
}
|
|
645
|
+
export function register(type, id) {}
|
|
646
|
+
export default { createSignatureFunctionForTransform, register };
|
|
647
|
+
`;
|
|
648
|
+
REACT_REFRESH_PREAMBLE = `
|
|
649
|
+
import RefreshRuntime from '/@react-refresh';
|
|
650
|
+
if (!window.$RefreshReg$) {
|
|
651
|
+
window.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, import.meta.url + ' ' + id);
|
|
652
|
+
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
653
|
+
}
|
|
654
|
+
`;
|
|
655
|
+
REACT_REFRESH_FOOTER = `
|
|
656
|
+
if (import.meta.hot) {
|
|
657
|
+
import.meta.hot.accept();
|
|
658
|
+
}
|
|
659
|
+
`;
|
|
624
660
|
esmBundleCache = /* @__PURE__ */ new Map();
|
|
625
661
|
VALID_IDENT = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
626
662
|
RESOLVE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".json", ".vue"];
|
|
@@ -1120,7 +1156,7 @@ var import_picocolors = __toESM(require("picocolors"), 1);
|
|
|
1120
1156
|
async function build(inlineConfig = {}) {
|
|
1121
1157
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1122
1158
|
const startTime = performance.now();
|
|
1123
|
-
console.log(import_picocolors.default.cyan("\n\u{1F528} nasti build") + import_picocolors.default.dim(` v${"1.3.
|
|
1159
|
+
console.log(import_picocolors.default.cyan("\n\u{1F528} nasti build") + import_picocolors.default.dim(` v${"1.3.9"}`));
|
|
1124
1160
|
console.log(import_picocolors.default.dim(` root: ${config.root}`));
|
|
1125
1161
|
console.log(import_picocolors.default.dim(` mode: ${config.mode}`));
|
|
1126
1162
|
const outDir = import_node_path7.default.resolve(config.root, config.build.outDir);
|
|
@@ -1526,7 +1562,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1526
1562
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1527
1563
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1528
1564
|
console.log();
|
|
1529
|
-
console.log(import_picocolors2.default.cyan(" nasti dev server") + import_picocolors2.default.dim(` v${"1.3.
|
|
1565
|
+
console.log(import_picocolors2.default.cyan(" nasti dev server") + import_picocolors2.default.dim(` v${"1.3.9"}`));
|
|
1530
1566
|
console.log();
|
|
1531
1567
|
console.log(` ${import_picocolors2.default.green(">")} Local: ${import_picocolors2.default.cyan(localUrl)}`);
|
|
1532
1568
|
if (networkUrl) {
|