@d1g1tal/tsbuild 1.8.4 → 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,26 @@
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
+
7
+ ## [1.8.5](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.8.4...v1.8.5) (2026-04-14)
8
+
9
+ ### Bug Fixes
10
+
11
+ * **iife:** resolve paths absolutely and output to nested directory (7514592a039f02e070b71f4c30c6cd88a99bd17d)
12
+ - Changes IIFE output to resolve paths absolutely instead of relatively
13
+ - Creates a dedicated `iife` output directory under the main `outdir`
14
+ - Fixes virtual loader plugin to handle the new directory structure properly
15
+ - Adds an integration test for IIFE builds
16
+
17
+
18
+ ### Build System
19
+
20
+ * **deps-dev:** bump typescript-eslint dependencies (e4abe9fe4083b89953f94f4cd17622387844b844)
21
+ - Updates `@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser`, and `typescript-eslint` from 8.58.1 to 8.58.2
22
+ - Updates `pnpm-lock.yaml` with the new versions and their sub-dependencies
23
+
1
24
  ## [1.8.4](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.8.3...v1.8.4) (2026-04-12)
2
25
 
3
26
  ### Performance Improvements
@@ -1624,63 +1624,74 @@ 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+)$/;
1627
+ var namespace = "iife";
1629
1628
  function wrapAsIife(text, globalName) {
1630
- const exportIndex = text.lastIndexOf("export");
1631
- if (exportIndex === -1) {
1629
+ const exportStart = text.lastIndexOf("export");
1630
+ if (exportStart === -1) {
1632
1631
  return text;
1633
1632
  }
1634
- exportRegex.lastIndex = exportIndex;
1635
- const last = exportRegex.exec(text);
1636
- 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() !== "") {
1637
1636
  return text;
1638
1637
  }
1639
- const props = [];
1640
- for (const raw of last[1].split(",")) {
1641
- const trimmed = raw.trim();
1642
- 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) {
1649
+ continue;
1650
+ }
1651
+ const asIndex = member.indexOf(" as ");
1652
+ if (asIndex <= 0) {
1653
+ properties.push(member);
1643
1654
  continue;
1644
1655
  }
1645
- const m = exportAliasRegex.exec(trimmed);
1646
- props.push(m ? `${m[2]}: ${m[1]}` : trimmed);
1656
+ const localName = member.slice(0, asIndex).trim();
1657
+ const exportName = member.slice(asIndex + 4).trim();
1658
+ properties.push(localName && exportName ? `${exportName}: ${localName}` : member);
1647
1659
  }
1648
- if (props.length === 0) {
1660
+ if (properties.length === 0) {
1649
1661
  return text;
1650
1662
  }
1651
- const assignment = globalName ? `globalThis.${globalName} = { ${props.join(", ")} };` : `Object.assign(globalThis, { ${props.join(", ")} });`;
1652
- const body = text.slice(0, last.index);
1653
- 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} });`;
1654
1665
  return `(() => {
1655
- ${body}
1666
+ ${text.slice(0, exportStart)}
1656
1667
  ${assignment}
1657
- })();${after}`;
1668
+ })();${text.slice(exportEnd)}`;
1658
1669
  }
