@d1g1tal/tsbuild 1.8.0 → 1.8.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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [1.8.2](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.8.1...v1.8.2) (2026-04-09)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **build:** add handling for modules where the export uses 'as' (d96f626e7329188e702cd32bd8ba028810647d06)
6
+
7
+ ## [1.8.1](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.8.0...v1.8.1) (2026-04-09)
8
+
9
+ ### Bug Fixes
10
+
11
+ * **iife:** ensure module exports are added to 'globalThis' (23933af3534c86b20ee364aae67e955d3cf374a6)
12
+ - change esbuild format from iife to esm to capture exports
13
+ - add wrapAsIife function to manually wrap esm content and assign exports
14
+ - execute esbuild per entry point to inline all dynamic chunks
15
+ - update tests to verify global export assignments and correct build options
16
+
1
17
  ## [1.8.0](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.7.5...v1.8.0) (2026-04-09)
2
18
 
3
19
  ### Features
@@ -1570,6 +1570,38 @@ function extractEntryNames(entryPoints) {
1570
1570
  }
1571
1571
  return Object.keys(entryPoints);
1572
1572
  }
1573
+ var exportRe = /export\s*\{([^}]*)\};?/g;
1574
+ var asRe = /^(\w+)\s+as\s+(\w+)$/;
1575
+ function wrapAsIife(text, globalName) {
1576
+ let last = null;
1577
+ let match;
1578
+ exportRe.lastIndex = 0;
1579
+ while ((match = exportRe.exec(text)) !== null) {
1580
+ last = match;
1581
+ }
1582
+ if (!last) {
1583
+ return text;
1584
+ }
1585
+ const props = [];
1586
+ for (const raw of last[1].split(",")) {
1587
+ const trimmed = raw.trim();
1588
+ if (!trimmed) {
1589
+ continue;
1590
+ }
1591
+ const m = asRe.exec(trimmed);
1592
+ props.push(m ? `${m[2]}: ${m[1]}` : trimmed);
1593
+ }
1594
+ if (props.length === 0) {
1595
+ return text;
1596
+ }
1597
+ const assignment = globalName ? `globalThis.${globalName} = { ${props.join(", ")} };` : `Object.assign(globalThis, { ${props.join(", ")} });`;
1598
+ const body = text.slice(0, last.index);
1599
+ const after = text.slice(last.index + last[0].length);
1600
+ return `(() => {
1601
+ ${body}
1602
+ ${assignment}
1603
+ })();${after}`;
1604
+ }
1573
1605
  async function buildIife(outputFiles, entryPointNames, outdir, globalName, sourcemap) {
1574
1606
  const fileContents = /* @__PURE__ */ new Map();
1575
1607
  for (const file of outputFiles) {
@@ -1577,43 +1609,45 @@ async function buildIife(outputFiles, entryPointNames, outdir, globalName, sourc
1577
1609
  fileContents.set(file.path, textDecoder2.decode(file.contents));
1578
1610
  }
1579
1611
  }
1580
- const entryPoints = {};
1612
+ const validEntries = [];
1581
1613
  for (const name of entryPointNames) {
1582
1614
  const absPath = join(outdir, name + jsExtension);
1583
1615
  if (fileContents.has(absPath)) {
1584
- entryPoints[name] = absPath;
1616
+ validEntries.push({ name, absPath });
1585
1617
  }
1586
1618
  }
1587
- if (Object.keys(entryPoints).length === 0) {
1619
+ if (validEntries.length === 0) {
1588
1620
  return [];
1589
1621
  }
1590
1622
  const hasSourceMap = sourcemap !== void 0 && sourcemap !== false;
1591
1623
  const iifeOutdir = join(outdir, "iife");
1592
- const { outputFiles: iifeFiles } = await esbuild({
1593
- entryPoints,
1594
- bundle: true,
1595
- format: "iife",
1596
- globalName,
1597
- splitting: false,
1598
- outdir: iifeOutdir,
1599
- sourcemap: hasSourceMap ? "external" : false,
1600
- write: false,
1601
- logLevel: "warning",
1602
- footer: globalName ? { js: `globalThis.${globalName} = ${globalName};` } : void 0,
1603
- plugins: [virtualLoaderPlugin(fileContents)]
1604
- });
1605
- const entryOutputs = /* @__PURE__ */ new Set();
1606
- for (const name of entryPointNames) {
1607
- entryOutputs.add(join(iifeOutdir, name + jsExtension));
1608
- }
1624
+ const loaderPlugin = virtualLoaderPlugin(fileContents);
1609
1625
  await mkdir3(iifeOutdir, { recursive: true });
1626
+ const results = await Promise.all(validEntries.map(
1627
+ ({ name, absPath }) => esbuild({
1628
+ entryPoints: { [name]: absPath },
1629
+ bundle: true,
1630
+ format: "esm",
1631
+ splitting: false,
1632
+ outdir: iifeOutdir,
1633
+ sourcemap: hasSourceMap ? "external" : false,
1634
+ write: false,
1635
+ logLevel: "warning",
1636
+ plugins: [loaderPlugin]
1637
+ })
1638
+ ));
1610
1639
  const written = [];
1611
1640
  const writes = [];
1612
- for (const file of iifeFiles) {
1613
- const basePath = file.path.endsWith(".map") ? file.path.slice(0, -4) : file.path;
1614
- if (entryOutputs.has(basePath)) {
1615
- writes.push(writeFile3(file.path, file.contents));
1616
- written.push({ path: relative(process.cwd(), file.path), size: file.contents.byteLength });
1641
+ for (const { outputFiles: iifeFiles } of results) {
1642
+ for (const file of iifeFiles) {
1643
+ if (file.path.endsWith(jsExtension)) {
1644
+ const text = wrapAsIife(textDecoder2.decode(file.contents), globalName);
1645
+ writes.push(writeFile3(file.path, text));
1646
+ written.push({ path: relative(process.cwd(), file.path), size: Buffer.byteLength(text) });
1647
+ } else {
1648
+ writes.push(writeFile3(file.path, file.contents));
1649
+ written.push({ path: relative(process.cwd(), file.path), size: file.contents.byteLength });
1650
+ }
1617
1651
  }
1618
1652
  }
1619
1653
  await Promise.all(writes);
@@ -2321,7 +2355,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2321
2355
  return Files.empty(this.buildConfiguration.outDir);
2322
2356
  }
2323
2357
  async build() {
2324
- Logger.header(`${tsLogo} tsbuild v${"1.8.0"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2358
+ Logger.header(`${tsLogo} tsbuild v${"1.8.2"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2325
2359
  try {
2326
2360
  const processes = [];
2327
2361
  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 "./YKY7BYLQ.js";
5
+ } from "./ALZQNZZK.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.0");
33
+ console.log("1.8.2");
34
34
  process.exit(0);
35
35
  }
36
36
  var typeScriptOptions = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TypeScriptProject
3
- } from "./YKY7BYLQ.js";
3
+ } from "./ALZQNZZK.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.0",
4
+ "version": "1.8.2",
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",