sandlot 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/bundler.d.ts +8 -0
- package/dist/browser/bundler.d.ts.map +1 -1
- package/dist/browser/iframe-executor.d.ts +82 -0
- package/dist/browser/iframe-executor.d.ts.map +1 -0
- package/dist/browser/index.d.ts +4 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +249 -55
- package/dist/browser/main-thread-executor.d.ts +46 -0
- package/dist/browser/main-thread-executor.d.ts.map +1 -0
- package/dist/browser/preset.d.ts +7 -2
- package/dist/browser/preset.d.ts.map +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/types.d.ts +9 -1
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/core/executor.d.ts.map +1 -1
- package/dist/core/sandbox.d.ts.map +1 -1
- package/dist/core/sandlot.d.ts.map +1 -1
- package/dist/core/typechecker.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -46
- package/dist/node/bundler.d.ts +5 -0
- package/dist/node/bundler.d.ts.map +1 -1
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +218 -54
- package/dist/node/preset.d.ts +16 -1
- package/dist/node/preset.d.ts.map +1 -1
- package/dist/node/wasm-bundler.d.ts +86 -0
- package/dist/node/wasm-bundler.d.ts.map +1 -0
- package/dist/types.d.ts +35 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/browser/bundler.ts +17 -0
- package/src/browser/iframe-executor.ts +320 -0
- package/src/browser/index.ts +9 -2
- package/src/browser/preset.ts +30 -6
- package/src/commands/index.ts +18 -40
- package/src/commands/types.ts +36 -0
- package/src/core/executor.ts +8 -7
- package/src/core/sandbox.ts +3 -0
- package/src/core/sandlot.ts +7 -0
- package/src/core/typechecker.ts +4 -2
- package/src/index.ts +2 -0
- package/src/node/bundler.ts +11 -0
- package/src/node/index.ts +10 -0
- package/src/node/preset.ts +59 -5
- package/src/node/wasm-bundler.ts +299 -0
- package/src/types.ts +38 -7
- /package/src/browser/{executor.ts → main-thread-executor.ts} +0 -0
package/dist/commands/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Commands wrap the sandbox's direct methods to provide a shell interface.
|
|
5
5
|
* This ensures consistency between `sandbox.build()` and `sandbox.exec('sandlot build')`.
|
|
6
6
|
*/
|
|
7
|
-
import type { Filesystem, InstallResult, UninstallResult, BuildResult, TypecheckResult, SandboxBuildOptions, SandboxTypecheckOptions, RunOptions, RunResult, BundleError, Diagnostic } from "../types";
|
|
7
|
+
import type { Filesystem, InstallResult, UninstallResult, BuildResult, BuildFailureDetails, TypecheckResult, SandboxBuildOptions, SandboxTypecheckOptions, RunOptions, RunResult, BundleError, Diagnostic } from "../types";
|
|
8
8
|
/**
|
|
9
9
|
* Reference to sandbox methods that commands can call.
|
|
10
10
|
*
|
|
@@ -37,4 +37,12 @@ export declare function formatDiagnostics(diagnostics: Diagnostic[]): string;
|
|
|
37
37
|
* Format bundle errors for shell output
|
|
38
38
|
*/
|
|
39
39
|
export declare function formatBundleErrors(errors: BundleError[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Format a build failure for shell output.
|
|
42
|
+
* Used by both build and run commands for consistent error formatting.
|
|
43
|
+
*
|
|
44
|
+
* @param failure - The build failure details
|
|
45
|
+
* @param prefix - Optional prefix for the error message (default: "Build failed")
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatBuildFailure(failure: BuildFailureDetails, prefix?: string): string;
|
|
40
48
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/commands/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAA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;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,YAAY,EACxB,OAAO,GAAE,oBAAyB,GACjC,SAAS,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/core/executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAiC,MAAM,UAAU,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,YAAY,EACxB,OAAO,GAAE,oBAAyB,GACjC,SAAS,CAyHX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/core/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,SAAS,EACT,OAAO,EACP,cAAc,EAYf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAA6B,MAAM,MAAM,CAAC;AA2J7D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,QAAQ,CAAC;IAClB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAMD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/core/sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,SAAS,EACT,OAAO,EACP,cAAc,EAYf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAA6B,MAAM,MAAM,CAAC;AA2J7D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,QAAQ,CAAC;IAClB,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAMD;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,CAAC,CA2ZlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandlot.d.ts","sourceRoot":"","sources":["../../src/core/sandlot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EAIf,MAAM,UAAU,CAAC;AAKlB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"sandlot.d.ts","sourceRoot":"","sources":["../../src/core/sandlot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EAIf,MAAM,UAAU,CAAC;AAKlB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CA6C9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typechecker.d.ts","sourceRoot":"","sources":["../../src/core/typechecker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAEhB,MAAM,UAAU,CAAC;AAsBlB,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"typechecker.d.ts","sourceRoot":"","sources":["../../src/core/typechecker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAEhB,MAAM,UAAU,CAAC;AAsBlB,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAwbD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAY,YAAW,YAAY;IAC9C,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAA8B;gBAErC,OAAO,GAAE,kBAAuB;IAI5C;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAcnB,SAAS;IAWvB;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;CA8CrE;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,YAAY,CAEd"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ export { createSandlot } from "./core/sandlot";
|
|
|
2
2
|
export { Filesystem, createFilesystem, wrapFilesystemForJustBash, } from "./core/fs";
|
|
3
3
|
export type { FilesystemOptions } from "./core/fs";
|
|
4
4
|
export { SharedModuleRegistry, createSharedModuleRegistry, } from "./core/shared-module-registry";
|
|
5
|
-
export { createSandlotCommand, createDefaultCommands, formatSize, formatDiagnostics, formatBundleErrors, } from "./commands";
|
|
5
|
+
export { createSandlotCommand, createDefaultCommands, formatSize, formatDiagnostics, formatBundleErrors, formatBuildFailure, } from "./commands";
|
|
6
6
|
export type { SandboxRef } from "./commands";
|
|
7
7
|
export { Typechecker, createTypechecker } from "./core/typechecker";
|
|
8
8
|
export type { TypecheckerOptions } from "./core/typechecker";
|
|
9
9
|
export { EsmTypesResolver, InMemoryTypesCache, } from "./core/esm-types-resolver";
|
|
10
10
|
export type { EsmTypesResolverOptions, ResolvedTypes, ITypesCache, } from "./core/esm-types-resolver";
|
|
11
|
-
export type { IBundler, ITypechecker, ITypesResolver, ISharedModuleRegistry, IExecutor, Sandlot, SandlotOptions, Sandbox, SandboxOptions, SandboxState, BuildPhase, BuildResult, BuildSuccess, BuildFailure, SandboxBuildOptions, InstallResult, UninstallResult, SandboxTypecheckOptions, RunOptions, RunResult, ExecuteOptions, ExecuteResult, BundleOptions, BundleResult, BundleSuccess, BundleFailure, BundleWarning, BundleError, BundleLocation, TypecheckOptions, TypecheckResult, Diagnostic, ExecResult, IFileSystem, FsEntry, FsStat, } from "./types";
|
|
11
|
+
export type { IBundler, ITypechecker, ITypesResolver, ISharedModuleRegistry, IExecutor, Sandlot, SandlotOptions, Sandbox, SandboxOptions, SandboxState, BuildPhase, BuildResult, BuildSuccess, BuildFailure, BuildFailureDetails, SandboxBuildOptions, InstallResult, UninstallResult, SandboxTypecheckOptions, RunOptions, RunResult, ExecuteOptions, ExecuteResult, BundleOptions, BundleResult, BundleSuccess, BundleFailure, BundleWarning, BundleError, BundleLocation, TypecheckOptions, TypecheckResult, Diagnostic, ExecResult, IFileSystem, FsEntry, FsStat, } from "./types";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAMnD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAM7D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,uBAAuB,EACvB,aAAa,EACb,WAAW,GACZ,MAAM,2BAA2B,CAAC;AAMnC,YAAY,EAEV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,SAAS,EAGT,OAAO,EACP,cAAc,EACd,OAAO,EACP,cAAc,EACd,YAAY,EAGZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,mBAAmB,EAGnB,aAAa,EACb,eAAe,EAGf,uBAAuB,EAGvB,UAAU,EACV,SAAS,EAGT,cAAc,EACd,aAAa,EAGb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,EACX,cAAc,EAGd,gBAAgB,EAChB,eAAe,EACf,UAA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V,UAAU,EAGV,WAAW,EACX,OAAO,EACP,MAAM,GACP,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -707,6 +707,37 @@ ${padding}^`;
|
|
|
707
707
|
|
|
708
708
|
`);
|
|
709
709
|
}
|
|
710
|
+
function formatBuildFailure(failure, prefix = "Build failed") {
|
|
711
|
+
switch (failure.phase) {
|
|
712
|
+
case "entry":
|
|
713
|
+
return `${prefix}: ${failure.message}
|
|
714
|
+
`;
|
|
715
|
+
case "typecheck":
|
|
716
|
+
if (failure.diagnostics && failure.diagnostics.length > 0) {
|
|
717
|
+
const errors = failure.diagnostics.filter((d) => d.severity === "error");
|
|
718
|
+
if (errors.length > 0) {
|
|
719
|
+
return `${prefix}: Type check errors
|
|
720
|
+
|
|
721
|
+
${formatDiagnostics(errors)}
|
|
722
|
+
`;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return `${prefix}: Type check errors
|
|
726
|
+
`;
|
|
727
|
+
case "bundle":
|
|
728
|
+
if (failure.bundleErrors && failure.bundleErrors.length > 0) {
|
|
729
|
+
return `${prefix}: Bundle errors
|
|
730
|
+
|
|
731
|
+
${formatBundleErrors(failure.bundleErrors)}
|
|
732
|
+
`;
|
|
733
|
+
}
|
|
734
|
+
return `${prefix}: Bundle error
|
|
735
|
+
`;
|
|
736
|
+
default:
|
|
737
|
+
return `${prefix}: Unknown error
|
|
738
|
+
`;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
710
741
|
// src/commands/index.ts
|
|
711
742
|
function createSandlotCommand(sandboxRef) {
|
|
712
743
|
return defineCommand("sandlot", async (args, ctx) => {
|
|
@@ -817,42 +848,9 @@ Examples:
|
|
|
817
848
|
format
|
|
818
849
|
});
|
|
819
850
|
if (!result.success) {
|
|
820
|
-
let stderr = `Build failed`;
|
|
821
|
-
switch (result.phase) {
|
|
822
|
-
case "entry":
|
|
823
|
-
stderr = `Build failed: ${result.message}
|
|
824
|
-
`;
|
|
825
|
-
break;
|
|
826
|
-
case "typecheck":
|
|
827
|
-
if (result.diagnostics) {
|
|
828
|
-
const errors = result.diagnostics.filter((d) => d.severity === "error");
|
|
829
|
-
stderr = `Build failed: Type check errors
|
|
830
|
-
|
|
831
|
-
${formatDiagnostics(errors)}
|
|
832
|
-
`;
|
|
833
|
-
} else {
|
|
834
|
-
stderr = `Build failed: Type check errors
|
|
835
|
-
`;
|
|
836
|
-
}
|
|
837
|
-
break;
|
|
838
|
-
case "bundle":
|
|
839
|
-
if (result.bundleErrors && result.bundleErrors.length > 0) {
|
|
840
|
-
stderr = `Build failed: Bundle errors
|
|
841
|
-
|
|
842
|
-
${formatBundleErrors(result.bundleErrors)}
|
|
843
|
-
`;
|
|
844
|
-
} else {
|
|
845
|
-
stderr = `Build failed: Bundle error
|
|
846
|
-
`;
|
|
847
|
-
}
|
|
848
|
-
break;
|
|
849
|
-
default:
|
|
850
|
-
stderr = `Build failed: Unknown error
|
|
851
|
-
`;
|
|
852
|
-
}
|
|
853
851
|
return {
|
|
854
852
|
stdout: "",
|
|
855
|
-
stderr,
|
|
853
|
+
stderr: formatBuildFailure(result),
|
|
856
854
|
exitCode: 1
|
|
857
855
|
};
|
|
858
856
|
}
|
|
@@ -916,18 +914,20 @@ Examples:
|
|
|
916
914
|
const formatted = formatDiagnostics(errors);
|
|
917
915
|
return {
|
|
918
916
|
stdout: "",
|
|
919
|
-
stderr: `Type check failed
|
|
917
|
+
stderr: `Type check failed
|
|
918
|
+
|
|
920
919
|
${formatted}
|
|
921
920
|
`,
|
|
922
921
|
exitCode: 1
|
|
923
922
|
};
|
|
924
923
|
}
|
|
925
924
|
const warnings = result.diagnostics.filter((d) => d.severity === "warning");
|
|
926
|
-
let output = `Type check passed
|
|
925
|
+
let output = `Type check passed
|
|
927
926
|
`;
|
|
928
927
|
if (warnings.length > 0) {
|
|
929
928
|
output += `
|
|
930
929
|
Warnings:
|
|
930
|
+
|
|
931
931
|
${formatDiagnostics(warnings)}
|
|
932
932
|
`;
|
|
933
933
|
}
|
|
@@ -1102,13 +1102,7 @@ Examples:
|
|
|
1102
1102
|
if (!result.success) {
|
|
1103
1103
|
let stderr = "";
|
|
1104
1104
|
if (result.buildFailure) {
|
|
1105
|
-
stderr =
|
|
1106
|
-
if (result.buildFailure.message) {
|
|
1107
|
-
stderr += `
|
|
1108
|
-
${result.buildFailure.message}`;
|
|
1109
|
-
}
|
|
1110
|
-
stderr += `
|
|
1111
|
-
`;
|
|
1105
|
+
stderr = formatBuildFailure(result.buildFailure, "Run failed");
|
|
1112
1106
|
} else {
|
|
1113
1107
|
stderr = `Run failed: ${result.error ?? "Unknown error"}
|
|
1114
1108
|
`;
|
|
@@ -1455,7 +1449,10 @@ async function createSandboxImpl(fs, options, context) {
|
|
|
1455
1449
|
error: buildResult.message ?? `Build failed in ${buildResult.phase} phase`,
|
|
1456
1450
|
buildFailure: {
|
|
1457
1451
|
phase: buildResult.phase,
|
|
1458
|
-
message: buildResult.message
|
|
1452
|
+
message: buildResult.message,
|
|
1453
|
+
diagnostics: buildResult.diagnostics,
|
|
1454
|
+
bundleErrors: buildResult.bundleErrors,
|
|
1455
|
+
bundleWarnings: buildResult.bundleWarnings
|
|
1459
1456
|
}
|
|
1460
1457
|
};
|
|
1461
1458
|
}
|
|
@@ -1553,6 +1550,11 @@ function createSandlot(options) {
|
|
|
1553
1550
|
},
|
|
1554
1551
|
get sharedModules() {
|
|
1555
1552
|
return sharedModuleRegistry;
|
|
1553
|
+
},
|
|
1554
|
+
async dispose() {
|
|
1555
|
+
if (bundler.dispose) {
|
|
1556
|
+
await bundler.dispose();
|
|
1557
|
+
}
|
|
1556
1558
|
}
|
|
1557
1559
|
};
|
|
1558
1560
|
}
|
|
@@ -1782,8 +1784,9 @@ function parseTsConfig(fs, configPath) {
|
|
|
1782
1784
|
}
|
|
1783
1785
|
};
|
|
1784
1786
|
const parsed = ts.parseJsonConfigFileContent(config, parseHost, "/", undefined, configPath);
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
+
const relevantErrors = parsed.errors.filter((e) => e.code !== 18003);
|
|
1788
|
+
if (relevantErrors.length > 0) {
|
|
1789
|
+
console.warn("[typechecker] tsconfig parse errors:", relevantErrors.map((e) => e.messageText));
|
|
1787
1790
|
}
|
|
1788
1791
|
return {
|
|
1789
1792
|
...parsed.options,
|
|
@@ -2075,6 +2078,7 @@ export {
|
|
|
2075
2078
|
formatSize,
|
|
2076
2079
|
formatDiagnostics,
|
|
2077
2080
|
formatBundleErrors,
|
|
2081
|
+
formatBuildFailure,
|
|
2078
2082
|
createTypechecker,
|
|
2079
2083
|
createSharedModuleRegistry,
|
|
2080
2084
|
createSandlotCommand,
|
package/dist/node/bundler.d.ts
CHANGED
|
@@ -39,6 +39,11 @@ export declare class EsbuildNativeBundler implements IBundler {
|
|
|
39
39
|
*/
|
|
40
40
|
initialize(): Promise<void>;
|
|
41
41
|
private getEsbuild;
|
|
42
|
+
/**
|
|
43
|
+
* Dispose of the esbuild service.
|
|
44
|
+
* This stops the esbuild child process and allows the Node.js process to exit.
|
|
45
|
+
*/
|
|
46
|
+
dispose(): Promise<void>;
|
|
42
47
|
bundle(options: BundleOptions): Promise<BundleResult>;
|
|
43
48
|
}
|
|
44
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/node/bundler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EAGb,MAAM,UAAU,CAAC;AAOlB,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,oBAAqB,YAAW,QAAQ;IACnD,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,OAAO,CAAoC;gBAEvC,OAAO,GAAE,2BAAgC;IAOrD;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC,OAAO,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/node/bundler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,YAAY,EAGb,MAAM,UAAU,CAAC;AAOlB,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,oBAAqB,YAAW,QAAQ;IACnD,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,OAAO,CAAoC;gBAEvC,OAAO,GAAE,2BAAgC;IAOrD;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC,OAAO,CAAC,UAAU;IAOlB;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAOxB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA0G5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,2BAA2B,GACpC,oBAAoB,CAEtB"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { EsbuildNativeBundler, createEsbuildNativeBundler } from "./bundler";
|
|
2
2
|
export type { EsbuildNativeBundlerOptions } from "./bundler";
|
|
3
|
+
export { EsbuildWasmNodeBundler, createEsbuildWasmNodeBundler, } from "./wasm-bundler";
|
|
4
|
+
export type { EsbuildWasmNodeBundlerOptions } from "./wasm-bundler";
|
|
3
5
|
export { Typechecker, createTypechecker } from "../core/typechecker";
|
|
4
6
|
export type { TypecheckerOptions } from "../core/typechecker";
|
|
5
7
|
export { NodeExecutor, createNodeExecutor } from "./executor";
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAC7E,YAAY,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAM9D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC9D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAMtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAC7E,YAAY,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAM7D,OAAO,EACL,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAMpE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAM9D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC9D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAMtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/node/index.js
CHANGED
|
@@ -342,6 +342,12 @@ class EsbuildNativeBundler {
|
|
|
342
342
|
}
|
|
343
343
|
return this.esbuild;
|
|
344
344
|
}
|
|
345
|
+
async dispose() {
|
|
346
|
+
if (this.esbuild) {
|
|
347
|
+
await this.esbuild.stop();
|
|
348
|
+
this.esbuild = null;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
345
351
|
async bundle(options) {
|
|
346
352
|
await this.initialize();
|
|
347
353
|
const esbuild = this.getEsbuild();
|
|
@@ -419,6 +425,142 @@ class EsbuildNativeBundler {
|
|
|
419
425
|
function createEsbuildNativeBundler(options) {
|
|
420
426
|
return new EsbuildNativeBundler(options);
|
|
421
427
|
}
|
|
428
|
+
// src/node/wasm-bundler.ts
|
|
429
|
+
var GLOBAL_KEY = "__sandlot_esbuild_wasm_node__";
|
|
430
|
+
function getGlobalState() {
|
|
431
|
+
const g = globalThis;
|
|
432
|
+
if (!g[GLOBAL_KEY]) {
|
|
433
|
+
g[GLOBAL_KEY] = {
|
|
434
|
+
esbuild: null,
|
|
435
|
+
initialized: false,
|
|
436
|
+
initPromise: null
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
return g[GLOBAL_KEY];
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
class EsbuildWasmNodeBundler {
|
|
443
|
+
options;
|
|
444
|
+
constructor(options = {}) {
|
|
445
|
+
this.options = {
|
|
446
|
+
cdnBaseUrl: "https://esm.sh",
|
|
447
|
+
...options
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
async initialize() {
|
|
451
|
+
const state = getGlobalState();
|
|
452
|
+
if (state.initialized && state.esbuild) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
if (state.initPromise) {
|
|
456
|
+
await state.initPromise;
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
state.initPromise = this.doInitialize(state);
|
|
460
|
+
await state.initPromise;
|
|
461
|
+
}
|
|
462
|
+
async doInitialize(state) {
|
|
463
|
+
const esbuild = await import("esbuild-wasm");
|
|
464
|
+
if (typeof esbuild?.initialize !== "function") {
|
|
465
|
+
throw new Error("Failed to load esbuild-wasm: initialize function not found");
|
|
466
|
+
}
|
|
467
|
+
await esbuild.initialize({});
|
|
468
|
+
state.esbuild = esbuild;
|
|
469
|
+
state.initialized = true;
|
|
470
|
+
}
|
|
471
|
+
getEsbuild() {
|
|
472
|
+
const state = getGlobalState();
|
|
473
|
+
if (!state.esbuild) {
|
|
474
|
+
throw new Error("esbuild not initialized - call initialize() first");
|
|
475
|
+
}
|
|
476
|
+
return state.esbuild;
|
|
477
|
+
}
|
|
478
|
+
async dispose() {
|
|
479
|
+
const state = getGlobalState();
|
|
480
|
+
if (state.esbuild) {
|
|
481
|
+
await state.esbuild.stop();
|
|
482
|
+
state.esbuild = null;
|
|
483
|
+
state.initialized = false;
|
|
484
|
+
state.initPromise = null;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async bundle(options) {
|
|
488
|
+
await this.initialize();
|
|
489
|
+
const esbuild = this.getEsbuild();
|
|
490
|
+
const {
|
|
491
|
+
fs,
|
|
492
|
+
entryPoint,
|
|
493
|
+
installedPackages = {},
|
|
494
|
+
sharedModules = [],
|
|
495
|
+
sharedModuleRegistry,
|
|
496
|
+
external = [],
|
|
497
|
+
format = "esm",
|
|
498
|
+
minify = false,
|
|
499
|
+
sourcemap = false,
|
|
500
|
+
target = ["es2020"]
|
|
501
|
+
} = options;
|
|
502
|
+
const normalizedEntry = entryPoint.startsWith("/") ? entryPoint : `/${entryPoint}`;
|
|
503
|
+
if (!fs.exists(normalizedEntry)) {
|
|
504
|
+
return {
|
|
505
|
+
success: false,
|
|
506
|
+
errors: [{ text: `Entry point not found: ${normalizedEntry}` }],
|
|
507
|
+
warnings: []
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
const includedFiles = new Set;
|
|
511
|
+
const plugin = createVfsPlugin({
|
|
512
|
+
fs,
|
|
513
|
+
entryPoint: normalizedEntry,
|
|
514
|
+
installedPackages,
|
|
515
|
+
sharedModules: new Set(sharedModules),
|
|
516
|
+
sharedModuleRegistry: sharedModuleRegistry ?? null,
|
|
517
|
+
cdnBaseUrl: this.options.cdnBaseUrl,
|
|
518
|
+
includedFiles,
|
|
519
|
+
bundleCdnImports: true
|
|
520
|
+
});
|
|
521
|
+
try {
|
|
522
|
+
const result = await esbuild.build({
|
|
523
|
+
entryPoints: [normalizedEntry],
|
|
524
|
+
bundle: true,
|
|
525
|
+
write: false,
|
|
526
|
+
format,
|
|
527
|
+
minify,
|
|
528
|
+
sourcemap: sourcemap ? "inline" : false,
|
|
529
|
+
target,
|
|
530
|
+
external,
|
|
531
|
+
plugins: [plugin],
|
|
532
|
+
jsx: "automatic"
|
|
533
|
+
});
|
|
534
|
+
const code = result.outputFiles?.[0]?.text ?? "";
|
|
535
|
+
const warnings = result.warnings.map((w) => convertEsbuildMessage(w));
|
|
536
|
+
return {
|
|
537
|
+
success: true,
|
|
538
|
+
code,
|
|
539
|
+
warnings,
|
|
540
|
+
includedFiles: Array.from(includedFiles)
|
|
541
|
+
};
|
|
542
|
+
} catch (err) {
|
|
543
|
+
if (isEsbuildBuildFailure(err)) {
|
|
544
|
+
const errors = err.errors.map((e) => convertEsbuildMessage(e));
|
|
545
|
+
const warnings = err.warnings.map((w) => convertEsbuildMessage(w));
|
|
546
|
+
return {
|
|
547
|
+
success: false,
|
|
548
|
+
errors,
|
|
549
|
+
warnings
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
553
|
+
return {
|
|
554
|
+
success: false,
|
|
555
|
+
errors: [{ text: message }],
|
|
556
|
+
warnings: []
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function createEsbuildWasmNodeBundler(options) {
|
|
562
|
+
return new EsbuildWasmNodeBundler(options);
|
|
563
|
+
}
|
|
422
564
|
// src/core/typechecker.ts
|
|
423
565
|
import ts from "typescript";
|
|
424
566
|
var TS_VERSION = "5.9.3";
|
|
@@ -645,8 +787,9 @@ function parseTsConfig(fs, configPath) {
|
|
|
645
787
|
}
|
|
646
788
|
};
|
|
647
789
|
const parsed = ts.parseJsonConfigFileContent(config, parseHost, "/", undefined, configPath);
|
|
648
|
-
|
|
649
|
-
|
|
790
|
+
const relevantErrors = parsed.errors.filter((e) => e.code !== 18003);
|
|
791
|
+
if (relevantErrors.length > 0) {
|
|
792
|
+
console.warn("[typechecker] tsconfig parse errors:", relevantErrors.map((e) => e.messageText));
|
|
650
793
|
}
|
|
651
794
|
return {
|
|
652
795
|
...parsed.options,
|
|
@@ -770,23 +913,18 @@ function createBasicExecutor(loadModule, options = {}) {
|
|
|
770
913
|
const formatArgs = (...args) => args.map((v) => typeof v === "object" ? JSON.stringify(v) : String(v)).join(" ");
|
|
771
914
|
const captureLog = (...args) => {
|
|
772
915
|
logs.push(formatArgs(...args));
|
|
773
|
-
originalConsole.log.apply(console, args);
|
|
774
916
|
};
|
|
775
917
|
const captureWarn = (...args) => {
|
|
776
918
|
logs.push(`[warn] ${formatArgs(...args)}`);
|
|
777
|
-
originalConsole.warn.apply(console, args);
|
|
778
919
|
};
|
|
779
920
|
const captureError = (...args) => {
|
|
780
921
|
logs.push(`[error] ${formatArgs(...args)}`);
|
|
781
|
-
originalConsole.error.apply(console, args);
|
|
782
922
|
};
|
|
783
923
|
const captureInfo = (...args) => {
|
|
784
924
|
logs.push(`[info] ${formatArgs(...args)}`);
|
|
785
|
-
originalConsole.info.apply(console, args);
|
|
786
925
|
};
|
|
787
926
|
const captureDebug = (...args) => {
|
|
788
927
|
logs.push(`[debug] ${formatArgs(...args)}`);
|
|
789
|
-
originalConsole.debug.apply(console, args);
|
|
790
928
|
};
|
|
791
929
|
const restoreConsole = () => {
|
|
792
930
|
console.log = originalConsole.log;
|
|
@@ -813,10 +951,16 @@ function createBasicExecutor(loadModule, options = {}) {
|
|
|
813
951
|
}
|
|
814
952
|
};
|
|
815
953
|
if (timeout > 0) {
|
|
954
|
+
let timeoutId;
|
|
816
955
|
const timeoutPromise = new Promise((_, reject) => {
|
|
817
|
-
setTimeout(() => reject(new Error(`Execution timed out after ${timeout}ms`)), timeout);
|
|
956
|
+
timeoutId = setTimeout(() => reject(new Error(`Execution timed out after ${timeout}ms`)), timeout);
|
|
818
957
|
});
|
|
819
|
-
|
|
958
|
+
try {
|
|
959
|
+
await Promise.race([executeExport(), timeoutPromise]);
|
|
960
|
+
} finally {
|
|
961
|
+
if (timeoutId)
|
|
962
|
+
clearTimeout(timeoutId);
|
|
963
|
+
}
|
|
820
964
|
} else {
|
|
821
965
|
await executeExport();
|
|
822
966
|
}
|
|
@@ -1571,6 +1715,37 @@ ${padding}^`;
|
|
|
1571
1715
|
|
|
1572
1716
|
`);
|
|
1573
1717
|
}
|
|
1718
|
+
function formatBuildFailure(failure, prefix = "Build failed") {
|
|
1719
|
+
switch (failure.phase) {
|
|
1720
|
+
case "entry":
|
|
1721
|
+
return `${prefix}: ${failure.message}
|
|
1722
|
+
`;
|
|
1723
|
+
case "typecheck":
|
|
1724
|
+
if (failure.diagnostics && failure.diagnostics.length > 0) {
|
|
1725
|
+
const errors = failure.diagnostics.filter((d) => d.severity === "error");
|
|
1726
|
+
if (errors.length > 0) {
|
|
1727
|
+
return `${prefix}: Type check errors
|
|
1728
|
+
|
|
1729
|
+
${formatDiagnostics(errors)}
|
|
1730
|
+
`;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
return `${prefix}: Type check errors
|
|
1734
|
+
`;
|
|
1735
|
+
case "bundle":
|
|
1736
|
+
if (failure.bundleErrors && failure.bundleErrors.length > 0) {
|
|
1737
|
+
return `${prefix}: Bundle errors
|
|
1738
|
+
|
|
1739
|
+
${formatBundleErrors(failure.bundleErrors)}
|
|
1740
|
+
`;
|
|
1741
|
+
}
|
|
1742
|
+
return `${prefix}: Bundle error
|
|
1743
|
+
`;
|
|
1744
|
+
default:
|
|
1745
|
+
return `${prefix}: Unknown error
|
|
1746
|
+
`;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1574
1749
|
// src/commands/index.ts
|
|
1575
1750
|
function createSandlotCommand(sandboxRef) {
|
|
1576
1751
|
return defineCommand("sandlot", async (args, ctx) => {
|
|
@@ -1681,42 +1856,9 @@ Examples:
|
|
|
1681
1856
|
format
|
|
1682
1857
|
});
|
|
1683
1858
|
if (!result.success) {
|
|
1684
|
-
let stderr = `Build failed`;
|
|
1685
|
-
switch (result.phase) {
|
|
1686
|
-
case "entry":
|
|
1687
|
-
stderr = `Build failed: ${result.message}
|
|
1688
|
-
`;
|
|
1689
|
-
break;
|
|
1690
|
-
case "typecheck":
|
|
1691
|
-
if (result.diagnostics) {
|
|
1692
|
-
const errors = result.diagnostics.filter((d) => d.severity === "error");
|
|
1693
|
-
stderr = `Build failed: Type check errors
|
|
1694
|
-
|
|
1695
|
-
${formatDiagnostics(errors)}
|
|
1696
|
-
`;
|
|
1697
|
-
} else {
|
|
1698
|
-
stderr = `Build failed: Type check errors
|
|
1699
|
-
`;
|
|
1700
|
-
}
|
|
1701
|
-
break;
|
|
1702
|
-
case "bundle":
|
|
1703
|
-
if (result.bundleErrors && result.bundleErrors.length > 0) {
|
|
1704
|
-
stderr = `Build failed: Bundle errors
|
|
1705
|
-
|
|
1706
|
-
${formatBundleErrors(result.bundleErrors)}
|
|
1707
|
-
`;
|
|
1708
|
-
} else {
|
|
1709
|
-
stderr = `Build failed: Bundle error
|
|
1710
|
-
`;
|
|
1711
|
-
}
|
|
1712
|
-
break;
|
|
1713
|
-
default:
|
|
1714
|
-
stderr = `Build failed: Unknown error
|
|
1715
|
-
`;
|
|
1716
|
-
}
|
|
1717
1859
|
return {
|
|
1718
1860
|
stdout: "",
|
|
1719
|
-
stderr,
|
|
1861
|
+
stderr: formatBuildFailure(result),
|
|
1720
1862
|
exitCode: 1
|
|
1721
1863
|
};
|
|
1722
1864
|
}
|
|
@@ -1780,18 +1922,20 @@ Examples:
|
|
|
1780
1922
|
const formatted = formatDiagnostics(errors);
|
|
1781
1923
|
return {
|
|
1782
1924
|
stdout: "",
|
|
1783
|
-
stderr: `Type check failed
|
|
1925
|
+
stderr: `Type check failed
|
|
1926
|
+
|
|
1784
1927
|
${formatted}
|
|
1785
1928
|
`,
|
|
1786
1929
|
exitCode: 1
|
|
1787
1930
|
};
|
|
1788
1931
|
}
|
|
1789
1932
|
const warnings = result.diagnostics.filter((d) => d.severity === "warning");
|
|
1790
|
-
let output = `Type check passed
|
|
1933
|
+
let output = `Type check passed
|
|
1791
1934
|
`;
|
|
1792
1935
|
if (warnings.length > 0) {
|
|
1793
1936
|
output += `
|
|
1794
1937
|
Warnings:
|
|
1938
|
+
|
|
1795
1939
|
${formatDiagnostics(warnings)}
|
|
1796
1940
|
`;
|
|
1797
1941
|
}
|
|
@@ -1966,13 +2110,7 @@ Examples:
|
|
|
1966
2110
|
if (!result.success) {
|
|
1967
2111
|
let stderr = "";
|
|
1968
2112
|
if (result.buildFailure) {
|
|
1969
|
-
stderr =
|
|
1970
|
-
if (result.buildFailure.message) {
|
|
1971
|
-
stderr += `
|
|
1972
|
-
${result.buildFailure.message}`;
|
|
1973
|
-
}
|
|
1974
|
-
stderr += `
|
|
1975
|
-
`;
|
|
2113
|
+
stderr = formatBuildFailure(result.buildFailure, "Run failed");
|
|
1976
2114
|
} else {
|
|
1977
2115
|
stderr = `Run failed: ${result.error ?? "Unknown error"}
|
|
1978
2116
|
`;
|
|
@@ -2319,7 +2457,10 @@ async function createSandboxImpl(fs, options, context) {
|
|
|
2319
2457
|
error: buildResult.message ?? `Build failed in ${buildResult.phase} phase`,
|
|
2320
2458
|
buildFailure: {
|
|
2321
2459
|
phase: buildResult.phase,
|
|
2322
|
-
message: buildResult.message
|
|
2460
|
+
message: buildResult.message,
|
|
2461
|
+
diagnostics: buildResult.diagnostics,
|
|
2462
|
+
bundleErrors: buildResult.bundleErrors,
|
|
2463
|
+
bundleWarnings: buildResult.bundleWarnings
|
|
2323
2464
|
}
|
|
2324
2465
|
};
|
|
2325
2466
|
}
|
|
@@ -2417,6 +2558,11 @@ function createSandlot(options) {
|
|
|
2417
2558
|
},
|
|
2418
2559
|
get sharedModules() {
|
|
2419
2560
|
return sharedModuleRegistry;
|
|
2561
|
+
},
|
|
2562
|
+
async dispose() {
|
|
2563
|
+
if (bundler.dispose) {
|
|
2564
|
+
await bundler.dispose();
|
|
2565
|
+
}
|
|
2420
2566
|
}
|
|
2421
2567
|
};
|
|
2422
2568
|
}
|
|
@@ -2610,7 +2756,7 @@ function escapeRegex(str) {
|
|
|
2610
2756
|
// src/node/preset.ts
|
|
2611
2757
|
async function createNodeSandlot(options = {}) {
|
|
2612
2758
|
const { bundler, typechecker, typesResolver, executor, ...rest } = options;
|
|
2613
|
-
const bundlerInstance =
|
|
2759
|
+
const bundlerInstance = createBundlerInstance(bundler);
|
|
2614
2760
|
await bundlerInstance.initialize();
|
|
2615
2761
|
const typecheckerInstance = typechecker === false ? undefined : isTypechecker(typechecker) ? typechecker : new Typechecker(typechecker);
|
|
2616
2762
|
const typesResolverInstance = typesResolver === false ? undefined : isTypesResolver(typesResolver) ? typesResolver : new EsmTypesResolver(typesResolver);
|
|
@@ -2623,6 +2769,22 @@ async function createNodeSandlot(options = {}) {
|
|
|
2623
2769
|
executor: executorInstance
|
|
2624
2770
|
});
|
|
2625
2771
|
}
|
|
2772
|
+
function createBundlerInstance(bundler) {
|
|
2773
|
+
if (isBundler(bundler)) {
|
|
2774
|
+
return bundler;
|
|
2775
|
+
}
|
|
2776
|
+
if (bundler === "wasm") {
|
|
2777
|
+
return new EsbuildWasmNodeBundler;
|
|
2778
|
+
}
|
|
2779
|
+
if (isWasmBundlerOptions(bundler)) {
|
|
2780
|
+
const { wasm: _, ...wasmOptions } = bundler;
|
|
2781
|
+
return new EsbuildWasmNodeBundler(wasmOptions);
|
|
2782
|
+
}
|
|
2783
|
+
return new EsbuildNativeBundler(bundler);
|
|
2784
|
+
}
|
|
2785
|
+
function isWasmBundlerOptions(value) {
|
|
2786
|
+
return typeof value === "object" && value !== null && "wasm" in value && value.wasm === true;
|
|
2787
|
+
}
|
|
2626
2788
|
function isBundler(value) {
|
|
2627
2789
|
return typeof value === "object" && value !== null && "bundle" in value && typeof value.bundle === "function";
|
|
2628
2790
|
}
|
|
@@ -2639,8 +2801,10 @@ export {
|
|
|
2639
2801
|
createTypechecker,
|
|
2640
2802
|
createNodeSandlot,
|
|
2641
2803
|
createNodeExecutor,
|
|
2804
|
+
createEsbuildWasmNodeBundler,
|
|
2642
2805
|
createEsbuildNativeBundler,
|
|
2643
2806
|
Typechecker,
|
|
2644
2807
|
NodeExecutor,
|
|
2808
|
+
EsbuildWasmNodeBundler,
|
|
2645
2809
|
EsbuildNativeBundler
|
|
2646
2810
|
};
|