@storm-software/unbuild 0.37.19 → 0.38.0

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/bin/unbuild.cjs CHANGED
@@ -1568,8 +1568,9 @@ var import_defu3 = __toESM(require("defu"), 1);
1568
1568
  var import_glob4 = require("glob");
1569
1569
  var import_node_fs6 = require("fs");
1570
1570
  var import_promises6 = require("fs/promises");
1571
- var import_node_path6 = require("path");
1571
+ var import_node_path5 = require("path");
1572
1572
  var import_find_workspace_root5 = require("nx/src/utils/find-workspace-root");
1573
+ var import_pkg_types = require("pkg-types");
1573
1574
  var import_unbuild = require("unbuild");
1574
1575
 
1575
1576
  // src/clean.ts
@@ -1685,37 +1686,6 @@ var tscPlugin = /* @__PURE__ */ __name(async (options) => {
1685
1686
  });
1686
1687
  }, "tscPlugin");
1687
1688
 
1688
- // src/plugins/type-definitions.ts
1689
- var import_node_path5 = require("path");
1690
- function typeDefinitionsPlugin(options) {
1691
- return {
1692
- name: "storm:dts-bundle",
1693
- async generateBundle(_opts, bundle) {
1694
- for (const file of Object.values(bundle)) {
1695
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) {
1696
- continue;
1697
- }
1698
- const hasDefaultExport = file.exports.includes("default");
1699
- const entrySourceFileName = (0, import_node_path5.relative)(options.projectRoot, file.facadeModuleId);
1700
- const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
1701
- const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
1702
- const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
1703
- const dtsFileSource = hasDefaultExport ? `
1704
- export * from ${relativeSourceDtsName};
1705
- export { default } from ${relativeSourceDtsName};
1706
- ` : `export * from ${relativeSourceDtsName};
1707
- `;
1708
- this.emitFile({
1709
- type: "asset",
1710
- fileName: dtsFileName,
1711
- source: dtsFileSource
1712
- });
1713
- }
1714
- }
1715
- };
1716
- }
1717
- __name(typeDefinitionsPlugin, "typeDefinitionsPlugin");
1718
-
1719
1689
  // src/build.ts
