@nasti-toolchain/nasti 1.3.6 → 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 +35 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +35 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +34 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -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),
|
|
@@ -882,6 +890,8 @@ function resolveNodeModule(root, moduleName) {
|
|
|
882
890
|
if (fs4.existsSync(entry)) return entry;
|
|
883
891
|
}
|
|
884
892
|
}
|
|
893
|
+
const indexFallback = path4.join(pkgDir, "index.js");
|
|
894
|
+
if (fs4.existsSync(indexFallback)) return indexFallback;
|
|
885
895
|
return null;
|
|
886
896
|
}
|
|
887
897
|
function resolvePackageExports(exports, key, pkgDir) {
|
|
@@ -1036,13 +1046,32 @@ if (!window.__nasti_hot_map) window.__nasti_hot_map = new Map();
|
|
|
1036
1046
|
window.__NASTI_HMR__ = { createHotContext };
|
|
1037
1047
|
`;
|
|
1038
1048
|
}
|
|
1039
|
-
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;
|
|
1040
1050
|
var init_middleware = __esm({
|
|
1041
1051
|
"src/server/middleware.ts"() {
|
|
1042
1052
|
"use strict";
|
|
1043
1053
|
init_transformer();
|
|
1044
1054
|
init_html();
|
|
1045
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
|
+
`;
|
|
1046
1075
|
esmBundleCache = /* @__PURE__ */ new Map();
|
|
1047
1076
|
VALID_IDENT = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
1048
1077
|
RESOLVE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".json", ".vue"];
|
|
@@ -1387,7 +1416,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1387
1416
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1388
1417
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1389
1418
|
console.log();
|
|
1390
|
-
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"}`));
|
|
1391
1420
|
console.log();
|
|
1392
1421
|
console.log(` ${pc.green(">")} Local: ${pc.cyan(localUrl)}`);
|
|
1393
1422
|
if (networkUrl) {
|
|
@@ -1461,7 +1490,7 @@ import pc2 from "picocolors";
|
|
|
1461
1490
|
async function build(inlineConfig = {}) {
|
|
1462
1491
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1463
1492
|
const startTime = performance.now();
|
|
1464
|
-
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"}`));
|
|
1465
1494
|
console.log(pc2.dim(` root: ${config.root}`));
|
|
1466
1495
|
console.log(pc2.dim(` mode: ${config.mode}`));
|
|
1467
1496
|
const outDir = path10.resolve(config.root, config.build.outDir);
|
|
@@ -1681,6 +1710,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
1681
1710
|
}
|
|
1682
1711
|
});
|
|
1683
1712
|
cli.help();
|
|
1684
|
-
cli.version("1.3.
|
|
1713
|
+
cli.version("1.3.8");
|
|
1685
1714
|
cli.parse();
|
|
1686
1715
|
//# sourceMappingURL=cli.js.map
|