@cloudflare/worker-bundler 0.2.2 → 0.2.4
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/{file-system-PsI0bi2L.d.ts → file-system-ZXKe_fv7.d.ts} +7 -2
- package/dist/index.d.ts +15 -13
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/dist/installer-DDvaMqav.js +630 -0
- package/dist/installer-DDvaMqav.js.map +1 -0
- package/dist/typescript.d.ts +1 -1
- package/dist/typescript.js +1 -1
- package/package.json +4 -3
- package/dist/installer-Ns4ivVf5.js +0 -272
- package/dist/installer-Ns4ivVf5.js.map +0 -1
|
@@ -11,7 +11,7 @@ interface FileSystem {
|
|
|
11
11
|
* @param path The path to the file.
|
|
12
12
|
* @param content The contents of the file.
|
|
13
13
|
*/
|
|
14
|
-
write(path: string, content:
|
|
14
|
+
write(path: string, content: FileEntry): void;
|
|
15
15
|
/**
|
|
16
16
|
* Deletes a file from the file system.
|
|
17
17
|
* @param path The path to the file.
|
|
@@ -128,6 +128,11 @@ declare function createFileSystemSnapshot(
|
|
|
128
128
|
| AsyncIterable<readonly [string, string]>
|
|
129
129
|
| Iterable<readonly [string, string]>
|
|
130
130
|
): Promise<InMemoryFileSystem>;
|
|
131
|
+
type FileEntry =
|
|
132
|
+
| string
|
|
133
|
+
| {
|
|
134
|
+
data: Uint8Array<ArrayBuffer>;
|
|
135
|
+
};
|
|
131
136
|
//#endregion
|
|
132
137
|
export {
|
|
133
138
|
createFileSystemSnapshot as a,
|
|
@@ -136,4 +141,4 @@ export {
|
|
|
136
141
|
FileSystem as r,
|
|
137
142
|
DurableObjectKVFileSystem as t
|
|
138
143
|
};
|
|
139
|
-
//# sourceMappingURL=file-system-
|
|
144
|
+
//# sourceMappingURL=file-system-ZXKe_fv7.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
n as DurableObjectRawFileSystem,
|
|
5
5
|
r as FileSystem,
|
|
6
6
|
t as DurableObjectKVFileSystem
|
|
7
|
-
} from "./file-system-
|
|
7
|
+
} from "./file-system-ZXKe_fv7.js";
|
|
8
8
|
|
|
9
9
|
//#region src/types.d.ts
|
|
10
10
|
/**
|
|
@@ -484,17 +484,7 @@ declare function inferContentType(path: string): string | undefined;
|
|
|
484
484
|
*/
|
|
485
485
|
declare function isTextContentType(contentType: string): boolean;
|
|
486
486
|
//#endregion
|
|
487
|
-
//#region src/
|
|
488
|
-
interface InstallOptions {
|
|
489
|
-
/**
|
|
490
|
-
* Include devDependencies (default: false)
|
|
491
|
-
*/
|
|
492
|
-
dev?: boolean;
|
|
493
|
-
/**
|
|
494
|
-
* Registry URL (default: https://registry.npmjs.org)
|
|
495
|
-
*/
|
|
496
|
-
registry?: string;
|
|
497
|
-
}
|
|
487
|
+
//#region src/common.d.ts
|
|
498
488
|
interface InstallResult {
|
|
499
489
|
/**
|
|
500
490
|
* Packages that were freshly installed in this call.
|
|
@@ -506,6 +496,18 @@ interface InstallResult {
|
|
|
506
496
|
*/
|
|
507
497
|
warnings: string[];
|
|
508
498
|
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/installer.d.ts
|
|
501
|
+
interface InstallOptions {
|
|
502
|
+
/**
|
|
503
|
+
* Include devDependencies (default: false)
|
|
504
|
+
*/
|
|
505
|
+
dev?: boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Registry URL (default: https://registry.npmjs.org)
|
|
508
|
+
*/
|
|
509
|
+
registry?: string;
|
|
510
|
+
}
|
|
509
511
|
/**
|
|
510
512
|
* Install npm dependencies into a virtual file system.
|
|
511
513
|
*
|
|
@@ -521,7 +523,7 @@ declare function installDependencies(
|
|
|
521
523
|
options?: InstallOptions
|
|
522
524
|
): Promise<InstallResult>;
|
|
523
525
|
/**
|
|
524
|
-
* Check if files contain a package.json with dependencies that need installing.
|
|
526
|
+
* Check if files contain a package.json or pyproject.toml with dependencies that need installing.
|
|
525
527
|
*/
|
|
526
528
|
declare function hasDependencies(files: FileSystem): boolean;
|
|
527
529
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as hasDependencies, r as installDependencies } from "./installer-
|
|
1
|
+
import { n as hasDependencies, r as installDependencies } from "./installer-DDvaMqav.js";
|
|
2
2
|
import * as esbuild from "esbuild-wasm/lib/browser.js";
|
|
3
3
|
import { parse } from "es-module-lexer/js";
|
|
4
4
|
import * as resolveExports from "resolve.exports";
|
|
@@ -784,6 +784,7 @@ const DEFAULT_ENTRY_POINTS = [
|
|
|
784
784
|
"src/index.mjs",
|
|
785
785
|
"index.ts",
|
|
786
786
|
"index.js",
|
|
787
|
+
"index.py",
|
|
787
788
|
"src/worker.ts",
|
|
788
789
|
"src/worker.js"
|
|
789
790
|
];
|
|
@@ -1516,7 +1517,7 @@ async function createApp(options) {
|
|
|
1516
1517
|
const nodejsCompat = hasNodejsCompat(wranglerConfig);
|
|
1517
1518
|
const installWarnings = [];
|
|
1518
1519
|
if (hasDependencies(fileSystem)) {
|
|
1519
|
-
const installResult = await installDependencies(fileSystem, registry ? { registry } : {});
|
|
1520
|
+
const installResult = await installDependencies(fileSystem, { ...registry ? { registry } : {} });
|
|
1520
1521
|
installWarnings.push(...installResult.warnings);
|
|
1521
1522
|
}
|
|
1522
1523
|
const clientEntries = options.client ? Array.isArray(options.client) ? options.client : [options.client] : [];
|
|
@@ -1627,12 +1628,29 @@ async function createWorker(options) {
|
|
|
1627
1628
|
const nodejsCompat = hasNodejsCompat(wranglerConfig);
|
|
1628
1629
|
const installWarnings = [];
|
|
1629
1630
|
if (hasDependencies(fileSystem)) {
|
|
1630
|
-
const installResult = await installDependencies(fileSystem, registry ? { registry } : {});
|
|
1631
|
+
const installResult = await installDependencies(fileSystem, { ...registry ? { registry } : {} });
|
|
1631
1632
|
installWarnings.push(...installResult.warnings);
|
|
1632
1633
|
}
|
|
1633
1634
|
const entryPoint = options.entryPoint ?? detectEntryPoint(fileSystem, wranglerConfig);
|
|
1634
1635
|
if (!entryPoint) throw new Error(`Could not determine entry point for createWorker. Tried (in order): the \`entryPoint\` option, \`main\` in wrangler config, \`exports\`/\`module\`/\`main\` in package.json, and the defaults ${DEFAULT_ENTRY_POINTS.join(", ")}. Pass \`entryPoint\` explicitly or add one of those files.`);
|
|
1635
1636
|
if (fileSystem.read(entryPoint) === null) throw new Error(`Entry point "${entryPoint}" was not found in \`files\`. Available files: ${formatFileListForError(fileSystem)}.`);
|
|
1637
|
+
if (entryPoint.endsWith(".py")) {
|
|
1638
|
+
const modules = {};
|
|
1639
|
+
for (const path of fileSystem.list()) {
|
|
1640
|
+
if (path === "pyproject.toml") continue;
|
|
1641
|
+
const content = fileSystem.read(path);
|
|
1642
|
+
if (content !== null) modules[path] = content;
|
|
1643
|
+
}
|
|
1644
|
+
return {
|
|
1645
|
+
mainModule: entryPoint,
|
|
1646
|
+
modules,
|
|
1647
|
+
wranglerConfig: {
|
|
1648
|
+
compatibilityDate: wranglerConfig?.compatibilityDate ?? "2026-07-02",
|
|
1649
|
+
compatibilityFlags: wranglerConfig?.compatibilityFlags ?? []
|
|
1650
|
+
},
|
|
1651
|
+
warnings: installWarnings
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1636
1654
|
if (bundle) {
|
|
1637
1655
|
const result = await bundleWithEsbuild({
|
|
1638
1656
|
files: fileSystem,
|