@tyndall/build 0.0.6 → 0.0.8
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/dist/build.d.ts.map +1 -1
- package/dist/build.js +53 -14
- package/package.json +3 -3
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,QAAQ,EAIR,UAAU,EAMV,iBAAiB,EAClB,MAAM,eAAe,CAAC;AA+DvB,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,KAAK,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnC,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,KAAK,EAAE,iBAAiB,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,QAAQ,EAIR,UAAU,EAMV,iBAAiB,EAClB,MAAM,eAAe,CAAC;AA+DvB,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,KAAK,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACnC,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,KAAK,EAAE,iBAAiB,CAAC;CAC1B;AAo5BD,eAAO,MAAM,KAAK,GAAU,SAAS,YAAY,KAAG,OAAO,CAAC,WAAW,CAi6CtE,CAAC"}
|
package/dist/build.js
CHANGED
|
@@ -552,52 +552,78 @@ const buildChunkFile = async (entryPath, outputPath, options) => {
|
|
|
552
552
|
},
|
|
553
553
|
}
|
|
554
554
|
: null;
|
|
555
|
-
|
|
555
|
+
const selectedBundler = options.syntaxTarget === "es5" ? "esbuild" : options.bundler ?? "bun";
|
|
556
|
+
if (selectedBundler === "esbuild") {
|
|
557
|
+
const tempOutDir = join(dirname(outputPath), `.@tyndall/esbuild-tmp-${hash(`${outputPath}-${Date.now()}`)}`);
|
|
556
558
|
try {
|
|
559
|
+
await mkdir(tempOutDir, { recursive: true });
|
|
557
560
|
const plugins = shimPlugin ? [shimPlugin, ...bundlerPlugins] : [...bundlerPlugins];
|
|
558
561
|
const bundled = await esbuild({
|
|
559
562
|
entryPoints: [entryPath],
|
|
560
563
|
bundle: true,
|
|
561
564
|
platform: options.target === "node" ? "node" : "browser",
|
|
562
565
|
format: options.format,
|
|
563
|
-
target: "es2015",
|
|
566
|
+
target: options.syntaxTarget === "es5" ? "es2015" : options.esbuildTarget ?? "esnext",
|
|
564
567
|
splitting: false,
|
|
565
568
|
sourcemap: false,
|
|
566
569
|
minify: false,
|
|
567
570
|
logLevel: "silent",
|
|
568
571
|
jsx: "automatic",
|
|
569
572
|
plugins: plugins.length > 0 ? plugins : undefined,
|
|
573
|
+
outdir: tempOutDir,
|
|
574
|
+
loader: {
|
|
575
|
+
".woff": "file",
|
|
576
|
+
".woff2": "file",
|
|
577
|
+
".ttf": "file",
|
|
578
|
+
".otf": "file",
|
|
579
|
+
},
|
|
570
580
|
write: false,
|
|
571
581
|
});
|
|
572
582
|
const outputFiles = bundled.outputFiles ?? [];
|
|
573
583
|
const jsOutput = outputFiles.find((file) => file.path.endsWith(".js") || file.path.endsWith(".mjs")) ??
|
|
574
584
|
outputFiles[0];
|
|
575
|
-
const outputText = jsOutput?.text
|
|
585
|
+
const outputText = jsOutput?.text ??
|
|
586
|
+
(jsOutput?.contents ? Buffer.from(jsOutput.contents).toString("utf-8") : undefined);
|
|
576
587
|
if (!outputText) {
|
|
577
|
-
throw new Error("
|
|
588
|
+
throw new Error("esbuild bundling produced no output.");
|
|
578
589
|
}
|
|
579
|
-
const transformed =
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
590
|
+
const transformed = options.syntaxTarget === "es5"
|
|
591
|
+
? await transform(outputText, {
|
|
592
|
+
jsc: {
|
|
593
|
+
target: "es5",
|
|
594
|
+
parser: {
|
|
595
|
+
syntax: "ecmascript",
|
|
596
|
+
},
|
|
584
597
|
},
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
598
|
+
sourceMaps: false,
|
|
599
|
+
})
|
|
600
|
+
: { code: outputText };
|
|
588
601
|
await mkdir(dirname(outputPath), { recursive: true });
|
|
589
602
|
await writeFile(outputPath, transformed.code, "utf-8");
|
|
603
|
+
const assetOutputDir = shouldEmitCss && options.cssOutputPath ? dirname(options.cssOutputPath) : dirname(outputPath);
|
|
590
604
|
if (shouldEmitCss && options.cssOutputPath) {
|
|
591
605
|
const cssChunks = outputFiles
|
|
592
606
|
.filter((file) => file.path.endsWith(".css"))
|
|
593
|
-
.map((file) => file.text)
|
|
607
|
+
.map((file) => file.text ?? Buffer.from(file.contents ?? new Uint8Array()).toString("utf-8"))
|
|
594
608
|
.filter((text) => typeof text === "string" && text.length > 0);
|
|
595
609
|
if (cssChunks.length > 0) {
|
|
596
610
|
await writeFileSafe(options.cssOutputPath, cssChunks.join("\n"));
|
|
597
611
|
}
|
|
598
612
|
}
|
|
613
|
+
const assetFiles = outputFiles.filter((file) => file !== jsOutput &&
|
|
614
|
+
!file.path.endsWith(".js") &&
|
|
615
|
+
!file.path.endsWith(".mjs") &&
|
|
616
|
+
!file.path.endsWith(".css"));
|
|
617
|
+
for (const asset of assetFiles) {
|
|
618
|
+
const relPath = relative(tempOutDir, asset.path);
|
|
619
|
+
const targetPath = join(assetOutputDir, relPath);
|
|
620
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
621
|
+
await writeFile(targetPath, asset.contents);
|
|
622
|
+
}
|
|
623
|
+
await rm(tempOutDir, { recursive: true, force: true }).catch(() => { });
|
|
599
624
|
}
|
|
600
625
|
catch (error) {
|
|
626
|
+
await rm(tempOutDir, { recursive: true, force: true }).catch(() => { });
|
|
601
627
|
const messages = typeof error === "object" && error !== null && "errors" in error
|
|
602
628
|
? error.errors
|
|
603
629
|
?.map((entry) => entry.text)
|
|
@@ -728,6 +754,7 @@ export const build = async (options) => {
|
|
|
728
754
|
const legacyBootstrapChunk = renderLegacyClientBootstrap();
|
|
729
755
|
const legacyEnabled = config.legacy.enabled;
|
|
730
756
|
const modernTarget = config.target;
|
|
757
|
+
const modernBundler = config.bundler === "esbuild" ? "esbuild" : "bun";
|
|
731
758
|
const isEs5Target = modernTarget === "es5";
|
|
732
759
|
const clientScriptType = isEs5Target ? "classic" : "module";
|
|
733
760
|
const serverTarget = "es2018";
|
|
@@ -1603,7 +1630,7 @@ export const build = async (options) => {
|
|
|
1603
1630
|
target: input.target,
|
|
1604
1631
|
format: input.format,
|
|
1605
1632
|
syntaxTarget: input.syntaxTarget,
|
|
1606
|
-
bundler: input.syntaxTarget === "es5" ? "esbuild" :
|
|
1633
|
+
bundler: input.syntaxTarget === "es5" ? "esbuild" : modernBundler,
|
|
1607
1634
|
bundleType: input.bundleType,
|
|
1608
1635
|
bundlerPlugins: plugins,
|
|
1609
1636
|
addBundlerPlugin: (plugin) => {
|
|
@@ -1699,6 +1726,8 @@ export const build = async (options) => {
|
|
|
1699
1726
|
format: clientScriptType === "classic" ? "iife" : "esm",
|
|
1700
1727
|
shimHyperCore: true,
|
|
1701
1728
|
syntaxTarget: isEs5Target ? "es5" : "modern",
|
|
1729
|
+
bundler: isEs5Target ? "esbuild" : modernBundler,
|
|
1730
|
+
esbuildTarget: isEs5Target ? undefined : modernTarget,
|
|
1702
1731
|
plugins: bundlerPlugins,
|
|
1703
1732
|
emitCss: Boolean(cssOutputPath),
|
|
1704
1733
|
cssOutputPath,
|
|
@@ -1726,6 +1755,8 @@ export const build = async (options) => {
|
|
|
1726
1755
|
format: clientScriptType === "classic" ? "iife" : "esm",
|
|
1727
1756
|
shimHyperCore: true,
|
|
1728
1757
|
syntaxTarget: isEs5Target ? "es5" : "modern",
|
|
1758
|
+
bundler: isEs5Target ? "esbuild" : modernBundler,
|
|
1759
|
+
esbuildTarget: isEs5Target ? undefined : modernTarget,
|
|
1729
1760
|
plugins: bundlerPlugins,
|
|
1730
1761
|
emitCss: Boolean(cssOutputPath),
|
|
1731
1762
|
cssOutputPath,
|
|
@@ -1754,6 +1785,8 @@ export const build = async (options) => {
|
|
|
1754
1785
|
format: clientScriptType === "classic" ? "iife" : "esm",
|
|
1755
1786
|
shimHyperCore: true,
|
|
1756
1787
|
syntaxTarget: isEs5Target ? "es5" : "modern",
|
|
1788
|
+
bundler: isEs5Target ? "esbuild" : modernBundler,
|
|
1789
|
+
esbuildTarget: isEs5Target ? undefined : modernTarget,
|
|
1757
1790
|
plugins: bundlerPlugins,
|
|
1758
1791
|
emitCss: Boolean(cssOutputPath),
|
|
1759
1792
|
cssOutputPath,
|
|
@@ -1784,6 +1817,8 @@ export const build = async (options) => {
|
|
|
1784
1817
|
format: "cjs",
|
|
1785
1818
|
shimHyperCore: false,
|
|
1786
1819
|
syntaxTarget: isEs5Target ? "es5" : "modern",
|
|
1820
|
+
bundler: isEs5Target ? "esbuild" : modernBundler,
|
|
1821
|
+
esbuildTarget: isEs5Target ? undefined : serverTarget,
|
|
1787
1822
|
plugins: bundlerPlugins,
|
|
1788
1823
|
});
|
|
1789
1824
|
}
|
|
@@ -1805,6 +1840,8 @@ export const build = async (options) => {
|
|
|
1805
1840
|
format: "cjs",
|
|
1806
1841
|
shimHyperCore: false,
|
|
1807
1842
|
syntaxTarget: isEs5Target ? "es5" : "modern",
|
|
1843
|
+
bundler: isEs5Target ? "esbuild" : modernBundler,
|
|
1844
|
+
esbuildTarget: isEs5Target ? undefined : serverTarget,
|
|
1808
1845
|
plugins: bundlerPlugins,
|
|
1809
1846
|
});
|
|
1810
1847
|
}
|
|
@@ -1827,6 +1864,8 @@ export const build = async (options) => {
|
|
|
1827
1864
|
format: "cjs",
|
|
1828
1865
|
shimHyperCore: false,
|
|
1829
1866
|
syntaxTarget: isEs5Target ? "es5" : "modern",
|
|
1867
|
+
bundler: isEs5Target ? "esbuild" : modernBundler,
|
|
1868
|
+
esbuildTarget: isEs5Target ? undefined : serverTarget,
|
|
1830
1869
|
plugins: bundlerPlugins,
|
|
1831
1870
|
});
|
|
1832
1871
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tyndall/build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@swc/core": "^1.15.17",
|
|
25
|
-
"@tyndall/core": "^0.0.
|
|
26
|
-
"@tyndall/shared": "^0.0.
|
|
25
|
+
"@tyndall/core": "^0.0.8",
|
|
26
|
+
"@tyndall/shared": "^0.0.8",
|
|
27
27
|
"esbuild": "0.21.5"
|
|
28
28
|
}
|
|
29
29
|
}
|