@tyndall/build 0.0.7 → 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 +26 -3
- 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
|
@@ -554,7 +554,9 @@ const buildChunkFile = async (entryPath, outputPath, options) => {
|
|
|
554
554
|
: null;
|
|
555
555
|
const selectedBundler = options.syntaxTarget === "es5" ? "esbuild" : options.bundler ?? "bun";
|
|
556
556
|
if (selectedBundler === "esbuild") {
|
|
557
|
+
const tempOutDir = join(dirname(outputPath), `.@tyndall/esbuild-tmp-${hash(`${outputPath}-${Date.now()}`)}`);
|
|
557
558
|
try {
|
|
559
|
+
await mkdir(tempOutDir, { recursive: true });
|
|
558
560
|
const plugins = shimPlugin ? [shimPlugin, ...bundlerPlugins] : [...bundlerPlugins];
|
|
559
561
|
const bundled = await esbuild({
|
|
560
562
|
entryPoints: [entryPath],
|
|
@@ -568,14 +570,22 @@ const buildChunkFile = async (entryPath, outputPath, options) => {
|
|
|
568
570
|
logLevel: "silent",
|
|
569
571
|
jsx: "automatic",
|
|
570
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
|
+
},
|
|
571
580
|
write: false,
|
|
572
581
|
});
|
|
573
582
|
const outputFiles = bundled.outputFiles ?? [];
|
|
574
583
|
const jsOutput = outputFiles.find((file) => file.path.endsWith(".js") || file.path.endsWith(".mjs")) ??
|
|
575
584
|
outputFiles[0];
|
|
576
|
-
const outputText = jsOutput?.text
|
|
585
|
+
const outputText = jsOutput?.text ??
|
|
586
|
+
(jsOutput?.contents ? Buffer.from(jsOutput.contents).toString("utf-8") : undefined);
|
|
577
587
|
if (!outputText) {
|
|
578
|
-
throw new Error("
|
|
588
|
+
throw new Error("esbuild bundling produced no output.");
|
|
579
589
|
}
|
|
580
590
|
const transformed = options.syntaxTarget === "es5"
|
|
581
591
|
? await transform(outputText, {
|
|
@@ -590,17 +600,30 @@ const buildChunkFile = async (entryPath, outputPath, options) => {
|
|
|
590
600
|
: { code: outputText };
|
|
591
601
|
await mkdir(dirname(outputPath), { recursive: true });
|
|
592
602
|
await writeFile(outputPath, transformed.code, "utf-8");
|
|
603
|
+
const assetOutputDir = shouldEmitCss && options.cssOutputPath ? dirname(options.cssOutputPath) : dirname(outputPath);
|
|
593
604
|
if (shouldEmitCss && options.cssOutputPath) {
|
|
594
605
|
const cssChunks = outputFiles
|
|
595
606
|
.filter((file) => file.path.endsWith(".css"))
|
|
596
|
-
.map((file) => file.text)
|
|
607
|
+
.map((file) => file.text ?? Buffer.from(file.contents ?? new Uint8Array()).toString("utf-8"))
|
|
597
608
|
.filter((text) => typeof text === "string" && text.length > 0);
|
|
598
609
|
if (cssChunks.length > 0) {
|
|
599
610
|
await writeFileSafe(options.cssOutputPath, cssChunks.join("\n"));
|
|
600
611
|
}
|
|
601
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(() => { });
|
|
602
624
|
}
|
|
603
625
|
catch (error) {
|
|
626
|
+
await rm(tempOutDir, { recursive: true, force: true }).catch(() => { });
|
|
604
627
|
const messages = typeof error === "object" && error !== null && "errors" in error
|
|
605
628
|
? error.errors
|
|
606
629
|
?.map((entry) => entry.text)
|
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
|
}
|