@d1g1tal/tsbuild 1.8.5 → 1.8.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [1.8.6](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.8.5...v1.8.6) (2026-04-14)
2
+
3
+ ### Bug Fixes
4
+
5
+ * ensure the source map is referenced in the iife output when source maps are enabled (f6bc57d11cfd7f8289f85c37aea5b6ff983fc302)
6
+
1
7
  ## [1.8.5](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.8.4...v1.8.5) (2026-04-14)
2
8
 
3
9
  ### Bug Fixes
@@ -1624,38 +1624,48 @@ function extractEntryNames(entryPoints) {
1624
1624
  }
1625
1625
  return Object.keys(entryPoints);
1626
1626
  }
1627
- var exportRegex = /export\s*\{([^}]*)\};?/g;
1628
- var exportAliasRegex = /^(\w+)\s+as\s+(\w+)$/;
1629
1627
  var namespace = "iife";
1630
1628
  function wrapAsIife(text, globalName) {
1631
- const exportIndex = text.lastIndexOf("export");
1632
- if (exportIndex === -1) {
1629
+ const exportStart = text.lastIndexOf("export");
1630
+ if (exportStart === -1) {
1633
1631
  return text;
1634
1632
  }
1635
- exportRegex.lastIndex = exportIndex;
1636
- const last = exportRegex.exec(text);
1637
- if (!last) {
1633
+ const openBrace = text.indexOf("{", exportStart + 6);
1634
+ const closeBrace = text.indexOf("}", openBrace + 1);
1635
+ if (openBrace === -1 || closeBrace === -1 || text.slice(exportStart + 6, openBrace).trim() !== "") {
1638
1636
  return text;
1639
1637
  }
1640
- const props = [];
1641
- for (const raw of last[1].split(",")) {
1642
- const trimmed = raw.trim();
1643
- if (!trimmed) {
1638
+ let exportEnd = closeBrace + 1;
1639
+ while (exportEnd < text.length && /[ \t]/.test(text[exportEnd] ?? "")) {
1640
+ exportEnd += 1;
1641
+ }
1642
+ if (text[exportEnd] === ";") {
1643
+ exportEnd += 1;
1644
+ }
1645
+ const properties = [];
1646
+ for (const rawMember of text.slice(openBrace + 1, closeBrace).split(",")) {
1647
+ const member = rawMember.trim();
1648
+ if (!member) {
1644
1649
  continue;
1645
1650
  }
1646
- const m = exportAliasRegex.exec(trimmed);
1647
- props.push(m ? `${m[2]}: ${m[1]}` : trimmed);
1651
+ const asIndex = member.indexOf(" as ");
1652
+ if (asIndex <= 0) {
1653
+ properties.push(member);
1654
+ continue;
1655
+ }
1656
+ const localName = member.slice(0, asIndex).trim();
1657
+ const exportName = member.slice(asIndex + 4).trim();
1658
+ properties.push(localName && exportName ? `${exportName}: ${localName}` : member);
1648
1659
  }
1649
- if (props.length === 0) {
1660
+ if (properties.length === 0) {
1650
1661
  return text;
1651
1662
  }
1652
- const assignment = globalName ? `globalThis.${globalName} = { ${props.join(", ")} };` : `Object.assign(globalThis, { ${props.join(", ")} });`;
1653
- const body = text.slice(0, last.index);
1654
- const after = text.slice(last.index + last[0].length);
1663
+ const exportedObject = properties.join(", ");
1664
+ const assignment = globalName ? `globalThis.${globalName} = { ${exportedObject} };` : `Object.assign(globalThis, { ${exportedObject} });`;
1655
1665
  return `(() => {
1656
- ${body}
1666
+ ${text.slice(0, exportStart)}
1657
1667
  ${assignment}
1658
- })();${after}`;
1668
+ })();${text.slice(exportEnd)}`;
1659
1669
  }
1660
1670
  async function buildIife(outputs, entryPointNames, outdir, globalName, sourcemap) {
1661
1671
  const { build: esbuild } = await import("esbuild");
@@ -1677,7 +1687,8 @@ async function buildIife(outputs, entryPointNames, outdir, globalName, sourcemap
1677
1687
  }
1678
1688
  const hasSourceMap = sourcemap !== void 0 && sourcemap !== false;
1679
1689
  const plugins = [virtualLoaderPlugin(fileContents)];
1680
- const iifeOutdir = await mkdir3(join(outdir, namespace), { recursive: true });
1690
+ const iifeOutdir = join(outdir, namespace);
1691
+ await mkdir3(iifeOutdir, { recursive: true });
1681
1692
  const results = await Promise.all(validEntries.map(({ name, path }) => {
1682
1693
  return esbuild({
1683
1694
  entryPoints: { [name]: path },
@@ -1695,9 +1706,14 @@ async function buildIife(outputs, entryPointNames, outdir, globalName, sourcemap
1695
1706
  const writes = [];
1696
1707
  const cwd = process.cwd();
1697
1708
  for (const { outputFiles: iifeFiles } of results) {
1709
+ const outputFilePaths = new Set(iifeFiles.map(({ path }) => path));
1698
1710
  for (const { path, contents } of iifeFiles) {
1699
1711
  if (path.endsWith(jsExtension)) {
1700
- const text = wrapAsIife(textDecoder.decode(contents), globalName);
1712
+ let text = wrapAsIife(textDecoder.decode(contents), globalName);
1713
+ if (outputFilePaths.has(`${path}.map`)) {
1714
+ text += `
1715
+ //# sourceMappingURL=${basename2(path)}.map`;
1716
+ }
1701
1717
  writes.push(writeFile3(path, text));
1702
1718
  written.push({ path: Paths.relative(cwd, path), size: Buffer.byteLength(text) });
1703
1719
  } else {
@@ -2424,7 +2440,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2424
2440
  return Files.empty(this.buildConfiguration.outDir);
2425
2441
  }
2426
2442
  async build() {
2427
- Logger.header(`${tsLogo} tsbuild v${"1.8.5"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2443
+ Logger.header(`${tsLogo} tsbuild v${"1.8.6"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2428
2444
  try {
2429
2445
  const processes = [];
2430
2446
  const filesWereEmitted = await this.typeCheck();
package/dist/tsbuild.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BuildError,
4
4
  TypeScriptProject
5
- } from "./WCBM4DJB.js";
5
+ } from "./2LQAKZEG.js";
6
6
  import "./JKGYA2AW.js";
7
7
 
8
8
  // src/tsbuild.ts
@@ -30,7 +30,7 @@ if (help) {
30
30
  process.exit(0);
31
31
  }
32
32
  if (version) {
33
- console.log("1.8.5");
33
+ console.log("1.8.6");
34
34
  process.exit(0);
35
35
  }
36
36
  var typeScriptOptions = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TypeScriptProject
3
- } from "./WCBM4DJB.js";
3
+ } from "./2LQAKZEG.js";
4
4
  import "./JKGYA2AW.js";
5
5
  export {
6
6
  TypeScriptProject
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d1g1tal/tsbuild",
3
3
  "author": "D1g1talEntr0py",
4
- "version": "1.8.5",
4
+ "version": "1.8.6",
5
5
  "license": "MIT",
6
6
  "description": "A fast, ESM-only TypeScript build tool combining the TypeScript API for type checking and declaration generation, esbuild for bundling, and SWC for decorator metadata.",
7
7
  "homepage": "https://github.com/D1g1talEntr0py/tsbuild#readme",