@storm-software/unbuild 0.38.5 → 0.38.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/README.md +1 -1
- package/bin/unbuild.cjs +102 -19
- package/bin/unbuild.js +103 -20
- package/dist/build.cjs +5 -3
- package/dist/build.js +4 -2
- package/dist/chunk-2FX3WQNK.js +31 -0
- package/dist/{chunk-PZ266WAX.cjs → chunk-5MDNSLYX.cjs} +25 -17
- package/dist/chunk-5XTPDLOE.js +35 -0
- package/dist/chunk-IYFBAI6G.js +62 -0
- package/dist/chunk-OOFPXPRC.cjs +35 -0
- package/dist/{chunk-LPAU53JZ.js → chunk-T3BNH4LG.js} +24 -16
- package/dist/{chunk-YC7U7HH4.cjs → chunk-VPCO2H3G.cjs} +27 -2
- package/dist/chunk-X25DCA4T.cjs +31 -0
- package/dist/index.cjs +5 -3
- package/dist/index.js +4 -2
- package/dist/plugins/analyze.cjs +4 -30
- package/dist/plugins/analyze.js +4 -30
- package/dist/plugins/on-error.cjs +4 -26
- package/dist/plugins/on-error.js +4 -26
- package/dist/plugins/tsc.cjs +4 -28
- package/dist/plugins/tsc.js +3 -27
- package/package.json +1 -1
- package/dist/chunk-QOHGN7PS.js +0 -37
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
package/bin/unbuild.cjs
CHANGED
|
@@ -1373,9 +1373,9 @@ var getConfig = /* @__PURE__ */ __name((workspaceRoot, skipLogs = false) => {
|
|
|
1373
1373
|
var import_commander = require("commander");
|
|
1374
1374
|
|
|
1375
1375
|
// src/build.ts
|
|
1376
|
-
var
|
|
1376
|
+
var import_devkit4 = require("@nx/devkit");
|
|
1377
1377
|
var import_js = require("@nx/js");
|
|
1378
|
-
var
|
|
1378
|
+
var import_buildable_libs_utils4 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
1379
1379
|
|
|
1380
1380
|
// ../build-tools/src/plugins/swc.ts
|
|
1381
1381
|
var import_core = require("@swc/core");
|
|
@@ -1570,7 +1570,6 @@ var import_node_fs6 = require("fs");
|
|
|
1570
1570
|
var import_promises6 = require("fs/promises");
|
|
1571
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");
|
|
1574
1573
|
var import_unbuild = require("unbuild");
|
|
1575
1574
|
|
|
1576
1575
|
// src/clean.ts
|
|
@@ -1590,6 +1589,58 @@ async function cleanDirectories(name = "Unbuild", directory, config) {
|
|
|
1590
1589
|
}
|
|
1591
1590
|
__name(cleanDirectories, "cleanDirectories");
|
|
1592
1591
|
|
|
1592
|
+
// src/plugins/analyze.ts
|
|
1593
|
+
var formatBytes = /* @__PURE__ */ __name((bytes) => {
|
|
1594
|
+
if (bytes === 0) return "0 Byte";
|
|
1595
|
+
const k = 1e3;
|
|
1596
|
+
const dm = 3;
|
|
1597
|
+
const sizes = [
|
|
1598
|
+
"Bytes",
|
|
1599
|
+
"KB",
|
|
1600
|
+
"MB",
|
|
1601
|
+
"GB"
|
|
1602
|
+
];
|
|
1603
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1604
|
+
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
1605
|
+
}, "formatBytes");
|
|
1606
|
+
var analyzePlugin = /* @__PURE__ */ __name((options) => {
|
|
1607
|
+
return {
|
|
1608
|
+
name: "storm:analyzer",
|
|
1609
|
+
renderChunk(source, chunk) {
|
|
1610
|
+
const sourceBytes = formatBytes(source.length);
|
|
1611
|
+
const fileName = chunk.fileName;
|
|
1612
|
+
writeInfo(` - ${fileName} ${sourceBytes}`, options.config);
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
}, "analyzePlugin");
|
|
1616
|
+
|
|
1617
|
+
// src/plugins/on-error.ts
|
|
1618
|
+
var onErrorPlugin = /* @__PURE__ */ __name((options) => ({
|
|
1619
|
+
name: "storm:on-error",
|
|
1620
|
+
buildEnd(error) {
|
|
1621
|
+
if (error) {
|
|
1622
|
+
writeError(`The following errors occurred during the build:
|
|
1623
|
+
${error ? error.message : "Unknown build error"}
|
|
1624
|
+
|
|
1625
|
+
`, options.config);
|
|
1626
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
1627
|
+
}
|
|
1628
|
+
},
|
|
1629
|
+
renderError(error) {
|
|
1630
|
+
writeError(`The following errors occurred during the build:
|
|
1631
|
+
${error ? error.message : "Unknown build error"}
|
|
1632
|
+
|
|
1633
|
+
`, options.config);
|
|
1634
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
1635
|
+
}
|
|
1636
|
+
}), "onErrorPlugin");
|
|
1637
|
+
|
|
1638
|
+
// src/plugins/tsc.ts
|
|
1639
|
+
var import_devkit3 = require("@nx/devkit");
|
|
1640
|
+
var import_buildable_libs_utils3 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
1641
|
+
var import_compiler_helper_dependency = require("@nx/js/src/utils/compiler-helper-dependency");
|
|
1642
|
+
var import_rollup_plugin_typescript2 = __toESM(require("rollup-plugin-typescript2"), 1);
|
|
1643
|
+
|
|
1593
1644
|
// src/utilities/helpers.ts
|
|
1594
1645
|
var import_devkit2 = require("@nx/devkit");
|
|
1595
1646
|
var import_buildable_libs_utils2 = require("@nx/js/src/utils/buildable-libs-utils");
|
|
@@ -1603,6 +1654,36 @@ async function loadConfig2(configPath) {
|
|
|
1603
1654
|
return import((0, import_node_url.pathToFileURL)(configPath).toString()).then((config) => config.default);
|
|
1604
1655
|
}
|
|
1605
1656
|
__name(loadConfig2, "loadConfig");
|
|
1657
|
+
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
1658
|
+
const tsConfigFile = import_typescript.default.readConfigFile((0, import_devkit2.joinPathFragments)(config.workspaceRoot, projectRoot, tsConfigPath), import_typescript.default.sys.readFile);
|
|
1659
|
+
const tsConfig = import_typescript.default.parseJsonConfigFileContent(tsConfigFile.config, import_typescript.default.sys, (0, import_node_path4.dirname)((0, import_devkit2.joinPathFragments)(config.workspaceRoot, projectRoot, tsConfigPath)));
|
|
1660
|
+
const compilerOptions = {
|
|
1661
|
+
rootDir: projectRoot,
|
|
1662
|
+
declaration: true,
|
|
1663
|
+
paths: (0, import_buildable_libs_utils2.computeCompilerOptionsPaths)(tsConfig, dependencies ?? [])
|
|
1664
|
+
};
|
|
1665
|
+
writeTrace(compilerOptions, config);
|
|
1666
|
+
return compilerOptions;
|
|
1667
|
+
}
|
|
1668
|
+
__name(createTsCompilerOptions, "createTsCompilerOptions");
|
|
1669
|
+
|
|
1670
|
+
// src/plugins/tsc.ts
|
|
1671
|
+
var tscPlugin = /* @__PURE__ */ __name(async (options) => {
|
|
1672
|
+
const projectGraph = (0, import_devkit3.readCachedProjectGraph)();
|
|
1673
|
+
const result = (0, import_buildable_libs_utils3.calculateProjectBuildableDependencies)(void 0, projectGraph, options.config.workspaceRoot, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1674
|
+
let dependencies = result.dependencies;
|
|
1675
|
+
const tsLibDependency = (0, import_compiler_helper_dependency.getHelperDependency)(import_compiler_helper_dependency.HelperDependency.tsc, options.tsconfig, dependencies, projectGraph, true);
|
|
1676
|
+
if (tsLibDependency) {
|
|
1677
|
+
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
1678
|
+
dependencies.push(tsLibDependency);
|
|
1679
|
+
}
|
|
1680
|
+
const compilerOptions = await createTsCompilerOptions(options.config, options.tsconfig, options.projectRoot, dependencies);
|
|
1681
|
+
return (0, import_rollup_plugin_typescript2.default)({
|
|
1682
|
+
check: options.declaration !== false,
|
|
1683
|
+
tsconfig: options.tsconfig,
|
|
1684
|
+
tsconfigOverride: compilerOptions
|
|
1685
|
+
});
|
|
1686
|
+
}, "tscPlugin");
|
|
1606
1687
|
|
|
1607
1688
|
// src/build.ts
|
|
1608
1689
|
async function resolveOptions(options, config) {
|
|
@@ -1615,7 +1696,7 @@ async function resolveOptions(options, config) {
|
|
|
1615
1696
|
}
|
|
1616
1697
|
}
|
|
1617
1698
|
const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
|
|
1618
|
-
const projectGraph = (0,
|
|
1699
|
+
const projectGraph = (0, import_devkit4.readCachedProjectGraph)();
|
|
1619
1700
|
const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
|
|
1620
1701
|
if (!(0, import_node_fs6.existsSync)(projectJsonPath)) {
|
|
1621
1702
|
throw new Error("Cannot find project.json configuration");
|
|
@@ -1639,7 +1720,6 @@ async function resolveOptions(options, config) {
|
|
|
1639
1720
|
if (!(0, import_node_fs6.existsSync)(tsconfig)) {
|
|
1640
1721
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
1641
1722
|
}
|
|
1642
|
-
const tsconfigFile = await (0, import_pkg_types.readTSConfig)(tsconfig);
|
|
1643
1723
|
let sourceRoot = projectJson.sourceRoot;
|
|
1644
1724
|
if (!sourceRoot) {
|
|
1645
1725
|
sourceRoot = joinPaths(options.projectRoot, "src");
|
|
@@ -1647,7 +1727,7 @@ async function resolveOptions(options, config) {
|
|
|
1647
1727
|
if (!(0, import_node_fs6.existsSync)(sourceRoot)) {
|
|
1648
1728
|
throw new Error("Cannot find sourceRoot directory");
|
|
1649
1729
|
}
|
|
1650
|
-
const result = (0,
|
|
1730
|
+
const result = (0, import_buildable_libs_utils4.calculateProjectBuildableDependencies)(void 0, projectGraph, config.workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1651
1731
|
let dependencies = result.dependencies;
|
|
1652
1732
|
const tsLibDependency = (0, import_js.getHelperDependency)(import_js.HelperDependency.tsc, tsconfig, dependencies, projectGraph, true);
|
|
1653
1733
|
if (tsLibDependency) {
|
|
@@ -1683,26 +1763,18 @@ async function resolveOptions(options, config) {
|
|
|
1683
1763
|
builder: "mkdist",
|
|
1684
1764
|
input: `./${entryPath}`,
|
|
1685
1765
|
outDir,
|
|
1686
|
-
declaration: options.emitTypes !== false,
|
|
1687
|
-
addRelativeDeclarationExtensions: true,
|
|
1766
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
1688
1767
|
format: "esm",
|
|
1689
|
-
ext: "mjs"
|
|
1690
|
-
typescript: {
|
|
1691
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
1692
|
-
}
|
|
1768
|
+
ext: "mjs"
|
|
1693
1769
|
});
|
|
1694
1770
|
ret.push({
|
|
1695
1771
|
name: `${name}-cjs`,
|
|
1696
1772
|
builder: "mkdist",
|
|
1697
1773
|
input: `./${entryPath}`,
|
|
1698
1774
|
outDir,
|
|
1699
|
-
declaration: options.emitTypes !== false,
|
|
1700
|
-
addRelativeDeclarationExtensions: true,
|
|
1775
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
1701
1776
|
format: "cjs",
|
|
1702
|
-
ext: "cjs"
|
|
1703
|
-
typescript: {
|
|
1704
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
1705
|
-
}
|
|
1777
|
+
ext: "cjs"
|
|
1706
1778
|
});
|
|
1707
1779
|
return ret;
|
|
1708
1780
|
}, []),
|
|
@@ -1787,6 +1859,17 @@ async function resolveOptions(options, config) {
|
|
|
1787
1859
|
}
|
|
1788
1860
|
resolvedOptions.hooks = {
|
|
1789
1861
|
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
1862
|
+
if (options.plugins && options.plugins.length > 0) {
|
|
1863
|
+
writeDebug(` \u{1F9E9} Found ${options.plugins.length} plugins in provided build options`, config);
|
|
1864
|
+
opts.plugins = options.plugins;
|
|
1865
|
+
} else {
|
|
1866
|
+
writeDebug(` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
|
|
1867
|
+
opts.plugins = await Promise.all([
|
|
1868
|
+
analyzePlugin(resolvedOptions),
|
|
1869
|
+
tscPlugin(resolvedOptions),
|
|
1870
|
+
onErrorPlugin(resolvedOptions)
|
|
1871
|
+
]);
|
|
1872
|
+
}
|
|
1790
1873
|
}, "rollup:options"),
|
|
1791
1874
|
"mkdist:entry:options": /* @__PURE__ */ __name(async (ctx, entry, opts) => {
|
|
1792
1875
|
opts.esbuild ||= {};
|
|
@@ -1892,7 +1975,7 @@ async function generatePackageJson(options) {
|
|
|
1892
1975
|
}, packageJson.exports);
|
|
1893
1976
|
packageJson.exports["./package.json"] ??= "./package.json";
|
|
1894
1977
|
packageJson.exports["."] ??= addPackageJsonExport("index", packageJson.type, options.sourceRoot, options.projectRoot);
|
|
1895
|
-
await (0,
|
|
1978
|
+
await (0, import_devkit4.writeJsonFile)(joinPaths(options.outDir, "package.json"), packageJson);
|
|
1896
1979
|
stopwatch();
|
|
1897
1980
|
}
|
|
1898
1981
|
return options;
|
package/bin/unbuild.js
CHANGED
|
@@ -1352,9 +1352,9 @@ var getConfig = /* @__PURE__ */ __name((workspaceRoot, skipLogs = false) => {
|
|
|
1352
1352
|
import { Command, Option } from "commander";
|
|
1353
1353
|
|
|
1354
1354
|
// src/build.ts
|
|
1355
|
-
import { readCachedProjectGraph as
|
|
1356
|
-
import { getHelperDependency, HelperDependency } from "@nx/js";
|
|
1357
|
-
import { calculateProjectBuildableDependencies as
|
|
1355
|
+
import { readCachedProjectGraph as readCachedProjectGraph3, writeJsonFile } from "@nx/devkit";
|
|
1356
|
+
import { getHelperDependency as getHelperDependency2, HelperDependency as HelperDependency2 } from "@nx/js";
|
|
1357
|
+
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies3 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1358
1358
|
|
|
1359
1359
|
// ../build-tools/src/plugins/swc.ts
|
|
1360
1360
|
import { transform } from "@swc/core";
|
|
@@ -1549,7 +1549,6 @@ import { existsSync as existsSync5 } from "node:fs";
|
|
|
1549
1549
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
1550
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";
|
|
1553
1552
|
import { build as unbuild } from "unbuild";
|
|
1554
1553
|
|
|
1555
1554
|
// src/clean.ts
|
|
@@ -1569,6 +1568,58 @@ async function cleanDirectories(name = "Unbuild", directory, config) {
|
|
|
1569
1568
|
}
|
|
1570
1569
|
__name(cleanDirectories, "cleanDirectories");
|
|
1571
1570
|
|
|
1571
|
+
// src/plugins/analyze.ts
|
|
1572
|
+
var formatBytes = /* @__PURE__ */ __name((bytes) => {
|
|
1573
|
+
if (bytes === 0) return "0 Byte";
|
|
1574
|
+
const k = 1e3;
|
|
1575
|
+
const dm = 3;
|
|
1576
|
+
const sizes = [
|
|
1577
|
+
"Bytes",
|
|
1578
|
+
"KB",
|
|
1579
|
+
"MB",
|
|
1580
|
+
"GB"
|
|
1581
|
+
];
|
|
1582
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1583
|
+
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
1584
|
+
}, "formatBytes");
|
|
1585
|
+
var analyzePlugin = /* @__PURE__ */ __name((options) => {
|
|
1586
|
+
return {
|
|
1587
|
+
name: "storm:analyzer",
|
|
1588
|
+
renderChunk(source, chunk) {
|
|
1589
|
+
const sourceBytes = formatBytes(source.length);
|
|
1590
|
+
const fileName = chunk.fileName;
|
|
1591
|
+
writeInfo(` - ${fileName} ${sourceBytes}`, options.config);
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
}, "analyzePlugin");
|
|
1595
|
+
|
|
1596
|
+
// src/plugins/on-error.ts
|
|
1597
|
+
var onErrorPlugin = /* @__PURE__ */ __name((options) => ({
|
|
1598
|
+
name: "storm:on-error",
|
|
1599
|
+
buildEnd(error) {
|
|
1600
|
+
if (error) {
|
|
1601
|
+
writeError(`The following errors occurred during the build:
|
|
1602
|
+
${error ? error.message : "Unknown build error"}
|
|
1603
|
+
|
|
1604
|
+
`, options.config);
|
|
1605
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
renderError(error) {
|
|
1609
|
+
writeError(`The following errors occurred during the build:
|
|
1610
|
+
${error ? error.message : "Unknown build error"}
|
|
1611
|
+
|
|
1612
|
+
`, options.config);
|
|
1613
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
1614
|
+
}
|
|
1615
|
+
}), "onErrorPlugin");
|
|
1616
|
+
|
|
1617
|
+
// src/plugins/tsc.ts
|
|
1618
|
+
import { readCachedProjectGraph as readCachedProjectGraph2 } from "@nx/devkit";
|
|
1619
|
+
import { calculateProjectBuildableDependencies as calculateProjectBuildableDependencies2 } from "@nx/js/src/utils/buildable-libs-utils";
|
|
1620
|
+
import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler-helper-dependency";
|
|
1621
|
+
import ts2Plugin from "rollup-plugin-typescript2";
|
|
1622
|
+
|
|
1572
1623
|
// src/utilities/helpers.ts
|
|
1573
1624
|
import { joinPathFragments } from "@nx/devkit";
|
|
1574
1625
|
import { computeCompilerOptionsPaths } from "@nx/js/src/utils/buildable-libs-utils";
|
|
@@ -1582,6 +1633,36 @@ async function loadConfig2(configPath) {
|
|
|
1582
1633
|
return import(pathToFileURL(configPath).toString()).then((config) => config.default);
|
|
1583
1634
|
}
|
|
1584
1635
|
__name(loadConfig2, "loadConfig");
|
|
1636
|
+
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
1637
|
+
const tsConfigFile = ts.readConfigFile(joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath), ts.sys.readFile);
|
|
1638
|
+
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, dirname(joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath)));
|
|
1639
|
+
const compilerOptions = {
|
|
1640
|
+
rootDir: projectRoot,
|
|
1641
|
+
declaration: true,
|
|
1642
|
+
paths: computeCompilerOptionsPaths(tsConfig, dependencies ?? [])
|
|
1643
|
+
};
|
|
1644
|
+
writeTrace(compilerOptions, config);
|
|
1645
|
+
return compilerOptions;
|
|
1646
|
+
}
|
|
1647
|
+
__name(createTsCompilerOptions, "createTsCompilerOptions");
|
|
1648
|
+
|
|
1649
|
+
// src/plugins/tsc.ts
|
|
1650
|
+
var tscPlugin = /* @__PURE__ */ __name(async (options) => {
|
|
1651
|
+
const projectGraph = readCachedProjectGraph2();
|
|
1652
|
+
const result = calculateProjectBuildableDependencies2(void 0, projectGraph, options.config.workspaceRoot, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1653
|
+
let dependencies = result.dependencies;
|
|
1654
|
+
const tsLibDependency = getHelperDependency(HelperDependency.tsc, options.tsconfig, dependencies, projectGraph, true);
|
|
1655
|
+
if (tsLibDependency) {
|
|
1656
|
+
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
1657
|
+
dependencies.push(tsLibDependency);
|
|
1658
|
+
}
|
|
1659
|
+
const compilerOptions = await createTsCompilerOptions(options.config, options.tsconfig, options.projectRoot, dependencies);
|
|
1660
|
+
return ts2Plugin({
|
|
1661
|
+
check: options.declaration !== false,
|
|
1662
|
+
tsconfig: options.tsconfig,
|
|
1663
|
+
tsconfigOverride: compilerOptions
|
|
1664
|
+
});
|
|
1665
|
+
}, "tscPlugin");
|
|
1585
1666
|
|
|
1586
1667
|
// src/build.ts
|
|
1587
1668
|
async function resolveOptions(options, config) {
|
|
@@ -1594,7 +1675,7 @@ async function resolveOptions(options, config) {
|
|
|
1594
1675
|
}
|
|
1595
1676
|
}
|
|
1596
1677
|
const outputPath = options.outputPath || joinPaths("dist", options.projectRoot);
|
|
1597
|
-
const projectGraph =
|
|
1678
|
+
const projectGraph = readCachedProjectGraph3();
|
|
1598
1679
|
const projectJsonPath = joinPaths(config.workspaceRoot, options.projectRoot, "project.json");
|
|
1599
1680
|
if (!existsSync5(projectJsonPath)) {
|
|
1600
1681
|
throw new Error("Cannot find project.json configuration");
|
|
@@ -1618,7 +1699,6 @@ async function resolveOptions(options, config) {
|
|
|
1618
1699
|
if (!existsSync5(tsconfig)) {
|
|
1619
1700
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
1620
1701
|
}
|
|
1621
|
-
const tsconfigFile = await readTSConfig(tsconfig);
|
|
1622
1702
|
let sourceRoot = projectJson.sourceRoot;
|
|
1623
1703
|
if (!sourceRoot) {
|
|
1624
1704
|
sourceRoot = joinPaths(options.projectRoot, "src");
|
|
@@ -1626,9 +1706,9 @@ async function resolveOptions(options, config) {
|
|
|
1626
1706
|
if (!existsSync5(sourceRoot)) {
|
|
1627
1707
|
throw new Error("Cannot find sourceRoot directory");
|
|
1628
1708
|
}
|
|
1629
|
-
const result =
|
|
1709
|
+
const result = calculateProjectBuildableDependencies3(void 0, projectGraph, config.workspaceRoot, projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
1630
1710
|
let dependencies = result.dependencies;
|
|
1631
|
-
const tsLibDependency =
|
|
1711
|
+
const tsLibDependency = getHelperDependency2(HelperDependency2.tsc, tsconfig, dependencies, projectGraph, true);
|
|
1632
1712
|
if (tsLibDependency) {
|
|
1633
1713
|
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
1634
1714
|
dependencies.push(tsLibDependency);
|
|
@@ -1662,26 +1742,18 @@ async function resolveOptions(options, config) {
|
|
|
1662
1742
|
builder: "mkdist",
|
|
1663
1743
|
input: `./${entryPath}`,
|
|
1664
1744
|
outDir,
|
|
1665
|
-
declaration: options.emitTypes !== false,
|
|
1666
|
-
addRelativeDeclarationExtensions: true,
|
|
1745
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
1667
1746
|
format: "esm",
|
|
1668
|
-
ext: "mjs"
|
|
1669
|
-
typescript: {
|
|
1670
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
1671
|
-
}
|
|
1747
|
+
ext: "mjs"
|
|
1672
1748
|
});
|
|
1673
1749
|
ret.push({
|
|
1674
1750
|
name: `${name}-cjs`,
|
|
1675
1751
|
builder: "mkdist",
|
|
1676
1752
|
input: `./${entryPath}`,
|
|
1677
1753
|
outDir,
|
|
1678
|
-
declaration: options.emitTypes !== false,
|
|
1679
|
-
addRelativeDeclarationExtensions: true,
|
|
1754
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
1680
1755
|
format: "cjs",
|
|
1681
|
-
ext: "cjs"
|
|
1682
|
-
typescript: {
|
|
1683
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
1684
|
-
}
|
|
1756
|
+
ext: "cjs"
|
|
1685
1757
|
});
|
|
1686
1758
|
return ret;
|
|
1687
1759
|
}, []),
|
|
@@ -1766,6 +1838,17 @@ async function resolveOptions(options, config) {
|
|
|
1766
1838
|
}
|
|
1767
1839
|
resolvedOptions.hooks = {
|
|
1768
1840
|
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
1841
|
+
if (options.plugins && options.plugins.length > 0) {
|
|
1842
|
+
writeDebug(` \u{1F9E9} Found ${options.plugins.length} plugins in provided build options`, config);
|
|
1843
|
+
opts.plugins = options.plugins;
|
|
1844
|
+
} else {
|
|
1845
|
+
writeDebug(` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
|
|
1846
|
+
opts.plugins = await Promise.all([
|
|
1847
|
+
analyzePlugin(resolvedOptions),
|
|
1848
|
+
tscPlugin(resolvedOptions),
|
|
1849
|
+
onErrorPlugin(resolvedOptions)
|
|
1850
|
+
]);
|
|
1851
|
+
}
|
|
1769
1852
|
}, "rollup:options"),
|
|
1770
1853
|
"mkdist:entry:options": /* @__PURE__ */ __name(async (ctx, entry, opts) => {
|
|
1771
1854
|
opts.esbuild ||= {};
|
package/dist/build.cjs
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk5MDNSLYXcjs = require('./chunk-5MDNSLYX.cjs');
|
|
9
9
|
require('./chunk-WGGER7UI.cjs');
|
|
10
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-OOFPXPRC.cjs');
|
|
11
|
+
require('./chunk-X25DCA4T.cjs');
|
|
12
|
+
require('./chunk-VPCO2H3G.cjs');
|
|
11
13
|
require('./chunk-K5SEKFQA.cjs');
|
|
12
14
|
require('./chunk-BGYQAVKQ.cjs');
|
|
13
15
|
|
|
@@ -17,4 +19,4 @@ require('./chunk-BGYQAVKQ.cjs');
|
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
|
|
20
|
-
exports.build =
|
|
22
|
+
exports.build = _chunk5MDNSLYXcjs.build; exports.cleanOutputPath = _chunk5MDNSLYXcjs.cleanOutputPath; exports.copyBuildAssets = _chunk5MDNSLYXcjs.copyBuildAssets; exports.executeUnbuild = _chunk5MDNSLYXcjs.executeUnbuild; exports.generatePackageJson = _chunk5MDNSLYXcjs.generatePackageJson; exports.resolveOptions = _chunk5MDNSLYXcjs.resolveOptions;
|
package/dist/build.js
CHANGED
|
@@ -5,9 +5,11 @@ import {
|
|
|
5
5
|
executeUnbuild,
|
|
6
6
|
generatePackageJson,
|
|
7
7
|
resolveOptions
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-T3BNH4LG.js";
|
|
9
9
|
import "./chunk-JLKMLDBA.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-5XTPDLOE.js";
|
|
11
|
+
import "./chunk-2FX3WQNK.js";
|
|
12
|
+
import "./chunk-IYFBAI6G.js";
|
|
11
13
|
import "./chunk-EJVOWVIQ.js";
|
|
12
14
|
import "./chunk-3GQAWCBQ.js";
|
|
13
15
|
export {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeError
|
|
3
|
+
} from "./chunk-EJVOWVIQ.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
7
|
+
|
|
8
|
+
// src/plugins/on-error.ts
|
|
9
|
+
var onErrorPlugin = /* @__PURE__ */ __name((options) => ({
|
|
10
|
+
name: "storm:on-error",
|
|
11
|
+
buildEnd(error) {
|
|
12
|
+
if (error) {
|
|
13
|
+
writeError(`The following errors occurred during the build:
|
|
14
|
+
${error ? error.message : "Unknown build error"}
|
|
15
|
+
|
|
16
|
+
`, options.config);
|
|
17
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
renderError(error) {
|
|
21
|
+
writeError(`The following errors occurred during the build:
|
|
22
|
+
${error ? error.message : "Unknown build error"}
|
|
23
|
+
|
|
24
|
+
`, options.config);
|
|
25
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
26
|
+
}
|
|
27
|
+
}), "onErrorPlugin");
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
onErrorPlugin
|
|
31
|
+
};
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
var _chunkWGGER7UIcjs = require('./chunk-WGGER7UI.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkOOFPXPRCcjs = require('./chunk-OOFPXPRC.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkX25DCA4Tcjs = require('./chunk-X25DCA4T.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkVPCO2H3Gcjs = require('./chunk-VPCO2H3G.cjs');
|
|
7
14
|
|
|
8
15
|
|
|
9
16
|
|
|
@@ -805,13 +812,12 @@ var _createtaskgraph = require('nx/src/tasks-runner/create-task-graph');
|
|
|
805
812
|
|
|
806
813
|
|
|
807
814
|
var _findworkspaceroot = require('nx/src/utils/find-workspace-root');
|
|
808
|
-
var _pkgtypes = require('pkg-types');
|
|
809
815
|
var _unbuild = require('unbuild');
|
|
810
816
|
async function resolveOptions(options, config) {
|
|
811
817
|
_chunkK5SEKFQAcjs.writeDebug.call(void 0, " \u2699\uFE0F Resolving build options", config);
|
|
812
818
|
const stopwatch = _chunkK5SEKFQAcjs.getStopwatch.call(void 0, "Build options resolution");
|
|
813
819
|
if (options.configPath) {
|
|
814
|
-
const configFile = await
|
|
820
|
+
const configFile = await _chunkVPCO2H3Gcjs.loadConfig.call(void 0, options.configPath);
|
|
815
821
|
if (configFile) {
|
|
816
822
|
options = _defu2.default.call(void 0, options, configFile);
|
|
817
823
|
}
|
|
@@ -841,7 +847,6 @@ async function resolveOptions(options, config) {
|
|
|
841
847
|
if (!_fs.existsSync.call(void 0, tsconfig)) {
|
|
842
848
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
843
849
|
}
|
|
844
|
-
const tsconfigFile = await _pkgtypes.readTSConfig.call(void 0, tsconfig);
|
|
845
850
|
let sourceRoot = projectJson.sourceRoot;
|
|
846
851
|
if (!sourceRoot) {
|
|
847
852
|
sourceRoot = _chunkK5SEKFQAcjs.joinPaths.call(void 0, options.projectRoot, "src");
|
|
@@ -885,26 +890,18 @@ async function resolveOptions(options, config) {
|
|
|
885
890
|
builder: "mkdist",
|
|
886
891
|
input: `./${entryPath}`,
|
|
887
892
|
outDir,
|
|
888
|
-
declaration: options.emitTypes !== false,
|
|
889
|
-
addRelativeDeclarationExtensions: true,
|
|
893
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
890
894
|
format: "esm",
|
|
891
|
-
ext: "mjs"
|
|
892
|
-
typescript: {
|
|
893
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
894
|
-
}
|
|
895
|
+
ext: "mjs"
|
|
895
896
|
});
|
|
896
897
|
ret.push({
|
|
897
898
|
name: `${name}-cjs`,
|
|
898
899
|
builder: "mkdist",
|
|
899
900
|
input: `./${entryPath}`,
|
|
900
901
|
outDir,
|
|
901
|
-
declaration: options.emitTypes !== false,
|
|
902
|
-
addRelativeDeclarationExtensions: true,
|
|
902
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
903
903
|
format: "cjs",
|
|
904
|
-
ext: "cjs"
|
|
905
|
-
typescript: {
|
|
906
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
907
|
-
}
|
|
904
|
+
ext: "cjs"
|
|
908
905
|
});
|
|
909
906
|
return ret;
|
|
910
907
|
}, []),
|
|
@@ -978,7 +975,7 @@ async function resolveOptions(options, config) {
|
|
|
978
975
|
if (options.rollup) {
|
|
979
976
|
let rollup = {};
|
|
980
977
|
if (typeof options.rollup === "string") {
|
|
981
|
-
const rollupFile = await
|
|
978
|
+
const rollupFile = await _chunkVPCO2H3Gcjs.loadConfig.call(void 0, options.rollup);
|
|
982
979
|
if (rollupFile) {
|
|
983
980
|
rollup = rollupFile;
|
|
984
981
|
}
|
|
@@ -989,6 +986,17 @@ async function resolveOptions(options, config) {
|
|
|
989
986
|
}
|
|
990
987
|
resolvedOptions.hooks = {
|
|
991
988
|
"rollup:options": /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (ctx, opts) => {
|
|
989
|
+
if (options.plugins && options.plugins.length > 0) {
|
|
990
|
+
_chunkK5SEKFQAcjs.writeDebug.call(void 0, ` \u{1F9E9} Found ${options.plugins.length} plugins in provided build options`, config);
|
|
991
|
+
opts.plugins = options.plugins;
|
|
992
|
+
} else {
|
|
993
|
+
_chunkK5SEKFQAcjs.writeDebug.call(void 0, ` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
|
|
994
|
+
opts.plugins = await Promise.all([
|
|
995
|
+
_chunkOOFPXPRCcjs.analyzePlugin.call(void 0, resolvedOptions),
|
|
996
|
+
_chunkVPCO2H3Gcjs.tscPlugin.call(void 0, resolvedOptions),
|
|
997
|
+
_chunkX25DCA4Tcjs.onErrorPlugin.call(void 0, resolvedOptions)
|
|
998
|
+
]);
|
|
999
|
+
}
|
|
992
1000
|
}, "rollup:options"),
|
|
993
1001
|
"mkdist:entry:options": /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (ctx, entry, opts) => {
|
|
994
1002
|
opts.esbuild ||= {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeInfo
|
|
3
|
+
} from "./chunk-EJVOWVIQ.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
7
|
+
|
|
8
|
+
// src/plugins/analyze.ts
|
|
9
|
+
var formatBytes = /* @__PURE__ */ __name((bytes) => {
|
|
10
|
+
if (bytes === 0) return "0 Byte";
|
|
11
|
+
const k = 1e3;
|
|
12
|
+
const dm = 3;
|
|
13
|
+
const sizes = [
|
|
14
|
+
"Bytes",
|
|
15
|
+
"KB",
|
|
16
|
+
"MB",
|
|
17
|
+
"GB"
|
|
18
|
+
];
|
|
19
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
20
|
+
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
21
|
+
}, "formatBytes");
|
|
22
|
+
var analyzePlugin = /* @__PURE__ */ __name((options) => {
|
|
23
|
+
return {
|
|
24
|
+
name: "storm:analyzer",
|
|
25
|
+
renderChunk(source, chunk) {
|
|
26
|
+
const sourceBytes = formatBytes(source.length);
|
|
27
|
+
const fileName = chunk.fileName;
|
|
28
|
+
writeInfo(` - ${fileName} ${sourceBytes}`, options.config);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}, "analyzePlugin");
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
analyzePlugin
|
|
35
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
writeTrace
|
|
3
|
+
} from "./chunk-EJVOWVIQ.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
7
|
+
|
|
8
|
+
// src/plugins/tsc.ts
|
|
9
|
+
import { readCachedProjectGraph } from "@nx/devkit";
|
|
10
|
+
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
11
|
+
import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler-helper-dependency";
|
|
12
|
+
import ts2Plugin from "rollup-plugin-typescript2";
|
|
13
|
+
|
|
14
|
+
// src/utilities/helpers.ts
|
|
15
|
+
import { joinPathFragments } from "@nx/devkit";
|
|
16
|
+
import { computeCompilerOptionsPaths } from "@nx/js/src/utils/buildable-libs-utils";
|
|
17
|
+
import { dirname, extname } from "node:path";
|
|
18
|
+
import { pathToFileURL } from "node:url";
|
|
19
|
+
import ts from "typescript";
|
|
20
|
+
async function loadConfig(configPath) {
|
|
21
|
+
if (!/\.(js|mjs)$/.test(extname(configPath))) {
|
|
22
|
+
throw new Error("Unsupported config file format");
|
|
23
|
+
}
|
|
24
|
+
return import(pathToFileURL(configPath).toString()).then((config) => config.default);
|
|
25
|
+
}
|
|
26
|
+
__name(loadConfig, "loadConfig");
|
|
27
|
+
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
28
|
+
const tsConfigFile = ts.readConfigFile(joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath), ts.sys.readFile);
|
|
29
|
+
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, dirname(joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath)));
|
|
30
|
+
const compilerOptions = {
|
|
31
|
+
rootDir: projectRoot,
|
|
32
|
+
declaration: true,
|
|
33
|
+
paths: computeCompilerOptionsPaths(tsConfig, dependencies ?? [])
|
|
34
|
+
};
|
|
35
|
+
writeTrace(compilerOptions, config);
|
|
36
|
+
return compilerOptions;
|
|
37
|
+
}
|
|
38
|
+
__name(createTsCompilerOptions, "createTsCompilerOptions");
|
|
39
|
+
|
|
40
|
+
// src/plugins/tsc.ts
|
|
41
|
+
var tscPlugin = /* @__PURE__ */ __name(async (options) => {
|
|
42
|
+
const projectGraph = readCachedProjectGraph();
|
|
43
|
+
const result = calculateProjectBuildableDependencies(void 0, projectGraph, options.config.workspaceRoot, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
44
|
+
let dependencies = result.dependencies;
|
|
45
|
+
const tsLibDependency = getHelperDependency(HelperDependency.tsc, options.tsconfig, dependencies, projectGraph, true);
|
|
46
|
+
if (tsLibDependency) {
|
|
47
|
+
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
48
|
+
dependencies.push(tsLibDependency);
|
|
49
|
+
}
|
|
50
|
+
const compilerOptions = await createTsCompilerOptions(options.config, options.tsconfig, options.projectRoot, dependencies);
|
|
51
|
+
return ts2Plugin({
|
|
52
|
+
check: options.declaration !== false,
|
|
53
|
+
tsconfig: options.tsconfig,
|
|
54
|
+
tsconfigOverride: compilerOptions
|
|
55
|
+
});
|
|
56
|
+
}, "tscPlugin");
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
loadConfig,
|
|
60
|
+
createTsCompilerOptions,
|
|
61
|
+
tscPlugin
|
|
62
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkK5SEKFQAcjs = require('./chunk-K5SEKFQA.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
|
|
7
|
+
|
|
8
|
+
// src/plugins/analyze.ts
|
|
9
|
+
var formatBytes = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (bytes) => {
|
|
10
|
+
if (bytes === 0) return "0 Byte";
|
|
11
|
+
const k = 1e3;
|
|
12
|
+
const dm = 3;
|
|
13
|
+
const sizes = [
|
|
14
|
+
"Bytes",
|
|
15
|
+
"KB",
|
|
16
|
+
"MB",
|
|
17
|
+
"GB"
|
|
18
|
+
];
|
|
19
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
20
|
+
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
21
|
+
}, "formatBytes");
|
|
22
|
+
var analyzePlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options) => {
|
|
23
|
+
return {
|
|
24
|
+
name: "storm:analyzer",
|
|
25
|
+
renderChunk(source, chunk) {
|
|
26
|
+
const sourceBytes = formatBytes(source.length);
|
|
27
|
+
const fileName = chunk.fileName;
|
|
28
|
+
_chunkK5SEKFQAcjs.writeInfo.call(void 0, ` - ${fileName} ${sourceBytes}`, options.config);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}, "analyzePlugin");
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.analyzePlugin = analyzePlugin;
|
|
@@ -2,8 +2,15 @@ import {
|
|
|
2
2
|
cleanDirectories
|
|
3
3
|
} from "./chunk-JLKMLDBA.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
analyzePlugin
|
|
6
|
+
} from "./chunk-5XTPDLOE.js";
|
|
7
|
+
import {
|
|
8
|
+
onErrorPlugin
|
|
9
|
+
} from "./chunk-2FX3WQNK.js";
|
|
10
|
+
import {
|
|
11
|
+
loadConfig,
|
|
12
|
+
tscPlugin
|
|
13
|
+
} from "./chunk-IYFBAI6G.js";
|
|
7
14
|
import {
|
|
8
15
|
COLOR_KEYS,
|
|
9
16
|
LogLevel,
|
|
@@ -805,7 +812,6 @@ import { existsSync as existsSync3 } from "node:fs";
|
|
|
805
812
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
806
813
|
import { relative as relative2 } from "node:path";
|
|
807
814
|
import { findWorkspaceRoot as findWorkspaceRoot2 } from "nx/src/utils/find-workspace-root";
|
|
808
|
-
import { readTSConfig } from "pkg-types";
|
|
809
815
|
import { build as unbuild } from "unbuild";
|
|
810
816
|
async function resolveOptions(options, config) {
|
|
811
817
|
writeDebug(" \u2699\uFE0F Resolving build options", config);
|
|
@@ -841,7 +847,6 @@ async function resolveOptions(options, config) {
|
|
|
841
847
|
if (!existsSync3(tsconfig)) {
|
|
842
848
|
throw new Error("Cannot find tsconfig.json configuration");
|
|
843
849
|
}
|
|
844
|
-
const tsconfigFile = await readTSConfig(tsconfig);
|
|
845
850
|
let sourceRoot = projectJson.sourceRoot;
|
|
846
851
|
if (!sourceRoot) {
|
|
847
852
|
sourceRoot = joinPaths(options.projectRoot, "src");
|
|
@@ -885,26 +890,18 @@ async function resolveOptions(options, config) {
|
|
|
885
890
|
builder: "mkdist",
|
|
886
891
|
input: `./${entryPath}`,
|
|
887
892
|
outDir,
|
|
888
|
-
declaration: options.emitTypes !== false,
|
|
889
|
-
addRelativeDeclarationExtensions: true,
|
|
893
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
890
894
|
format: "esm",
|
|
891
|
-
ext: "mjs"
|
|
892
|
-
typescript: {
|
|
893
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
894
|
-
}
|
|
895
|
+
ext: "mjs"
|
|
895
896
|
});
|
|
896
897
|
ret.push({
|
|
897
898
|
name: `${name}-cjs`,
|
|
898
899
|
builder: "mkdist",
|
|
899
900
|
input: `./${entryPath}`,
|
|
900
901
|
outDir,
|
|
901
|
-
declaration: options.emitTypes !== false,
|
|
902
|
-
addRelativeDeclarationExtensions: true,
|
|
902
|
+
declaration: options.emitTypes !== false ? "compatible" : false,
|
|
903
903
|
format: "cjs",
|
|
904
|
-
ext: "cjs"
|
|
905
|
-
typescript: {
|
|
906
|
-
compilerOptions: tsconfigFile.compilerOptions
|
|
907
|
-
}
|
|
904
|
+
ext: "cjs"
|
|
908
905
|
});
|
|
909
906
|
return ret;
|
|
910
907
|
}, []),
|
|
@@ -989,6 +986,17 @@ async function resolveOptions(options, config) {
|
|
|
989
986
|
}
|
|
990
987
|
resolvedOptions.hooks = {
|
|
991
988
|
"rollup:options": /* @__PURE__ */ __name(async (ctx, opts) => {
|
|
989
|
+
if (options.plugins && options.plugins.length > 0) {
|
|
990
|
+
writeDebug(` \u{1F9E9} Found ${options.plugins.length} plugins in provided build options`, config);
|
|
991
|
+
opts.plugins = options.plugins;
|
|
992
|
+
} else {
|
|
993
|
+
writeDebug(` \u{1F9E9} No plugins found in provided build options, using default plugins`, config);
|
|
994
|
+
opts.plugins = await Promise.all([
|
|
995
|
+
analyzePlugin(resolvedOptions),
|
|
996
|
+
tscPlugin(resolvedOptions),
|
|
997
|
+
onErrorPlugin(resolvedOptions)
|
|
998
|
+
]);
|
|
999
|
+
}
|
|
992
1000
|
}, "rollup:options"),
|
|
993
1001
|
"mkdist:entry:options": /* @__PURE__ */ __name(async (ctx, entry, opts) => {
|
|
994
1002
|
opts.esbuild ||= {};
|
|
@@ -5,9 +5,15 @@ var _chunkK5SEKFQAcjs = require('./chunk-K5SEKFQA.cjs');
|
|
|
5
5
|
|
|
6
6
|
var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
|
|
7
7
|
|
|
8
|
-
// src/
|
|
8
|
+
// src/plugins/tsc.ts
|
|
9
9
|
var _devkit = require('@nx/devkit');
|
|
10
10
|
var _buildablelibsutils = require('@nx/js/src/utils/buildable-libs-utils');
|
|
11
|
+
var _compilerhelperdependency = require('@nx/js/src/utils/compiler-helper-dependency');
|
|
12
|
+
var _rollupplugintypescript2 = require('rollup-plugin-typescript2'); var _rollupplugintypescript22 = _interopRequireDefault(_rollupplugintypescript2);
|
|
13
|
+
|
|
14
|
+
// src/utilities/helpers.ts
|
|
15
|
+
|
|
16
|
+
|
|
11
17
|
var _path = require('path');
|
|
12
18
|
var _url = require('url');
|
|
13
19
|
var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
|
|
@@ -31,7 +37,26 @@ async function createTsCompilerOptions(config, tsConfigPath, projectRoot, depend
|
|
|
31
37
|
}
|
|
32
38
|
_chunkBGYQAVKQcjs.__name.call(void 0, createTsCompilerOptions, "createTsCompilerOptions");
|
|
33
39
|
|
|
40
|
+
// src/plugins/tsc.ts
|
|
41
|
+
var tscPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (options) => {
|
|
42
|
+
const projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
43
|
+
const result = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, projectGraph, options.config.workspaceRoot, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
44
|
+
let dependencies = result.dependencies;
|
|
45
|
+
const tsLibDependency = _compilerhelperdependency.getHelperDependency.call(void 0, _compilerhelperdependency.HelperDependency.tsc, options.tsconfig, dependencies, projectGraph, true);
|
|
46
|
+
if (tsLibDependency) {
|
|
47
|
+
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
48
|
+
dependencies.push(tsLibDependency);
|
|
49
|
+
}
|
|
50
|
+
const compilerOptions = await createTsCompilerOptions(options.config, options.tsconfig, options.projectRoot, dependencies);
|
|
51
|
+
return _rollupplugintypescript22.default.call(void 0, {
|
|
52
|
+
check: options.declaration !== false,
|
|
53
|
+
tsconfig: options.tsconfig,
|
|
54
|
+
tsconfigOverride: compilerOptions
|
|
55
|
+
});
|
|
56
|
+
}, "tscPlugin");
|
|
57
|
+
|
|
58
|
+
|
|
34
59
|
|
|
35
60
|
|
|
36
61
|
|
|
37
|
-
exports.loadConfig = loadConfig; exports.createTsCompilerOptions = createTsCompilerOptions;
|
|
62
|
+
exports.loadConfig = loadConfig; exports.createTsCompilerOptions = createTsCompilerOptions; exports.tscPlugin = tscPlugin;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkK5SEKFQAcjs = require('./chunk-K5SEKFQA.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkBGYQAVKQcjs = require('./chunk-BGYQAVKQ.cjs');
|
|
7
|
+
|
|
8
|
+
// src/plugins/on-error.ts
|
|
9
|
+
var onErrorPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options) => ({
|
|
10
|
+
name: "storm:on-error",
|
|
11
|
+
buildEnd(error) {
|
|
12
|
+
if (error) {
|
|
13
|
+
_chunkK5SEKFQAcjs.writeError.call(void 0, `The following errors occurred during the build:
|
|
14
|
+
${error ? error.message : "Unknown build error"}
|
|
15
|
+
|
|
16
|
+
`, options.config);
|
|
17
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
renderError(error) {
|
|
21
|
+
_chunkK5SEKFQAcjs.writeError.call(void 0, `The following errors occurred during the build:
|
|
22
|
+
${error ? error.message : "Unknown build error"}
|
|
23
|
+
|
|
24
|
+
`, options.config);
|
|
25
|
+
throw new Error("Storm unbuild process failed with errors.");
|
|
26
|
+
}
|
|
27
|
+
}), "onErrorPlugin");
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
exports.onErrorPlugin = onErrorPlugin;
|
package/dist/index.cjs
CHANGED
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk5MDNSLYXcjs = require('./chunk-5MDNSLYX.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkWGGER7UIcjs = require('./chunk-WGGER7UI.cjs');
|
|
13
13
|
require('./chunk-ORA4UQMU.cjs');
|
|
14
|
+
require('./chunk-OOFPXPRC.cjs');
|
|
15
|
+
require('./chunk-X25DCA4T.cjs');
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
var
|
|
19
|
+
var _chunkVPCO2H3Gcjs = require('./chunk-VPCO2H3G.cjs');
|
|
18
20
|
require('./chunk-K5SEKFQA.cjs');
|
|
19
21
|
require('./chunk-BGYQAVKQ.cjs');
|
|
20
22
|
|
|
@@ -28,4 +30,4 @@ require('./chunk-BGYQAVKQ.cjs');
|
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
|
|
31
|
-
exports.build =
|
|
33
|
+
exports.build = _chunk5MDNSLYXcjs.build; exports.clean = _chunkWGGER7UIcjs.clean; exports.cleanDirectories = _chunkWGGER7UIcjs.cleanDirectories; exports.cleanOutputPath = _chunk5MDNSLYXcjs.cleanOutputPath; exports.copyBuildAssets = _chunk5MDNSLYXcjs.copyBuildAssets; exports.createTsCompilerOptions = _chunkVPCO2H3Gcjs.createTsCompilerOptions; exports.executeUnbuild = _chunk5MDNSLYXcjs.executeUnbuild; exports.generatePackageJson = _chunk5MDNSLYXcjs.generatePackageJson; exports.loadConfig = _chunkVPCO2H3Gcjs.loadConfig; exports.resolveOptions = _chunk5MDNSLYXcjs.resolveOptions;
|
package/dist/index.js
CHANGED
|
@@ -5,16 +5,18 @@ import {
|
|
|
5
5
|
executeUnbuild,
|
|
6
6
|
generatePackageJson,
|
|
7
7
|
resolveOptions
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-T3BNH4LG.js";
|
|
9
9
|
import {
|
|
10
10
|
clean,
|
|
11
11
|
cleanDirectories
|
|
12
12
|
} from "./chunk-JLKMLDBA.js";
|
|
13
13
|
import "./chunk-OULCUN6I.js";
|
|
14
|
+
import "./chunk-5XTPDLOE.js";
|
|
15
|
+
import "./chunk-2FX3WQNK.js";
|
|
14
16
|
import {
|
|
15
17
|
createTsCompilerOptions,
|
|
16
18
|
loadConfig
|
|
17
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-IYFBAI6G.js";
|
|
18
20
|
import "./chunk-EJVOWVIQ.js";
|
|
19
21
|
import "./chunk-3GQAWCBQ.js";
|
|
20
22
|
export {
|
package/dist/plugins/analyze.cjs
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkOOFPXPRCcjs = require('../chunk-OOFPXPRC.cjs');
|
|
4
|
+
require('../chunk-K5SEKFQA.cjs');
|
|
5
|
+
require('../chunk-BGYQAVKQ.cjs');
|
|
4
6
|
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// src/plugins/analyze.ts
|
|
9
|
-
var formatBytes = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (bytes) => {
|
|
10
|
-
if (bytes === 0) return "0 Byte";
|
|
11
|
-
const k = 1e3;
|
|
12
|
-
const dm = 3;
|
|
13
|
-
const sizes = [
|
|
14
|
-
"Bytes",
|
|
15
|
-
"KB",
|
|
16
|
-
"MB",
|
|
17
|
-
"GB"
|
|
18
|
-
];
|
|
19
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
20
|
-
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
21
|
-
}, "formatBytes");
|
|
22
|
-
var analyzePlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options) => {
|
|
23
|
-
return {
|
|
24
|
-
name: "storm:analyzer",
|
|
25
|
-
renderChunk(source, chunk) {
|
|
26
|
-
const sourceBytes = formatBytes(source.length);
|
|
27
|
-
const fileName = chunk.fileName;
|
|
28
|
-
_chunkK5SEKFQAcjs.writeInfo.call(void 0, ` - ${fileName} ${sourceBytes}`, options.config);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}, "analyzePlugin");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
exports.analyzePlugin = analyzePlugin;
|
|
8
|
+
exports.analyzePlugin = _chunkOOFPXPRCcjs.analyzePlugin;
|
package/dist/plugins/analyze.js
CHANGED
|
@@ -1,34 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
} from "../chunk-3GQAWCBQ.js";
|
|
7
|
-
|
|
8
|
-
// src/plugins/analyze.ts
|
|
9
|
-
var formatBytes = /* @__PURE__ */ __name((bytes) => {
|
|
10
|
-
if (bytes === 0) return "0 Byte";
|
|
11
|
-
const k = 1e3;
|
|
12
|
-
const dm = 3;
|
|
13
|
-
const sizes = [
|
|
14
|
-
"Bytes",
|
|
15
|
-
"KB",
|
|
16
|
-
"MB",
|
|
17
|
-
"GB"
|
|
18
|
-
];
|
|
19
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
20
|
-
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`;
|
|
21
|
-
}, "formatBytes");
|
|
22
|
-
var analyzePlugin = /* @__PURE__ */ __name((options) => {
|
|
23
|
-
return {
|
|
24
|
-
name: "storm:analyzer",
|
|
25
|
-
renderChunk(source, chunk) {
|
|
26
|
-
const sourceBytes = formatBytes(source.length);
|
|
27
|
-
const fileName = chunk.fileName;
|
|
28
|
-
writeInfo(` - ${fileName} ${sourceBytes}`, options.config);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}, "analyzePlugin");
|
|
2
|
+
analyzePlugin
|
|
3
|
+
} from "../chunk-5XTPDLOE.js";
|
|
4
|
+
import "../chunk-EJVOWVIQ.js";
|
|
5
|
+
import "../chunk-3GQAWCBQ.js";
|
|
32
6
|
export {
|
|
33
7
|
analyzePlugin
|
|
34
8
|
};
|
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkX25DCA4Tcjs = require('../chunk-X25DCA4T.cjs');
|
|
4
|
+
require('../chunk-K5SEKFQA.cjs');
|
|
5
|
+
require('../chunk-BGYQAVKQ.cjs');
|
|
4
6
|
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// src/plugins/on-error.ts
|
|
9
|
-
var onErrorPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, (options) => ({
|
|
10
|
-
name: "storm:on-error",
|
|
11
|
-
buildEnd(error) {
|
|
12
|
-
if (error) {
|
|
13
|
-
_chunkK5SEKFQAcjs.writeError.call(void 0, `The following errors occurred during the build:
|
|
14
|
-
${error ? error.message : "Unknown build error"}
|
|
15
|
-
|
|
16
|
-
`, options.config);
|
|
17
|
-
throw new Error("Storm unbuild process failed with errors.");
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
renderError(error) {
|
|
21
|
-
_chunkK5SEKFQAcjs.writeError.call(void 0, `The following errors occurred during the build:
|
|
22
|
-
${error ? error.message : "Unknown build error"}
|
|
23
|
-
|
|
24
|
-
`, options.config);
|
|
25
|
-
throw new Error("Storm unbuild process failed with errors.");
|
|
26
|
-
}
|
|
27
|
-
}), "onErrorPlugin");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
exports.onErrorPlugin = onErrorPlugin;
|
|
8
|
+
exports.onErrorPlugin = _chunkX25DCA4Tcjs.onErrorPlugin;
|
package/dist/plugins/on-error.js
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
} from "../chunk-3GQAWCBQ.js";
|
|
7
|
-
|
|
8
|
-
// src/plugins/on-error.ts
|
|
9
|
-
var onErrorPlugin = /* @__PURE__ */ __name((options) => ({
|
|
10
|
-
name: "storm:on-error",
|
|
11
|
-
buildEnd(error) {
|
|
12
|
-
if (error) {
|
|
13
|
-
writeError(`The following errors occurred during the build:
|
|
14
|
-
${error ? error.message : "Unknown build error"}
|
|
15
|
-
|
|
16
|
-
`, options.config);
|
|
17
|
-
throw new Error("Storm unbuild process failed with errors.");
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
renderError(error) {
|
|
21
|
-
writeError(`The following errors occurred during the build:
|
|
22
|
-
${error ? error.message : "Unknown build error"}
|
|
23
|
-
|
|
24
|
-
`, options.config);
|
|
25
|
-
throw new Error("Storm unbuild process failed with errors.");
|
|
26
|
-
}
|
|
27
|
-
}), "onErrorPlugin");
|
|
2
|
+
onErrorPlugin
|
|
3
|
+
} from "../chunk-2FX3WQNK.js";
|
|
4
|
+
import "../chunk-EJVOWVIQ.js";
|
|
5
|
+
import "../chunk-3GQAWCBQ.js";
|
|
28
6
|
export {
|
|
29
7
|
onErrorPlugin
|
|
30
8
|
};
|
package/dist/plugins/tsc.cjs
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkVPCO2H3Gcjs = require('../chunk-VPCO2H3G.cjs');
|
|
4
4
|
require('../chunk-K5SEKFQA.cjs');
|
|
5
|
+
require('../chunk-BGYQAVKQ.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// src/plugins/tsc.ts
|
|
10
|
-
var _devkit = require('@nx/devkit');
|
|
11
|
-
var _buildablelibsutils = require('@nx/js/src/utils/buildable-libs-utils');
|
|
12
|
-
var _compilerhelperdependency = require('@nx/js/src/utils/compiler-helper-dependency');
|
|
13
|
-
var _rollupplugintypescript2 = require('rollup-plugin-typescript2'); var _rollupplugintypescript22 = _interopRequireDefault(_rollupplugintypescript2);
|
|
14
|
-
var tscPlugin = /* @__PURE__ */ _chunkBGYQAVKQcjs.__name.call(void 0, async (options) => {
|
|
15
|
-
const projectGraph = _devkit.readCachedProjectGraph.call(void 0, );
|
|
16
|
-
const result = _buildablelibsutils.calculateProjectBuildableDependencies.call(void 0, void 0, projectGraph, options.config.workspaceRoot, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
17
|
-
let dependencies = result.dependencies;
|
|
18
|
-
const tsLibDependency = _compilerhelperdependency.getHelperDependency.call(void 0, _compilerhelperdependency.HelperDependency.tsc, options.tsconfig, dependencies, projectGraph, true);
|
|
19
|
-
if (tsLibDependency) {
|
|
20
|
-
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
21
|
-
dependencies.push(tsLibDependency);
|
|
22
|
-
}
|
|
23
|
-
const compilerOptions = await _chunkYC7U7HH4cjs.createTsCompilerOptions.call(void 0, options.config, options.tsconfig, options.projectRoot, dependencies);
|
|
24
|
-
return _rollupplugintypescript22.default.call(void 0, {
|
|
25
|
-
check: options.declaration !== false,
|
|
26
|
-
tsconfig: options.tsconfig,
|
|
27
|
-
tsconfigOverride: compilerOptions
|
|
28
|
-
});
|
|
29
|
-
}, "tscPlugin");
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exports.tscPlugin = tscPlugin;
|
|
8
|
+
exports.tscPlugin = _chunkVPCO2H3Gcjs.tscPlugin;
|
package/dist/plugins/tsc.js
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
2
|
+
tscPlugin
|
|
3
|
+
} from "../chunk-IYFBAI6G.js";
|
|
4
4
|
import "../chunk-EJVOWVIQ.js";
|
|
5
|
-
import
|
|
6
|
-
__name
|
|
7
|
-
} from "../chunk-3GQAWCBQ.js";
|
|
8
|
-
|
|
9
|
-
// src/plugins/tsc.ts
|
|
10
|
-
import { readCachedProjectGraph } from "@nx/devkit";
|
|
11
|
-
import { calculateProjectBuildableDependencies } from "@nx/js/src/utils/buildable-libs-utils";
|
|
12
|
-
import { getHelperDependency, HelperDependency } from "@nx/js/src/utils/compiler-helper-dependency";
|
|
13
|
-
import ts2Plugin from "rollup-plugin-typescript2";
|
|
14
|
-
var tscPlugin = /* @__PURE__ */ __name(async (options) => {
|
|
15
|
-
const projectGraph = readCachedProjectGraph();
|
|
16
|
-
const result = calculateProjectBuildableDependencies(void 0, projectGraph, options.config.workspaceRoot, options.projectName, process.env.NX_TASK_TARGET_TARGET || "build", process.env.NX_TASK_TARGET_CONFIGURATION || "production", true);
|
|
17
|
-
let dependencies = result.dependencies;
|
|
18
|
-
const tsLibDependency = getHelperDependency(HelperDependency.tsc, options.tsconfig, dependencies, projectGraph, true);
|
|
19
|
-
if (tsLibDependency) {
|
|
20
|
-
dependencies = dependencies.filter((deps) => deps.name !== tsLibDependency.name);
|
|
21
|
-
dependencies.push(tsLibDependency);
|
|
22
|
-
}
|
|
23
|
-
const compilerOptions = await createTsCompilerOptions(options.config, options.tsconfig, options.projectRoot, dependencies);
|
|
24
|
-
return ts2Plugin({
|
|
25
|
-
check: options.declaration !== false,
|
|
26
|
-
tsconfig: options.tsconfig,
|
|
27
|
-
tsconfigOverride: compilerOptions
|
|
28
|
-
});
|
|
29
|
-
}, "tscPlugin");
|
|
5
|
+
import "../chunk-3GQAWCBQ.js";
|
|
30
6
|
export {
|
|
31
7
|
tscPlugin
|
|
32
8
|
};
|
package/package.json
CHANGED
package/dist/chunk-QOHGN7PS.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
writeTrace
|
|
3
|
-
} from "./chunk-EJVOWVIQ.js";
|
|
4
|
-
import {
|
|
5
|
-
__name
|
|
6
|
-
} from "./chunk-3GQAWCBQ.js";
|
|
7
|
-
|
|
8
|
-
// src/utilities/helpers.ts
|
|
9
|
-
import { joinPathFragments } from "@nx/devkit";
|
|
10
|
-
import { computeCompilerOptionsPaths } from "@nx/js/src/utils/buildable-libs-utils";
|
|
11
|
-
import { dirname, extname } from "node:path";
|
|
12
|
-
import { pathToFileURL } from "node:url";
|
|
13
|
-
import ts from "typescript";
|
|
14
|
-
async function loadConfig(configPath) {
|
|
15
|
-
if (!/\.(js|mjs)$/.test(extname(configPath))) {
|
|
16
|
-
throw new Error("Unsupported config file format");
|
|
17
|
-
}
|
|
18
|
-
return import(pathToFileURL(configPath).toString()).then((config) => config.default);
|
|
19
|
-
}
|
|
20
|
-
__name(loadConfig, "loadConfig");
|
|
21
|
-
async function createTsCompilerOptions(config, tsConfigPath, projectRoot, dependencies) {
|
|
22
|
-
const tsConfigFile = ts.readConfigFile(joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath), ts.sys.readFile);
|
|
23
|
-
const tsConfig = ts.parseJsonConfigFileContent(tsConfigFile.config, ts.sys, dirname(joinPathFragments(config.workspaceRoot, projectRoot, tsConfigPath)));
|
|
24
|
-
const compilerOptions = {
|
|
25
|
-
rootDir: projectRoot,
|
|
26
|
-
declaration: true,
|
|
27
|
-
paths: computeCompilerOptionsPaths(tsConfig, dependencies ?? [])
|
|
28
|
-
};
|
|
29
|
-
writeTrace(compilerOptions, config);
|
|
30
|
-
return compilerOptions;
|
|
31
|
-
}
|
|
32
|
-
__name(createTsCompilerOptions, "createTsCompilerOptions");
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
-
loadConfig,
|
|
36
|
-
createTsCompilerOptions
|
|
37
|
-
};
|