@nasti-toolchain/nasti 2.0.1 → 2.0.2

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 CHANGED
@@ -1489,15 +1489,15 @@ async function doBundlePackage(entryFile, root) {
1489
1489
  const externalBaseDir = import_node_path4.default.dirname(entryFile);
1490
1490
  code = code.replace(
1491
1491
  /^(import\b[^;'"]*?\bfrom\s+)(['"])([^'"./][^'"]*)(\2)/gm,
1492
- (_, prefix, q, spec) => `${prefix}${q}${externalSpecToModuleUrl(spec, externalBaseDir)}${q}`
1492
+ (_, prefix, q, spec) => `${prefix}${q}${externalSpecToModuleUrl(spec, externalBaseDir, root)}${q}`
1493
1493
  ).replace(
1494
1494
  /^(export\b[^;'"]*?\bfrom\s+)(['"])([^'"./][^'"]*)(\2)/gm,
1495
- (_, prefix, q, spec) => `${prefix}${q}${externalSpecToModuleUrl(spec, externalBaseDir)}${q}`
1495
+ (_, prefix, q, spec) => `${prefix}${q}${externalSpecToModuleUrl(spec, externalBaseDir, root)}${q}`
1496
1496
  ).replace(
1497
1497
  /^(import\s+)(['"])([^'"./][^'"]*)(\2)/gm,
1498
- (_, prefix, q, spec) => `${prefix}${q}${externalSpecToModuleUrl(spec, externalBaseDir)}${q}`
1498
+ (_, prefix, q, spec) => `${prefix}${q}${externalSpecToModuleUrl(spec, externalBaseDir, root)}${q}`
1499
1499
  );
1500
- code = rewriteExternalRequires(code, externalBaseDir);
1500
+ code = rewriteExternalRequires(code, externalBaseDir, root);
1501
1501
  if (code.includes("__commonJSMin")) {
1502
1502
  code = await injectCjsNamedExports(code, entryFile);
1503
1503
  }
@@ -1602,7 +1602,7 @@ function pickMainEntryByExtension(pkgDir, preferredExt) {
1602
1602
  }
1603
1603
  return null;
1604
1604
  }
1605
- function rewriteExternalRequires(code, baseDir) {
1605
+ function rewriteExternalRequires(code, baseDir, root) {
1606
1606
  const pkgs = /* @__PURE__ */ new Set();
1607
1607
  const re = /__require\(["']([^"']+)["']\)/g;
1608
1608
  let m;
@@ -1614,7 +1614,7 @@ function rewriteExternalRequires(code, baseDir) {
1614
1614
  const imports = [];
1615
1615
  for (const pkg of pkgs) {
1616
1616
  const safe = pkg.replace(/[^a-zA-Z0-9_$]/g, "_");
1617
- imports.push(`import * as __ns_${safe} from "${externalSpecToModuleUrl(pkg, baseDir)}";`);
1617
+ imports.push(`import * as __ns_${safe} from "${externalSpecToModuleUrl(pkg, baseDir, root)}";`);
1618
1618
  imports.push(`var __req_${safe} = "default" in __ns_${safe} ? __ns_${safe}["default"] : __ns_${safe};`);
1619
1619
  result = result.replaceAll(`__require("${pkg}")`, `__req_${safe}`);
1620
1620
  result = result.replaceAll(`__require('${pkg}')`, `__req_${safe}`);
@@ -1711,9 +1711,12 @@ function isUnderRoot(abs, root) {
1711
1711
  const rel = import_node_path4.default.relative(root, abs);
1712
1712
  return !!rel && !rel.startsWith("..") && !import_node_path4.default.isAbsolute(rel);
1713
1713
  }
1714
- function externalSpecToModuleUrl(spec, baseDir) {
1714
+ function externalSpecToModuleUrl(spec, baseDir, root) {
1715
1715
  const resolved = resolveNodeModule(baseDir, spec);
1716
- return resolved ? `/@modules/${spec}?id=${encodeURIComponent(resolved)}` : `/@modules/${spec}`;
1716
+ if (!resolved) return `/@modules/${spec}`;
1717
+ const rootResolved = resolveNodeModule(root, spec);
1718
+ if (rootResolved && rootResolved === resolved) return `/@modules/${spec}`;
1719
+ return `/@modules/${spec}?id=${encodeURIComponent(resolved)}`;
1717
1720
  }
1718
1721
  function resolveNodeModule(baseDir, moduleName) {
1719
1722
  const resolved = resolveNodeModuleEntry(baseDir, moduleName);
@@ -4033,7 +4036,7 @@ async function build(inlineConfig = {}) {
4033
4036
  const startTime = performance.now();
4034
4037
  logger.info(
4035
4038
  import_picocolors6.default.cyan(`
4036
- nasti v${"2.0.1"} `) + import_picocolors6.default.green(`building for ${config.mode}...`)
4039
+ nasti v${"2.0.2"} `) + import_picocolors6.default.green(`building for ${config.mode}...`)
4037
4040
  );
4038
4041
  debug5?.(`root: ${config.root}`);
4039
4042
  const buildableNames = Object.keys(config.environments).filter(
@@ -4752,7 +4755,7 @@ async function createServer(inlineConfig = {}) {
4752
4755
  const readyIn = Math.ceil(performance.now() - startTime);
4753
4756
  logger.info(
4754
4757
  `
4755
- ${import_picocolors8.default.cyan(import_picocolors8.default.bold("NASTI"))} ${import_picocolors8.default.cyan(`v${"2.0.1"}`)} ${import_picocolors8.default.dim("ready in")} ${import_picocolors8.default.bold(readyIn)} ${import_picocolors8.default.dim("ms")}
4758
+ ${import_picocolors8.default.cyan(import_picocolors8.default.bold("NASTI"))} ${import_picocolors8.default.cyan(`v${"2.0.2"}`)} ${import_picocolors8.default.dim("ready in")} ${import_picocolors8.default.bold(readyIn)} ${import_picocolors8.default.dim("ms")}
4756
4759
  `
4757
4760
  );
4758
4761
  printServerUrls(
@@ -4886,7 +4889,7 @@ async function buildElectron(inlineConfig = {}) {
4886
4889
  const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
4887
4890
  const startTime = performance.now();
4888
4891
  assertElectronVersion(config);
4889
- console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.0.1"}`));
4892
+ console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.0.2"}`));
4890
4893
  console.log(import_picocolors9.default.dim(` root: ${config.root}`));
4891
4894
  console.log(import_picocolors9.default.dim(` mode: ${config.mode}`));
4892
4895
  console.log(import_picocolors9.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
@@ -5042,7 +5045,7 @@ async function startElectronDev(inlineConfig = {}) {
5042
5045
  const { noSpawn, ...rest } = inlineConfig;
5043
5046
  const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
5044
5047
  warnElectronVersion(config);
5045
- console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.0.1"}`));
5048
+ console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.0.2"}`));
5046
5049
  const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
5047
5050
  const server = await createServer2({ ...rest, target: "electron" });
5048
5051
  await server.listen();
@@ -5395,7 +5398,7 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
5395
5398
  const host = options.host === true ? "0.0.0.0" : options.host ?? "localhost";
5396
5399
  http2.createServer(app).listen(port, host, () => {
5397
5400
  logger.info(`
5398
- ${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.0.1"}`)} ${import_picocolors11.default.dim("preview")}
5401
+ ${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.0.2"}`)} ${import_picocolors11.default.dim("preview")}
5399
5402
  `);
5400
5403
  printServerUrls2(
5401
5404
  {
@@ -5412,6 +5415,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
5412
5415
  }
5413
5416
  });
5414
5417
  cli.help();
5415
- cli.version("2.0.1");
5418
+ cli.version("2.0.2");
5416
5419
  cli.parse();
5417
5420
  //# sourceMappingURL=cli.cjs.map