1659
1670
  async function buildIife(outputs, entryPointNames, outdir, globalName, sourcemap) {
1660
1671
  const { build: esbuild } = await import("esbuild");
1661
1672
  const fileContents = /* @__PURE__ */ new Map();
1662
1673
  for (const outputPath of Object.keys(outputs)) {
1663
1674
  if (outputPath.endsWith(jsExtension)) {
1664
- fileContents.set(outputPath, await readFile2(outputPath, "utf8"));
1675
+ fileContents.set(resolve2(outputPath), await readFile2(outputPath, "utf8"));
1665
1676
  }
1666
1677
  }
1667
1678
  const validEntries = [];
1668
1679
  for (const name of entryPointNames) {
1669
- const absPath = join(outdir, name + jsExtension);
1670
- if (fileContents.has(absPath)) {
1671
- validEntries.push({ name, absPath });
1680
+ const path = Paths.absolute(outdir, name + jsExtension);
1681
+ if (fileContents.has(path)) {
1682
+ validEntries.push({ name, path });
1672
1683
  }
1673
1684
  }
1674
1685
  if (validEntries.length === 0) {
1675
1686
  return [];
1676
1687
  }
1677
1688
  const hasSourceMap = sourcemap !== void 0 && sourcemap !== false;
1678
- const iifeOutdir = join(outdir, "iife");
1679
- const loaderPlugin = virtualLoaderPlugin(fileContents);
1689
+ const plugins = [virtualLoaderPlugin(fileContents)];
1690
+ const iifeOutdir = join(outdir, namespace);
1680
1691
  await mkdir3(iifeOutdir, { recursive: true });
1681
- const results = await Promise.all(validEntries.map(
1682
- ({ name, absPath }) => esbuild({
1683
- entryPoints: { [name]: absPath },
1692
+ const results = await Promise.all(validEntries.map(({ name, path }) => {
1693
+ return esbuild({
1694
+ entryPoints: { [name]: path },
1684
1695
  bundle: true,
1685
1696
  format: "esm",
1686
1697
  splitting: false,
@@ -1688,16 +1699,21 @@ async function buildIife(outputs, entryPointNames, outdir, globalName, sourcemap
1688
1699
  sourcemap: hasSourceMap ? "external" : false,
1689
1700
  write: false,
1690
1701
  logLevel: "warning",
1691
- plugins: [loaderPlugin]
1692
- })
1693
- ));
1702
+ plugins
1703
+ });
1704
+ }));
1694
1705
  const written = [];
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 {
@@ -1719,23 +1735,20 @@ function virtualLoaderPlugin(fileContents) {
1719
1735
  setup(build) {
1720
1736
  build.onResolve({ filter: /.*/ }, (args) => {
1721
1737
  if (args.kind === "entry-point") {
1722
- return { path: args.path, namespace: "iife" };
1738
+ return { path: args.path, namespace };
1723
1739
  }
1724
1740
  if (!args.path.startsWith(".") && !args.path.startsWith("/")) {
1725
1741
  return { external: true };
1726
1742
  }
1727
1743
  const resolved = resolve2(args.resolveDir, args.path);
1728
1744
  if (fileContents.has(resolved)) {
1729
- return { path: resolved, namespace: "iife" };
1745
+ return { path: resolved, namespace };
1730
1746
  }
1731
1747
  return { external: true };
1732
1748
  });
1733
- build.onLoad({ filter: /.*/, namespace: "iife" }, (args) => {
1749
+ build.onLoad({ filter: /.*/, namespace }, (args) => {
1734
1750
  const contents = fileContents.get(args.path);
1735
- if (contents !== void 0) {
1736
- return { contents, loader: "js", resolveDir: dirname2(args.path) };
1737
- }
1738
- return null;
1751
+ return contents === void 0 ? null : { contents, loader: "js", resolveDir: dirname2(args.path) };
1739
1752
  });
1740
1753
  }
1741
1754
  };
@@ -2427,7 +2440,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2427
2440
  return Files.empty(this.buildConfiguration.outDir);
2428
2441
  }
2429
2442
  async build() {
2430
- Logger.header(`${tsLogo} tsbuild v${"1.8.4"}${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]" : ""}`);
2431
2444
  try {
2432
2445
  const processes = [];
2433
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 "./23A5VAYC.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.4");
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 "./23A5VAYC.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.4",
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",
@@ -51,8 +51,8 @@
51
51
  "devDependencies": {
52
52
  "@eslint/js": "^10.0.1",
53
53
  "@types/node": "^25.6.0",
54
- "@typescript-eslint/eslint-plugin": "^8.58.1",
55
- "@typescript-eslint/parser": "^8.58.1",
54
+ "@typescript-eslint/eslint-plugin": "^8.58.2",
55
+ "@typescript-eslint/parser": "^8.58.2",
56
56
  "@vitest/coverage-v8": "^4.1.4",
57
57
  "eslint": "^10.2.0",
58
58
  "eslint-plugin-jsdoc": "^62.9.0",
@@ -60,7 +60,7 @@
60
60
  "memfs": "^4.57.1",
61
61
  "tsx": "^4.21.0",
62
62
  "typescript": "^6.0.2",
63
- "typescript-eslint": "^8.58.1",
63
+ "typescript-eslint": "^8.58.2",
64
64
  "vitest": "^4.1.4"
65
65
  },
66
66
  "peerDependencies": {