@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/cli.cjs
CHANGED
|
@@ -717,15 +717,18 @@ function transformMiddleware(ctx) {
|
|
|
717
717
|
}
|
|
718
718
|
async function transformRequest(url, ctx) {
|
|
719
719
|
const { config, pluginContainer, moduleGraph } = ctx;
|
|
720
|
+
const cleanReqUrl = url.split("?")[0];
|
|
720
721
|
const cached = moduleGraph.getModuleByUrl(url);
|
|
721
722
|
if (cached?.transformResult) {
|
|
722
723
|
return cached.transformResult;
|
|
723
724
|
}
|
|
725
|
+
if (cleanReqUrl === "/@react-refresh") {
|
|
726
|
+
return { code: REACT_REFRESH_RUNTIME };
|
|
727
|
+
}
|
|
724
728
|
const filePath = resolveUrlToFile(url, config.root);
|
|
725
729
|
if (!filePath || !import_node_fs4.default.existsSync(filePath)) return null;
|
|
726
730
|
const mod = await moduleGraph.ensureEntryFromUrl(url);
|
|
727
731
|
moduleGraph.registerModule(mod, filePath);
|
|
728
|
-
const cleanReqUrl = url.split("?")[0];
|
|
729
732
|
if (cleanReqUrl.startsWith("/@modules/")) {
|
|
730
733
|
const code2 = await bundlePackageAsEsm(filePath);
|
|
731
734
|
const transformResult2 = { code: code2 };
|
|
@@ -738,13 +741,18 @@ async function transformRequest(url, ctx) {
|
|
|
738
741
|
code = typeof pluginResult === "string" ? pluginResult : pluginResult.code;
|
|
739
742
|
}
|
|
740
743
|
if (shouldTransform(filePath)) {
|
|
744
|
+
const isJsx = /\.[jt]sx$/.test(filePath);
|
|
745
|
+
const useRefresh = isJsx && config.framework !== "vue";
|
|
741
746
|
const result = transformCode(filePath, code, {
|
|
742
747
|
sourcemap: true,
|
|
743
748
|
jsxRuntime: "automatic",
|
|
744
749
|
jsxImportSource: config.framework === "vue" ? "vue" : "react",
|
|
745
|
-
reactRefresh:
|
|
750
|
+
reactRefresh: useRefresh
|
|
746
751
|
});
|
|
747
752
|
code = result.code;
|
|
753
|
+
if (useRefresh) {
|
|
754
|
+
code = REACT_REFRESH_PREAMBLE + code + REACT_REFRESH_FOOTER;
|
|
755
|
+
}
|
|
748
756
|
}
|
|
749
757
|
const envDefine = ctx.envDefine ?? buildEnvDefine(
|
|
750
758
|
loadEnv(config.mode, config.root, config.envPrefix),
|
|
@@ -891,10 +899,19 @@ function resolveNodeModule(root, moduleName) {
|
|
|
891
899
|
if (resolved) return resolved;
|
|
892
900
|
}
|
|
893
901
|
if (subpath) {
|
|
894
|
-
const
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
902
|
+
const subDirs = [""];
|
|
903
|
+
for (const field of ["module", "main"]) {
|
|
904
|
+
if (typeof pkg[field] === "string") {
|
|
905
|
+
const dir2 = import_node_path4.default.dirname(pkg[field]);
|
|
906
|
+
if (dir2 && dir2 !== "." && !subDirs.includes(dir2)) subDirs.push(dir2);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
for (const dir2 of subDirs) {
|
|
910
|
+
const direct = import_node_path4.default.join(pkgDir, dir2, subpath);
|
|
911
|
+
if (import_node_fs4.default.existsSync(direct) && import_node_fs4.default.statSync(direct).isFile()) return direct;
|
|
912
|
+
for (const ext of RESOLVE_EXTENSIONS) {
|
|
913
|
+
if (import_node_fs4.default.existsSync(direct + ext)) return direct + ext;
|
|
914
|
+
}
|
|
898
915
|
}
|
|
899
916
|
return null;
|
|
900
917
|
}
|
|
@@ -1060,7 +1077,7 @@ if (!window.__nasti_hot_map) window.__nasti_hot_map = new Map();
|
|
|
1060
1077
|
window.__NASTI_HMR__ = { createHotContext };
|
|
1061
1078
|
`;
|
|
1062
1079
|
}
|
|
1063
|
-
var import_node_path4, import_node_fs4, esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
1080
|
+
var import_node_path4, import_node_fs4, REACT_REFRESH_RUNTIME, REACT_REFRESH_PREAMBLE, REACT_REFRESH_FOOTER, esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
1064
1081
|
var init_middleware = __esm({
|
|
1065
1082
|
"src/server/middleware.ts"() {
|
|
1066
1083
|
"use strict";
|
|
@@ -1069,6 +1086,25 @@ var init_middleware = __esm({
|
|
|
1069
1086
|
init_transformer();
|
|
1070
1087
|
init_html();
|
|
1071
1088
|
init_env();
|
|
1089
|
+
REACT_REFRESH_RUNTIME = `
|
|
1090
|
+
export function createSignatureFunctionForTransform() {
|
|
1091
|
+
return function(type, key, forceReset, getCustomHooks) { return type; };
|
|
1092
|
+
}
|
|
1093
|
+
export function register(type, id) {}
|
|
1094
|
+
export default { createSignatureFunctionForTransform, register };
|
|
1095
|
+
`;
|
|
1096
|
+
REACT_REFRESH_PREAMBLE = `
|
|
1097
|
+
import RefreshRuntime from '/@react-refresh';
|
|
1098
|
+
if (!window.$RefreshReg$) {
|
|
1099
|
+
window.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, import.meta.url + ' ' + id);
|
|
1100
|
+
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
1101
|
+
}
|
|
1102
|
+
`;
|
|
1103
|
+
REACT_REFRESH_FOOTER = `
|
|
1104
|
+
if (import.meta.hot) {
|
|
1105
|
+
import.meta.hot.accept();
|
|
1106
|
+
}
|
|
1107
|
+
`;
|
|
1072
1108
|
esmBundleCache = /* @__PURE__ */ new Map();
|
|
1073
1109
|
VALID_IDENT = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
1074
1110
|
RESOLVE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".json", ".vue"];
|
|
@@ -1409,7 +1445,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1409
1445
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1410
1446
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1411
1447
|
console.log();
|
|
1412
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.
|
|
1448
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.9"}`));
|
|
1413
1449
|
console.log();
|
|
1414
1450
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1415
1451
|
if (networkUrl) {
|
|
@@ -1487,7 +1523,7 @@ __export(build_exports, {
|
|
|
1487
1523
|
async function build(inlineConfig = {}) {
|
|
1488
1524
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1489
1525
|
const startTime = performance.now();
|
|
1490
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.
|
|
1526
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.9"}`));
|
|
1491
1527
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1492
1528
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1493
1529
|
const outDir = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
@@ -1712,6 +1748,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
1712
1748
|
}
|
|
1713
1749
|
});
|
|
1714
1750
|
cli.help();
|
|
1715
|
-
cli.version("1.3.
|
|
1751
|
+
cli.version("1.3.9");
|
|
1716
1752
|
cli.parse();
|
|
1717
1753
|
//# sourceMappingURL=cli.cjs.map
|