1720
1690
  async function resolveOptions(options, config) {
1721
1691
  writeDebug(" \u2699\uFE0F Resolving build options", config);
@@ -1748,6 +1718,7 @@ async function resolveOptions(options, config) {
1748
1718
  if (!(0, import_node_fs6.existsSync)(tsconfig)) {
1749
1719
  throw new Error("Cannot find tsconfig.json configuration");
1750
1720
  }
1721
+ const tsconfigFile = await (0, import_pkg_types.readTSConfig)(tsconfig);
1751
1722
  let sourceRoot = projectJson.sourceRoot;
1752
1723
  if (!sourceRoot) {
1753
1724
  sourceRoot = joinPaths(options.projectRoot, "src");
@@ -1774,10 +1745,9 @@ async function resolveOptions(options, config) {
1774
1745
  sourceRoot,
1775
1746
  projectName,
1776
1747
  tsconfig,
1777
- platform: options.platform ?? "neutral",
1748
+ platform: options.platform || "neutral",
1778
1749
  generatePackageJson: true,
1779
1750
  clean: false,
1780
- env: {},
1781
1751
  entries: entries.reduce((ret, entry) => {
1782
1752
  let entryPath = entry.replace(options.projectRoot, "");
1783
1753
  while (entryPath.startsWith(".")) {
@@ -1786,23 +1756,32 @@ async function resolveOptions(options, config) {
1786
1756
  while (entryPath.startsWith("/")) {
1787
1757
  entryPath = entryPath.substring(1);
1788
1758
  }
1789
- const outDir = joinPaths((0, import_node_path6.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
1759
+ const outDir = joinPaths((0, import_node_path5.relative)(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
1790
1760
  ret.push({
1791
1761
  name: `${name}-esm`,
1792
1762
  builder: "mkdist",
1793
1763
  input: `./${entryPath}`,
1794
1764
  outDir,
1795
- declaration: options.emitTypes !== false ? "compatible" : false,
1796
- format: "esm"
1765
+ declaration: options.emitTypes !== false,
1766
+ addRelativeDeclarationExtensions: true,
1767
+ format: "esm",
1768
+ ext: "mjs",
1769
+ typescript: {
1770
+ compilerOptions: tsconfigFile.compilerOptions
1771
+ }
1797
1772
  });
1798
1773
  ret.push({
1799
1774
  name: `${name}-cjs`,
1800
1775
  builder: "mkdist",
1801
1776
  input: `./${entryPath}`,
1802
1777
  outDir,
1803
- declaration: options.emitTypes !== false ? "compatible" : false,
1778
+ declaration: options.emitTypes !== false,
1779
+ addRelativeDeclarationExtensions: true,
1804
1780
  format: "cjs",
1805
- ext: "cjs"
1781
+ ext: "cjs",
1782
+ typescript: {
1783
+ compilerOptions: tsconfigFile.compilerOptions
1784
+ }
1806
1785
  });
1807
1786
  return ret;
1808
1787
  }, []),
@@ -1811,11 +1790,7 @@ async function resolveOptions(options, config) {
1811
1790
  sourcemap: options.sourcemap ?? !!options.debug,
1812
1791
  outDir: outputPath,
1813
1792
  parallel: true,
1814
- stub: false,
1815
- stubOptions: {
1816
- jiti: {}
1817
- },
1818
- externals: options.external ?? [],
1793
+ externals: options.external,
1819
1794
  dependencies: [],
1820
1795
  peerDependencies: [],
1821
1796
  devDependencies: [],
@@ -1844,12 +1819,15 @@ async function resolveOptions(options, config) {
1844
1819
  resolve: {
1845
1820
  preferBuiltins: true,
1846
1821
  extensions: [
1822
+ ".tsx",
1823
+ ".ts",
1824
+ ".cts",
1825
+ ".mts",
1826
+ ".jsx",
1827
+ ".js",
1847
1828
  ".cjs",
1848
1829
  ".mjs",
1849
- ".js",
1850
- ".jsx",
1851
- ".ts",
1852
- ".tsx",
1830
+ ".css",
1853
1831
  ".json"
1854
1832
  ]
1855
1833
  },
@@ -1858,7 +1836,7 @@ async function resolveOptions(options, config) {
1858
1836
  sourceMap: options.sourcemap ?? !!options.debug,
1859
1837
  splitting: options.splitting !== false,
1860
1838
  treeShaking: options.treeShaking !== false,
1861
- platform: options.platform ?? "neutral",
1839
+ platform: options.platform || "neutral",
1862
1840
  color: true,
1863
1841
  logLevel: config.logLevel === LogLevelLabel.FATAL ? LogLevelLabel.ERROR : isVerbose() ? "verbose" : config.logLevel
1864
1842
  }
@@ -1895,7 +1873,6 @@ async function resolveOptions(options, config) {
1895
1873
  writeDebug(` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
1896
1874
  opts.plugins = await Promise.all([
1897
1875
  analyzePlugin(resolvedOptions),
1898
- typeDefinitionsPlugin(resolvedOptions),
1899
1876
  tscPlugin(resolvedOptions),
1900
1877
  onErrorPlugin(resolvedOptions)
1901
1878
  ]);
@@ -1936,15 +1913,15 @@ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", source
1936
1913
  }
1937
1914
  return {
1938
1915
  import: {
1939
- types: `./dist/${entry}.d.ts`,
1916
+ types: `./dist/${entry}.d.mts`,
1940
1917
  default: `./dist/${entry}.mjs`
1941
1918
  },
1942
1919
  require: {
1943
- types: `./dist/${entry}.d.ts`,
1920
+ types: `./dist/${entry}.d.cts`,
1944
1921
  default: `./dist/${entry}.cjs`
1945
1922
  },
1946
1923
  default: {
1947
- types: `./dist/${entry}.d.ts`,
1924
+ types: `./dist/${entry}.d.mts`,
1948
1925
  default: type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
1949
1926
  }
1950
1927
  };
package/bin/unbuild.js CHANGED
@@ -1547,8 +1547,9 @@ import defu3 from "defu";
1547
1547
  import { Glob as Glob2 } from "glob";
1548
1548
  import { existsSync as existsSync5 } from "node:fs";
1549
1549
  import { readFile as readFile5 } from "node:fs/promises";
1550
- import { relative as relative3 } from "node:path";
1550
+ import { relative as relative2 } from "node:path";
1551
1551
  import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
1552
+ import { readTSConfig } from "pkg-types";
1552
1553
  import { build as unbuild } from "unbuild";
1553
1554
 
1554
1555
  // src/clean.ts
@@ -1664,37 +1665,6 @@ var tscPlugin = /* @__PURE__ */ __name(async (options) => {
1664
1665
  });
1665
1666
  }, "tscPlugin");
1666
1667
 
1667
- // src/plugins/type-definitions.ts
1668
- import { relative as relative2 } from "node:path";
1669
- function typeDefinitionsPlugin(options) {
1670
- return {
1671
- name: "storm:dts-bundle",
1672
- async generateBundle(_opts, bundle) {
1673
- for (const file of Object.values(bundle)) {
1674
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) {
1675
- continue;
1676
- }
1677
- const hasDefaultExport = file.exports.includes("default");
1678
- const entrySourceFileName = relative2(options.projectRoot, file.facadeModuleId);
1679
- const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
1680
- const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
1681
- const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
1682
- const dtsFileSource = hasDefaultExport ? `
1683
- export * from ${relativeSourceDtsName};
1684
- export { default } from ${relativeSourceDtsName};
1685
- ` : `export * from ${relativeSourceDtsName};
1686
- `;
1687
- this.emitFile({
1688
- type: "asset",
1689
- fileName: dtsFileName,
1690
- source: dtsFileSource
1691
- });
1692
- }
1693
- }
1694
- };
1695
- }
1696
- __name(typeDefinitionsPlugin, "typeDefinitionsPlugin");
1697
-
1698
1668
  // src/build.ts
1699
1669
  async function resolveOptions(options, config) {
1700
1670
  writeDebug(" \u2699\uFE0F Resolving build options", config);
@@ -1727,6 +1697,7 @@ async function resolveOptions(options, config) {
1727
1697
  if (!existsSync5(tsconfig)) {
1728
1698
  throw new Error("Cannot find tsconfig.json configuration");
1729
1699
  }
1700
+ const tsconfigFile = await readTSConfig(tsconfig);
1730
1701
  let sourceRoot = projectJson.sourceRoot;
1731
1702
  if (!sourceRoot) {
1732
1703
  sourceRoot = joinPaths(options.projectRoot, "src");
@@ -1753,10 +1724,9 @@ async function resolveOptions(options, config) {
1753
1724
  sourceRoot,
1754
1725
  projectName,
1755
1726
  tsconfig,
1756
- platform: options.platform ?? "neutral",
1727
+ platform: options.platform || "neutral",
1757
1728
  generatePackageJson: true,
1758
1729
  clean: false,
1759
- env: {},
1760
1730
  entries: entries.reduce((ret, entry) => {
1761
1731
  let entryPath = entry.replace(options.projectRoot, "");
1762
1732
  while (entryPath.startsWith(".")) {
@@ -1765,23 +1735,32 @@ async function resolveOptions(options, config) {
1765
1735
  while (entryPath.startsWith("/")) {
1766
1736
  entryPath = entryPath.substring(1);
1767
1737
  }
1768
- const outDir = joinPaths(relative3(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
1738
+ const outDir = joinPaths(relative2(joinPaths(config.workspaceRoot, options.projectRoot), config.workspaceRoot), outputPath, "dist");
1769
1739
  ret.push({
1770
1740
  name: `${name}-esm`,
1771
1741
  builder: "mkdist",
1772
1742
  input: `./${entryPath}`,
1773
1743
  outDir,
1774
- declaration: options.emitTypes !== false ? "compatible" : false,
1775
- format: "esm"
1744
+ declaration: options.emitTypes !== false,
1745
+ addRelativeDeclarationExtensions: true,
1746
+ format: "esm",
1747
+ ext: "mjs",
1748
+ typescript: {
1749
+ compilerOptions: tsconfigFile.compilerOptions
1750
+ }
1776
1751
  });
1777
1752
  ret.push({
1778
1753
  name: `${name}-cjs`,
1779
1754
  builder: "mkdist",
1780
1755
  input: `./${entryPath}`,
1781
1756
  outDir,
1782
- declaration: options.emitTypes !== false ? "compatible" : false,
1757
+ declaration: options.emitTypes !== false,
1758
+ addRelativeDeclarationExtensions: true,
1783
1759
  format: "cjs",
1784
- ext: "cjs"
1760
+ ext: "cjs",
1761
+ typescript: {
1762
+ compilerOptions: tsconfigFile.compilerOptions
1763
+ }
1785
1764
  });
1786
1765
  return ret;
1787
1766
  }, []),
@@ -1790,11 +1769,7 @@ async function resolveOptions(options, config) {
1790
1769
  sourcemap: options.sourcemap ?? !!options.debug,
1791
1770
  outDir: outputPath,
1792
1771
  parallel: true,
1793
- stub: false,
1794
- stubOptions: {
1795
- jiti: {}
1796
- },
1797
- externals: options.external ?? [],
1772
+ externals: options.external,
1798
1773
  dependencies: [],
1799
1774
  peerDependencies: [],
1800
1775
  devDependencies: [],
@@ -1823,12 +1798,15 @@ async function resolveOptions(options, config) {
1823
1798
  resolve: {
1824
1799
  preferBuiltins: true,
1825
1800
  extensions: [
1801
+ ".tsx",
1802
+ ".ts",
1803
+ ".cts",
1804
+ ".mts",
1805
+ ".jsx",
1806
+ ".js",
1826
1807
  ".cjs",
1827
1808
  ".mjs",
1828
- ".js",
1829
- ".jsx",
1830
- ".ts",
1831
- ".tsx",
1809
+ ".css",
1832
1810
  ".json"
1833
1811
  ]
1834
1812
  },
@@ -1837,7 +1815,7 @@ async function resolveOptions(options, config) {
1837
1815
  sourceMap: options.sourcemap ?? !!options.debug,
1838
1816
  splitting: options.splitting !== false,
1839
1817
  treeShaking: options.treeShaking !== false,
1840
- platform: options.platform ?? "neutral",
1818
+ platform: options.platform || "neutral",
1841
1819
  color: true,
1842
1820
  logLevel: config.logLevel === LogLevelLabel.FATAL ? LogLevelLabel.ERROR : isVerbose() ? "verbose" : config.logLevel
1843
1821
  }
@@ -1874,7 +1852,6 @@ async function resolveOptions(options, config) {
1874
1852
  writeDebug(` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
1875
1853
  opts.plugins = await Promise.all([
1876
1854
  analyzePlugin(resolvedOptions),
1877
- typeDefinitionsPlugin(resolvedOptions),
1878
1855
  tscPlugin(resolvedOptions),
1879
1856
  onErrorPlugin(resolvedOptions)
1880
1857
  ]);
@@ -1915,15 +1892,15 @@ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", source
1915
1892
  }
1916
1893
  return {
1917
1894
  import: {
1918
- types: `./dist/${entry}.d.ts`,
1895
+ types: `./dist/${entry}.d.mts`,
1919
1896
  default: `./dist/${entry}.mjs`
1920
1897
  },
1921
1898
  require: {
1922
- types: `./dist/${entry}.d.ts`,
1899
+ types: `./dist/${entry}.d.cts`,
1923
1900
  default: `./dist/${entry}.cjs`
1924
1901
  },
1925
1902
  default: {
1926
- types: `./dist/${entry}.d.ts`,
1903
+ types: `./dist/${entry}.d.mts`,
1927
1904
  default: type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
1928
1905
  }
1929
1906
  };
package/dist/build.cjs CHANGED
@@ -5,8 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkSOHZAEOHcjs = require('./chunk-SOHZAEOH.cjs');
9
- require('./chunk-OD3ULBE3.cjs');
8
+ var _chunkEGE6IZNJcjs = require('./chunk-EGE6IZNJ.cjs');
10
9
  require('./chunk-WGGER7UI.cjs');
11
10
  require('./chunk-OOFPXPRC.cjs');
12
11
  require('./chunk-X25DCA4T.cjs');
@@ -20,4 +19,4 @@ require('./chunk-BGYQAVKQ.cjs');
20
19
 
21
20
 
22
21
 
23
- exports.build = _chunkSOHZAEOHcjs.build; exports.cleanOutputPath = _chunkSOHZAEOHcjs.cleanOutputPath; exports.copyBuildAssets = _chunkSOHZAEOHcjs.copyBuildAssets; exports.executeUnbuild = _chunkSOHZAEOHcjs.executeUnbuild; exports.generatePackageJson = _chunkSOHZAEOHcjs.generatePackageJson; exports.resolveOptions = _chunkSOHZAEOHcjs.resolveOptions;
22
+ exports.build = _chunkEGE6IZNJcjs.build; exports.cleanOutputPath = _chunkEGE6IZNJcjs.cleanOutputPath; exports.copyBuildAssets = _chunkEGE6IZNJcjs.copyBuildAssets; exports.executeUnbuild = _chunkEGE6IZNJcjs.executeUnbuild; exports.generatePackageJson = _chunkEGE6IZNJcjs.generatePackageJson; exports.resolveOptions = _chunkEGE6IZNJcjs.resolveOptions;
package/dist/build.js CHANGED
@@ -5,8 +5,7 @@ import {
5
5
  executeUnbuild,
6
6
  generatePackageJson,
7
7
  resolveOptions
8
- } from "./chunk-JJ5QDPA6.js";
9
- import "./chunk-RBYYB7X2.js";
8
+ } from "./chunk-ZXW56XVQ.js";
10
9
  import "./chunk-JLKMLDBA.js";
11
10
  import "./chunk-5XTPDLOE.js";
12
11
  import "./chunk-2FX3WQNK.js";
@@ -1,8 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkOD3ULBE3cjs = require('./chunk-OD3ULBE3.cjs');
4
-
5
-
6
3
  var _chunkWGGER7UIcjs = require('./chunk-WGGER7UI.cjs');
7
4
 
8
5
 
@@ -815,6 +812,7 @@ var _createtaskgraph = require('nx/src/tasks-runner/create-task-graph');
815
812
 
816
813
 
817
814
  var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
815
+ var _pkgtypes = require('pkg-types');
818
816
  var _unbuild = require('unbuild');
819
817
  async function resolveOptions(options, config) {
820
818
  _chunkK5SEKFQAcjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", config);
@@ -847,6 +845,7 @@ async function resolveOptions(options, config) {
847
845
  if (!_fs.existsSync.call(void 0, tsconfig)) {
848
846
  throw new Error("Cannot find tsconfig.json configuration");
849
847
  }
848
+ const tsconfigFile = await _pkgtypes.readTSConfig.call(void 0, tsconfig);
850
849
  let sourceRoot = projectJson.sourceRoot;
851
850
  if (!sourceRoot) {
852
851
  sourceRoot = _chunkK5SEKFQAcjs.joinPaths.call(void 0, options.projectRoot, "src");
@@ -873,10 +872,9 @@ async function resolveOptions(options, config) {
873
872
  sourceRoot,
874
873
  projectName,
875
874
  tsconfig,
876
- platform: _nullishCoalesce(options.platform, () => ( "neutral")),
875
+ platform: options.platform || "neutral",
877
876
  generatePackageJson: true,
878
877
  clean: false,
879
- env: {},
880
878
  entries: entries.reduce((ret, entry) => {
881
879
  let entryPath = entry.replace(options.projectRoot, "");
882
880
  while (entryPath.startsWith(".")) {
@@ -891,17 +889,26 @@ async function resolveOptions(options, config) {
891
889
  builder: "mkdist",
892
890
  input: `./${entryPath}`,
893
891
  outDir,
894
- declaration: options.emitTypes !== false ? "compatible" : false,
895
- format: "esm"
892
+ declaration: options.emitTypes !== false,
893
+ addRelativeDeclarationExtensions: true,
894
+ format: "esm",
895
+ ext: "mjs",
896
+ typescript: {
897
+ compilerOptions: tsconfigFile.compilerOptions
898
+ }
896
899
  });
897
900
  ret.push({
898
901
  name: `${name}-cjs`,
899
902
  builder: "mkdist",
900
903
  input: `./${entryPath}`,
901
904
  outDir,
902
- declaration: options.emitTypes !== false ? "compatible" : false,
905
+ declaration: options.emitTypes !== false,
906
+ addRelativeDeclarationExtensions: true,
903
907
  format: "cjs",
904
- ext: "cjs"
908
+ ext: "cjs",
909
+ typescript: {
910
+ compilerOptions: tsconfigFile.compilerOptions
911
+ }
905
912
  });
906
913
  return ret;
907
914
  }, []),
@@ -910,11 +917,7 @@ async function resolveOptions(options, config) {
910
917
  sourcemap: _nullishCoalesce(options.sourcemap, () => ( !!options.debug)),
911
918
  outDir: outputPath,
912
919
  parallel: true,
913
- stub: false,
914
- stubOptions: {
915
- jiti: {}
916
- },
917
- externals: _nullishCoalesce(options.external, () => ( [])),
920
+ externals: options.external,
918
921
  dependencies: [],
919
922
  peerDependencies: [],
920
923
  devDependencies: [],
@@ -943,12 +946,15 @@ async function resolveOptions(options, config) {
943
946
  resolve: {
944
947
  preferBuiltins: true,
945
948
  extensions: [
949
+ ".tsx",
950
+ ".ts",
951
+ ".cts",
952
+ ".mts",
953
+ ".jsx",
954
+ ".js",
946
955
  ".cjs",
947
956
  ".mjs",
948
- ".js",
949
- ".jsx",
950
- ".ts",
951
- ".tsx",
957
+ ".css",
952
958
  ".json"
953
959
  ]
954
960
  },
@@ -957,7 +963,7 @@ async function resolveOptions(options, config) {
957
963
  sourceMap: _nullishCoalesce(options.sourcemap, () => ( !!options.debug)),
958
964
  splitting: options.splitting !== false,
959
965
  treeShaking: options.treeShaking !== false,
960
- platform: _nullishCoalesce(options.platform, () => ( "neutral")),
966
+ platform: options.platform || "neutral",
961
967
  color: true,
962
968
  logLevel: config.logLevel === _chunkK5SEKFQAcjs.LogLevelLabel.FATAL ? _chunkK5SEKFQAcjs.LogLevelLabel.ERROR : _chunkK5SEKFQAcjs.isVerbose.call(void 0, ) ? "verbose" : config.logLevel
963
969
  }
@@ -994,7 +1000,6 @@ async function resolveOptions(options, config) {
994
1000
  _chunkK5SEKFQAcjs.writeDebug.call(void 0, ` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
995
1001
  opts.plugins = await Promise.all([
996
1002
  _chunkOOFPXPRCcjs.analyzePlugin.call(void 0, resolvedOptions),
997
- _chunkOD3ULBE3cjs.typeDefinitionsPlugin.call(void 0, resolvedOptions),
998
1003
  _chunkVPCO2H3Gcjs.tscPlugin.call(void 0, resolvedOptions),
999
1004
  _chunkX25DCA4Tcjs.onErrorPlugin.call(void 0, resolvedOptions)
1000
1005
  ]);
@@ -1035,15 +1040,15 @@ var addPackageJsonExport = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0,
1035
1040
  }
1036
1041
  return {
1037
1042
  import: {
1038
- types: `./dist/${entry}.d.ts`,
1043
+ types: `./dist/${entry}.d.mts`,
1039
1044
  default: `./dist/${entry}.mjs`
1040
1045
  },
1041
1046
  require: {
1042
- types: `./dist/${entry}.d.ts`,
1047
+ types: `./dist/${entry}.d.cts`,
1043
1048
  default: `./dist/${entry}.cjs`
1044
1049
  },
1045
1050
  default: {
1046
- types: `./dist/${entry}.d.ts`,
1051
+ types: `./dist/${entry}.d.mts`,
1047
1052
  default: type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
1048
1053
  }
1049
1054
  };
@@ -1,6 +1,3 @@
1
- import {
2
- typeDefinitionsPlugin
3
- } from "./chunk-RBYYB7X2.js";
4
1
  import {
5
2
  cleanDirectories
6
3
  } from "./chunk-JLKMLDBA.js";
@@ -815,6 +812,7 @@ import { existsSync as existsSync3 } from "node:fs";
815
812
  import { readFile as readFile4 } from "node:fs/promises";
816
813
  import { relative as relative2 } from "node:path";
817
814
  import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
815
+ import { readTSConfig } from "pkg-types";
818
816
  import { build as unbuild } from "unbuild";
819
817
  async function resolveOptions(options, config) {
820
818
  writeDebug(" \u2699\uFE0F Resolving build options", config);
@@ -847,6 +845,7 @@ async function resolveOptions(options, config) {
847
845
  if (!existsSync3(tsconfig)) {
848
846
  throw new Error("Cannot find tsconfig.json configuration");
849
847
  }
848
+ const tsconfigFile = await readTSConfig(tsconfig);
850
849
  let sourceRoot = projectJson.sourceRoot;
851
850
  if (!sourceRoot) {
852
851
  sourceRoot = joinPaths(options.projectRoot, "src");
@@ -873,10 +872,9 @@ async function resolveOptions(options, config) {
873
872
  sourceRoot,
874
873
  projectName,
875
874
  tsconfig,
876
- platform: options.platform ?? "neutral",
875
+ platform: options.platform || "neutral",
877
876
  generatePackageJson: true,
878
877
  clean: false,
879
- env: {},
880
878
  entries: entries.reduce((ret, entry) => {
881
879
  let entryPath = entry.replace(options.projectRoot, "");
882
880
  while (entryPath.startsWith(".")) {
@@ -891,17 +889,26 @@ async function resolveOptions(options, config) {
891
889
  builder: "mkdist",
892
890
  input: `./${entryPath}`,
893
891
  outDir,
894
- declaration: options.emitTypes !== false ? "compatible" : false,
895
- format: "esm"
892
+ declaration: options.emitTypes !== false,
893
+ addRelativeDeclarationExtensions: true,
894
+ format: "esm",
895
+ ext: "mjs",
896
+ typescript: {
897
+ compilerOptions: tsconfigFile.compilerOptions
898
+ }
896
899
  });
897
900
  ret.push({
898
901
  name: `${name}-cjs`,
899
902
  builder: "mkdist",
900
903
  input: `./${entryPath}`,
901
904
  outDir,
902
- declaration: options.emitTypes !== false ? "compatible" : false,
905
+ declaration: options.emitTypes !== false,
906
+ addRelativeDeclarationExtensions: true,
903
907
  format: "cjs",
904
- ext: "cjs"
908
+ ext: "cjs",
909
+ typescript: {
910
+ compilerOptions: tsconfigFile.compilerOptions
911
+ }
905
912
  });
906
913
  return ret;
907
914
  }, []),
@@ -910,11 +917,7 @@ async function resolveOptions(options, config) {
910
917
  sourcemap: options.sourcemap ?? !!options.debug,
911
918
  outDir: outputPath,
912
919
  parallel: true,
913
- stub: false,
914
- stubOptions: {
915
- jiti: {}
916
- },
917
- externals: options.external ?? [],
920
+ externals: options.external,
918
921
  dependencies: [],
919
922
  peerDependencies: [],
920
923
  devDependencies: [],
@@ -943,12 +946,15 @@ async function resolveOptions(options, config) {
943
946
  resolve: {
944
947
  preferBuiltins: true,
945
948
  extensions: [
949
+ ".tsx",
950
+ ".ts",
951
+ ".cts",
952
+ ".mts",
953
+ ".jsx",
954
+ ".js",
946
955
  ".cjs",
947
956
  ".mjs",
948
- ".js",
949
- ".jsx",
950
- ".ts",
951
- ".tsx",
957
+ ".css",
952
958
  ".json"
953
959
  ]
954
960
  },
@@ -957,7 +963,7 @@ async function resolveOptions(options, config) {
957
963
  sourceMap: options.sourcemap ?? !!options.debug,
958
964
  splitting: options.splitting !== false,
959
965
  treeShaking: options.treeShaking !== false,
960
- platform: options.platform ?? "neutral",
966
+ platform: options.platform || "neutral",
961
967
  color: true,
962
968
  logLevel: config.logLevel === LogLevelLabel.FATAL ? LogLevelLabel.ERROR : isVerbose() ? "verbose" : config.logLevel
963
969
  }
@@ -994,7 +1000,6 @@ async function resolveOptions(options, config) {
994
1000
  writeDebug(` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
995
1001
  opts.plugins = await Promise.all([
996
1002
  analyzePlugin(resolvedOptions),
997
- typeDefinitionsPlugin(resolvedOptions),
998
1003
  tscPlugin(resolvedOptions),
999
1004
  onErrorPlugin(resolvedOptions)
1000
1005
  ]);
@@ -1035,15 +1040,15 @@ var addPackageJsonExport = /* @__PURE__ */ __name((file, type = "module", source
1035
1040
  }
1036
1041
  return {
1037
1042
  import: {
1038
- types: `./dist/${entry}.d.ts`,
1043
+ types: `./dist/${entry}.d.mts`,
1039
1044
  default: `./dist/${entry}.mjs`
1040
1045
  },
1041
1046
  require: {
1042
- types: `./dist/${entry}.d.ts`,
1047
+ types: `./dist/${entry}.d.cts`,
1043
1048
  default: `./dist/${entry}.cjs`
1044
1049
  },
1045
1050
  default: {
1046
- types: `./dist/${entry}.d.ts`,
1051
+ types: `./dist/${entry}.d.mts`,
1047
1052
  default: type === "commonjs" ? `./dist/${entry}.cjs` : `./dist/${entry}.mjs`
1048
1053
  }
1049
1054
  };
package/dist/index.cjs CHANGED
@@ -5,8 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkSOHZAEOHcjs = require('./chunk-SOHZAEOH.cjs');
9
- require('./chunk-OD3ULBE3.cjs');
8
+ var _chunkEGE6IZNJcjs = require('./chunk-EGE6IZNJ.cjs');
10
9
 
11
10
 
12
11
 
@@ -31,4 +30,4 @@ require('./chunk-BGYQAVKQ.cjs');
31
30
 
32
31
 
33
32
 
34
- exports.build = _chunkSOHZAEOHcjs.build; exports.clean = _chunkWGGER7UIcjs.clean; exports.cleanDirectories = _chunkWGGER7UIcjs.cleanDirectories; exports.cleanOutputPath = _chunkSOHZAEOHcjs.cleanOutputPath; exports.copyBuildAssets = _chunkSOHZAEOHcjs.copyBuildAssets; exports.createTsCompilerOptions = _chunkVPCO2H3Gcjs.createTsCompilerOptions; exports.executeUnbuild = _chunkSOHZAEOHcjs.executeUnbuild; exports.generatePackageJson = _chunkSOHZAEOHcjs.generatePackageJson; exports.loadConfig = _chunkVPCO2H3Gcjs.loadConfig; exports.resolveOptions = _chunkSOHZAEOHcjs.resolveOptions;
33
+ exports.build = _chunkEGE6IZNJcjs.build; exports.clean = _chunkWGGER7UIcjs.clean; exports.cleanDirectories = _chunkWGGER7UIcjs.cleanDirectories; exports.cleanOutputPath = _chunkEGE6IZNJcjs.cleanOutputPath; exports.copyBuildAssets = _chunkEGE6IZNJcjs.copyBuildAssets; exports.createTsCompilerOptions = _chunkVPCO2H3Gcjs.createTsCompilerOptions; exports.executeUnbuild = _chunkEGE6IZNJcjs.executeUnbuild; exports.generatePackageJson = _chunkEGE6IZNJcjs.generatePackageJson; exports.loadConfig = _chunkVPCO2H3Gcjs.loadConfig; exports.resolveOptions = _chunkEGE6IZNJcjs.resolveOptions;
package/dist/index.js CHANGED
@@ -5,8 +5,7 @@ import {
5
5
  executeUnbuild,
6
6
  generatePackageJson,
7
7
  resolveOptions
8
- } from "./chunk-JJ5QDPA6.js";
9
- import "./chunk-RBYYB7X2.js";
8
+ } from "./chunk-ZXW56XVQ.js";
10
9
  import {
11
10
  clean,
12
11
  cleanDirectories
@@ -1,7 +1,37 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkOD3ULBE3cjs = require('../chunk-OD3ULBE3.cjs');
4
- require('../chunk-BGYQAVKQ.cjs');
3
+ var _chunkBGYQAVKQcjs = require('../chunk-BGYQAVKQ.cjs');
5
4
 
5
+ // src/plugins/type-definitions.ts
6
+ var _path = require('path');
7
+ function typeDefinitionsPlugin(options) {
8
+ return {
9
+ name: "storm:dts-bundle",
10
+ async generateBundle(_opts, bundle) {
11
+ for (const file of Object.values(bundle)) {
12
+ if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) {
13
+ continue;
14
+ }
15
+ const hasDefaultExport = file.exports.includes("default");
16
+ const entrySourceFileName = _path.relative.call(void 0, options.projectRoot, file.facadeModuleId);
17
+ const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
18
+ const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
19
+ const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
20
+ const dtsFileSource = hasDefaultExport ? `
21
+ export * from ${relativeSourceDtsName};
22
+ export { default } from ${relativeSourceDtsName};
23
+ ` : `export * from ${relativeSourceDtsName};
24
+ `;
25
+ this.emitFile({
26
+ type: "asset",
27
+ fileName: dtsFileName,
28
+ source: dtsFileSource
29
+ });
30
+ }
31
+ }
32
+ };
33
+ }
34
+ _chunkBGYQAVKQcjs.__name.call(void 0, typeDefinitionsPlugin, "typeDefinitionsPlugin");
6
35
 
7
- exports.typeDefinitionsPlugin = _chunkOD3ULBE3cjs.typeDefinitionsPlugin;
36
+
37
+ exports.typeDefinitionsPlugin = typeDefinitionsPlugin;
@@ -1,7 +1,37 @@
1
1
  import {
2
- typeDefinitionsPlugin
3
- } from "../chunk-RBYYB7X2.js";
4
- import "../chunk-3GQAWCBQ.js";
2
+ __name
3
+ } from "../chunk-3GQAWCBQ.js";
4
+
5
+ // src/plugins/type-definitions.ts
6
+ import { relative } from "node:path";
7
+ function typeDefinitionsPlugin(options) {
8
+ return {
9
+ name: "storm:dts-bundle",
10
+ async generateBundle(_opts, bundle) {
11
+ for (const file of Object.values(bundle)) {
12
+ if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) {
13
+ continue;
14
+ }
15
+ const hasDefaultExport = file.exports.includes("default");
16
+ const entrySourceFileName = relative(options.projectRoot, file.facadeModuleId);
17
+ const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
18
+ const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
19
+ const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
20
+ const dtsFileSource = hasDefaultExport ? `
21
+ export * from ${relativeSourceDtsName};
22
+ export { default } from ${relativeSourceDtsName};
23
+ ` : `export * from ${relativeSourceDtsName};
24
+ `;
25
+ this.emitFile({
26
+ type: "asset",
27
+ fileName: dtsFileName,
28
+ source: dtsFileSource
29
+ });
30
+ }
31
+ }
32
+ };
33
+ }
34
+ __name(typeDefinitionsPlugin, "typeDefinitionsPlugin");
5
35
  export {
6
36
  typeDefinitionsPlugin
7
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/unbuild",
3
- "version": "0.37.19",
3
+ "version": "0.38.0",
4
4
  "type": "module",
5
5
  "description": "A package containing `unbuild` utilities for building Storm Software libraries and applications",
6
6
  "repository": {
@@ -138,6 +138,7 @@
138
138
  "@storm-software/build-tools": "workspace:*",
139
139
  "@storm-software/config": "workspace:*",
140
140
  "@storm-software/config-tools": "workspace:*",
141
+ "@swc/core": "1.7.26",
141
142
  "nx": "20.6.0",
142
143
  "rollup": "^4.29.1",
143
144
  "typescript": "^5.7.2"
@@ -148,24 +149,19 @@
148
149
  "@storm-software/build-tools": { "optional": false },
149
150
  "@storm-software/config": { "optional": false },
150
151
  "@storm-software/config-tools": { "optional": false },
152
+ "@swc/core": { "optional": true },
151
153
  "nx": { "optional": true },
152
154
  "rollup": { "optional": false },
153
155
  "typescript": { "optional": false }
154
156
  },
155
157
  "dependencies": {
156
- "@rollup/plugin-alias": "^5.1.1",
157
- "@rollup/plugin-commonjs": "^28.0.2",
158
- "@rollup/plugin-json": "^6.1.0",
159
- "@rollup/plugin-node-resolve": "^16.0.0",
160
- "@rollup/plugin-replace": "^6.0.2",
161
- "@rollup/pluginutils": "^5.1.4",
162
- "@swc/core": "1.7.26",
163
158
  "commander": "^12.1.0",
164
159
  "defu": "6.1.4",
165
160
  "esbuild": "^0.25.0",
166
161
  "glob": "^11.0.1",
167
162
  "jiti": "^2.4.2",
168
163
  "mkdist": "^2.2.0",
164
+ "pkg-types": "^1.3.1",
169
165
  "rollup": "^4.29.1",
170
166
  "rollup-plugin-typescript2": "0.36.0",
171
167
  "unbuild": "^3.2.0"
@@ -1,38 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
4
-
5
- // src/plugins/type-definitions.ts
6
- var _path = require('path');
7
- function typeDefinitionsPlugin(options) {
8
- return {
9
- name: "storm:dts-bundle",
10
- async generateBundle(_opts, bundle) {
11
- for (const file of Object.values(bundle)) {
12
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) {
13
- continue;
14
- }
15
- const hasDefaultExport = file.exports.includes("default");
16
- const entrySourceFileName = _path.relative.call(void 0, options.projectRoot, file.facadeModuleId);
17
- const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
18
- const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
19
- const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
20
- const dtsFileSource = hasDefaultExport ? `
21
- export * from ${relativeSourceDtsName};
22
- export { default } from ${relativeSourceDtsName};
23
- ` : `export * from ${relativeSourceDtsName};
24
- `;
25
- this.emitFile({
26
- type: "asset",
27
- fileName: dtsFileName,
28
- source: dtsFileSource
29
- });
30
- }
31
- }
32
- };
33
- }
34
- _chunkBGYQAVKQcjs.__name.call(void 0, typeDefinitionsPlugin, "typeDefinitionsPlugin");
35
-
36
-
37
-
38
- exports.typeDefinitionsPlugin = typeDefinitionsPlugin;
@@ -1,38 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-3GQAWCBQ.js";
4
-
5
- // src/plugins/type-definitions.ts
6
- import { relative } from "node:path";
7
- function typeDefinitionsPlugin(options) {
8
- return {
9
- name: "storm:dts-bundle",
10
- async generateBundle(_opts, bundle) {
11
- for (const file of Object.values(bundle)) {
12
- if (file.type === "asset" || !file.isEntry || file.facadeModuleId == null) {
13
- continue;
14
- }
15
- const hasDefaultExport = file.exports.includes("default");
16
- const entrySourceFileName = relative(options.projectRoot, file.facadeModuleId);
17
- const entrySourceDtsName = entrySourceFileName.replace(/\.[cm]?[jt]sx?$/, "");
18
- const dtsFileName = file.fileName.replace(/\.[cm]?js$/, ".d.ts");
19
- const relativeSourceDtsName = JSON.stringify("./" + entrySourceDtsName);
20
- const dtsFileSource = hasDefaultExport ? `
21
- export * from ${relativeSourceDtsName};
22
- export { default } from ${relativeSourceDtsName};
23
- ` : `export * from ${relativeSourceDtsName};
24
- `;
25
- this.emitFile({
26
- type: "asset",
27
- fileName: dtsFileName,
28
- source: dtsFileSource
29
- });
30
- }
31
- }
32
- };
33
- }
34
- __name(typeDefinitionsPlugin, "typeDefinitionsPlugin");
35
-
36
- export {
37
- typeDefinitionsPlugin
38
- };