@nasti-toolchain/nasti 1.3.4 → 1.3.6
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/README.md +1 -1
- package/dist/cli.cjs +23 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +23 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -786,17 +786,36 @@ async function doBundlePackage(entryFile) {
|
|
|
786
786
|
/^(import\s+)(['"])([^'"./][^'"]*)(\2)/gm,
|
|
787
787
|
(_, prefix, q, spec) => `${prefix}${q}/@modules/${spec}${q}`
|
|
788
788
|
);
|
|
789
|
+
code = rewriteExternalRequires(code);
|
|
789
790
|
if (code.includes("__commonJSMin")) {
|
|
790
791
|
code = await injectCjsNamedExports(code, entryFile);
|
|
791
792
|
}
|
|
792
793
|
return code;
|
|
793
794
|
}
|
|
795
|
+
function rewriteExternalRequires(code) {
|
|
796
|
+
const pkgs = /* @__PURE__ */ new Set();
|
|
797
|
+
const re = /__require\(["']([^"']+)["']\)/g;
|
|
798
|
+
let m;
|
|
799
|
+
while ((m = re.exec(code)) !== null) {
|
|
800
|
+
pkgs.add(m[1]);
|
|
801
|
+
}
|
|
802
|
+
if (pkgs.size === 0) return code;
|
|
803
|
+
let result = code;
|
|
804
|
+
const imports = [];
|
|
805
|
+
for (const pkg of pkgs) {
|
|
806
|
+
const safe = pkg.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
807
|
+
imports.push(`import __req_${safe} from "/@modules/${pkg}";`);
|
|
808
|
+
result = result.replaceAll(`__require("${pkg}")`, `__req_${safe}`);
|
|
809
|
+
result = result.replaceAll(`__require('${pkg}')`, `__req_${safe}`);
|
|
810
|
+
}
|
|
811
|
+
return imports.join("\n") + "\n" + result;
|
|
812
|
+
}
|
|
794
813
|
async function injectCjsNamedExports(code, entryFile) {
|
|
795
814
|
try {
|
|
796
815
|
const { createRequire: createRequire2 } = await import("module");
|
|
797
816
|
const req = createRequire2(entryFile);
|
|
798
817
|
const cjsExports = req(entryFile);
|
|
799
|
-
if (!cjsExports || typeof cjsExports !== "object" || Array.isArray(cjsExports)) return code;
|
|
818
|
+
if (!cjsExports || typeof cjsExports !== "object" && typeof cjsExports !== "function" || Array.isArray(cjsExports)) return code;
|
|
800
819
|
const namedKeys = Object.keys(cjsExports).filter(
|
|
801
820
|
(k) => k !== "__esModule" && k !== "default" && VALID_IDENT.test(k)
|
|
802
821
|
);
|
|
@@ -1388,7 +1407,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1388
1407
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1389
1408
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1390
1409
|
console.log();
|
|
1391
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.
|
|
1410
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.6"}`));
|
|
1392
1411
|
console.log();
|
|
1393
1412
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1394
1413
|
if (networkUrl) {
|
|
@@ -1466,7 +1485,7 @@ __export(build_exports, {
|
|
|
1466
1485
|
async function build(inlineConfig = {}) {
|
|
1467
1486
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1468
1487
|
const startTime = performance.now();
|
|
1469
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.
|
|
1488
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.6"}`));
|
|
1470
1489
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1471
1490
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1472
1491
|
const outDir = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
@@ -1691,6 +1710,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
1691
1710
|
}
|
|
1692
1711
|
});
|
|
1693
1712
|
cli.help();
|
|
1694
|
-
cli.version("1.3.
|
|
1713
|
+
cli.version("1.3.6");
|
|
1695
1714
|
cli.parse();
|
|
1696
1715
|
//# sourceMappingURL=cli.cjs.map
|