@nasti-toolchain/nasti 1.3.7 → 1.3.8
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 +33 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +33 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +32 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -695,15 +695,18 @@ function transformMiddleware(ctx) {
|
|
|
695
695
|
}
|
|
696
696
|
async function transformRequest(url, ctx) {
|
|
697
697
|
const { config, pluginContainer, moduleGraph } = ctx;
|
|
698
|
+
const cleanReqUrl = url.split("?")[0];
|
|
698
699
|
const cached = moduleGraph.getModuleByUrl(url);
|
|
699
700
|
if (cached?.transformResult) {
|
|
700
701
|
return cached.transformResult;
|
|
701
702
|
}
|
|
703
|
+
if (cleanReqUrl === "/@react-refresh") {
|
|
704
|
+
return { code: REACT_REFRESH_RUNTIME };
|
|
705
|
+
}
|
|
702
706
|
const filePath = resolveUrlToFile(url, config.root);
|
|
703
707
|
if (!filePath || !fs4.existsSync(filePath)) return null;
|
|
704
708
|
const mod = await moduleGraph.ensureEntryFromUrl(url);
|
|
705
709
|
moduleGraph.registerModule(mod, filePath);
|
|
706
|
-
const cleanReqUrl = url.split("?")[0];
|
|
707
710
|
if (cleanReqUrl.startsWith("/@modules/")) {
|
|
708
711
|
const code2 = await bundlePackageAsEsm(filePath);
|
|
709
712
|
const transformResult2 = { code: code2 };
|
|
@@ -716,13 +719,18 @@ async function transformRequest(url, ctx) {
|
|
|
716
719
|
code = typeof pluginResult === "string" ? pluginResult : pluginResult.code;
|
|
717
720
|
}
|
|
718
721
|
if (shouldTransform(filePath)) {
|
|
722
|
+
const isJsx = /\.[jt]sx$/.test(filePath);
|
|
723
|
+
const useRefresh = isJsx && config.framework !== "vue";
|
|
719
724
|
const result = transformCode(filePath, code, {
|
|
720
725
|
sourcemap: true,
|
|
721
726
|
jsxRuntime: "automatic",
|
|
722
727
|
jsxImportSource: config.framework === "vue" ? "vue" : "react",
|
|
723
|
-
reactRefresh:
|
|
728
|
+
reactRefresh: useRefresh
|
|
724
729
|
});
|
|
725
730
|
code = result.code;
|
|
731
|
+
if (useRefresh) {
|
|
732
|
+
code = REACT_REFRESH_PREAMBLE + code + REACT_REFRESH_FOOTER;
|
|
733
|
+
}
|
|
726
734
|
}
|
|
727
735
|
const envDefine = ctx.envDefine ?? buildEnvDefine(
|
|
728
736
|
loadEnv(config.mode, config.root, config.envPrefix),
|
|
@@ -1038,13 +1046,32 @@ if (!window.__nasti_hot_map) window.__nasti_hot_map = new Map();
|
|
|
1038
1046
|
window.__NASTI_HMR__ = { createHotContext };
|
|
1039
1047
|
`;
|
|
1040
1048
|
}
|
|
1041
|
-
var esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
1049
|
+
var REACT_REFRESH_RUNTIME, REACT_REFRESH_PREAMBLE, REACT_REFRESH_FOOTER, esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
1042
1050
|
var init_middleware = __esm({
|
|
1043
1051
|
"src/server/middleware.ts"() {
|
|
1044
1052
|
"use strict";
|
|
1045
1053
|
init_transformer();
|
|
1046
1054
|
init_html();
|
|
1047
1055
|
init_env();
|
|
1056
|
+
REACT_REFRESH_RUNTIME = `
|
|
1057
|
+
export function createSignatureFunctionForTransform() {
|
|
1058
|
+
return function(type, key, forceReset, getCustomHooks) { return type; };
|
|
1059
|
+
}
|
|
1060
|
+
export function register(type, id) {}
|
|
1061
|
+
export default { createSignatureFunctionForTransform, register };
|
|
1062
|
+
`;
|
|
1063
|
+
REACT_REFRESH_PREAMBLE = `
|
|
1064
|
+
import RefreshRuntime from '/@react-refresh';
|
|
1065
|
+
if (!window.$RefreshReg$) {
|
|
1066
|
+
window.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, import.meta.url + ' ' + id);
|
|
1067
|
+
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
1068
|
+
}
|
|
1069
|
+
`;
|
|
1070
|
+
REACT_REFRESH_FOOTER = `
|
|
1071
|
+
if (import.meta.hot) {
|
|
1072
|
+
import.meta.hot.accept();
|
|
1073
|
+
}
|
|
1074
|
+
`;
|
|
1048
1075
|
esmBundleCache = /* @__PURE__ */ new Map();
|
|
1049
1076
|
VALID_IDENT = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
1050
1077
|
RESOLVE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".json", ".vue"];
|
|
@@ -1389,7 +1416,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1389
1416
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1390
1417
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1391
1418
|
console.log();
|
|
1392
|
-
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.3.
|
|
1419
|
+
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.3.8"}`));
|
|
1393
1420
|
console.log();
|
|
1394
1421
|
console.log(` ${pc.green(">")} Local: ${pc.cyan(localUrl)}`);
|
|
1395
1422
|
if (networkUrl) {
|
|
@@ -1463,7 +1490,7 @@ import pc2 from "picocolors";
|
|
|
1463
1490
|
async function build(inlineConfig = {}) {
|
|
1464
1491
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1465
1492
|
const startTime = performance.now();
|
|
1466
|
-
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.3.
|
|
1493
|
+
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.3.8"}`));
|
|
1467
1494
|
console.log(pc2.dim(` root: ${config.root}`));
|
|
1468
1495
|
console.log(pc2.dim(` mode: ${config.mode}`));
|
|
1469
1496
|
const outDir = path10.resolve(config.root, config.build.outDir);
|
|
@@ -1683,6 +1710,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
1683
1710
|
}
|
|
1684
1711
|
});
|
|
1685
1712
|
cli.help();
|
|
1686
|
-
cli.version("1.3.
|
|
1713
|
+
cli.version("1.3.8");
|
|
1687
1714
|
cli.parse();
|
|
1688
1715
|
//# sourceMappingURL=cli.js.map
|