@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.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),
|
|
@@ -904,6 +912,8 @@ function resolveNodeModule(root, moduleName) {
|
|
|
904
912
|
if (import_node_fs4.default.existsSync(entry)) return entry;
|
|
905
913
|
}
|
|
906
914
|
}
|
|
915
|
+
const indexFallback = import_node_path4.default.join(pkgDir, "index.js");
|
|
916
|
+
if (import_node_fs4.default.existsSync(indexFallback)) return indexFallback;
|
|
907
917
|
return null;
|
|
908
918
|
}
|
|
909
919
|
function resolvePackageExports(exports2, key, pkgDir) {
|
|
@@ -1058,7 +1068,7 @@ if (!window.__nasti_hot_map) window.__nasti_hot_map = new Map();
|
|
|
1058
1068
|
window.__NASTI_HMR__ = { createHotContext };
|
|
1059
1069
|
`;
|
|
1060
1070
|
}
|
|
1061
|
-
var import_node_path4, import_node_fs4, esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
1071
|
+
var import_node_path4, import_node_fs4, REACT_REFRESH_RUNTIME, REACT_REFRESH_PREAMBLE, REACT_REFRESH_FOOTER, esmBundleCache, VALID_IDENT, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
1062
1072
|
var init_middleware = __esm({
|
|
1063
1073
|
"src/server/middleware.ts"() {
|
|
1064
1074
|
"use strict";
|
|
@@ -1067,6 +1077,25 @@ var init_middleware = __esm({
|
|
|
1067
1077
|
init_transformer();
|
|
1068
1078
|
init_html();
|
|
1069
1079
|
init_env();
|
|
1080
|
+
REACT_REFRESH_RUNTIME = `
|
|
1081
|
+
export function createSignatureFunctionForTransform() {
|
|
1082
|
+
return function(type, key, forceReset, getCustomHooks) { return type; };
|
|
1083
|
+
}
|
|
1084
|
+
export function register(type, id) {}
|
|
1085
|
+
export default { createSignatureFunctionForTransform, register };
|
|
1086
|
+
`;
|
|
1087
|
+
REACT_REFRESH_PREAMBLE = `
|
|
1088
|
+
import RefreshRuntime from '/@react-refresh';
|
|
1089
|
+
if (!window.$RefreshReg$) {
|
|
1090
|
+
window.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, import.meta.url + ' ' + id);
|
|
1091
|
+
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
1092
|
+
}
|
|
1093
|
+
`;
|
|
1094
|
+
REACT_REFRESH_FOOTER = `
|
|
1095
|
+
if (import.meta.hot) {
|
|
1096
|
+
import.meta.hot.accept();
|
|
1097
|
+
}
|
|
1098
|
+
`;
|
|
1070
1099
|
esmBundleCache = /* @__PURE__ */ new Map();
|
|
1071
1100
|
VALID_IDENT = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
1072
1101
|
RESOLVE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".json", ".vue"];
|
|
@@ -1407,7 +1436,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1407
1436
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1408
1437
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1409
1438
|
console.log();
|
|
1410
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.
|
|
1439
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.8"}`));
|
|
1411
1440
|
console.log();
|
|
1412
1441
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1413
1442
|
if (networkUrl) {
|
|
@@ -1485,7 +1514,7 @@ __export(build_exports, {
|
|
|
1485
1514
|
async function build(inlineConfig = {}) {
|
|
1486
1515
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1487
1516
|
const startTime = performance.now();
|
|
1488
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.
|
|
1517
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.8"}`));
|
|
1489
1518
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1490
1519
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1491
1520
|
const outDir = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
@@ -1710,6 +1739,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
1710
1739
|
}
|
|
1711
1740
|
});
|
|
1712
1741
|
cli.help();
|
|
1713
|
-
cli.version("1.3.
|
|
1742
|
+
cli.version("1.3.8");
|
|
1714
1743
|
cli.parse();
|
|
1715
1744
|
//# sourceMappingURL=cli.cjs.map
|