alchemy 0.22.2 → 0.22.3

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.
Files changed (33) hide show
  1. package/lib/cloudflare/bundle/bundle-worker.d.ts +4 -1
  2. package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -1
  3. package/lib/cloudflare/bundle/bundle-worker.js +35 -24
  4. package/lib/cloudflare/bundle/bundle-worker.js.map +1 -1
  5. package/lib/cloudflare/react-router.js +1 -1
  6. package/lib/cloudflare/website.d.ts.map +1 -1
  7. package/lib/cloudflare/website.js +1 -0
  8. package/lib/cloudflare/website.js.map +1 -1
  9. package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
  10. package/lib/cloudflare/worker-metadata.js +6 -1
  11. package/lib/cloudflare/worker-metadata.js.map +1 -1
  12. package/lib/cloudflare/worker.d.ts +25 -2
  13. package/lib/cloudflare/worker.d.ts.map +1 -1
  14. package/lib/cloudflare/worker.js +29 -11
  15. package/lib/cloudflare/worker.js.map +1 -1
  16. package/lib/cloudflare/wrangler.json.d.ts +3 -3
  17. package/lib/esbuild/bundle.d.ts +56 -61
  18. package/lib/esbuild/bundle.d.ts.map +1 -1
  19. package/lib/esbuild/bundle.js +2 -3
  20. package/lib/esbuild/bundle.js.map +1 -1
  21. package/lib/tsconfig.test.tsbuildinfo +1 -0
  22. package/lib/util/content-type.d.ts.map +1 -1
  23. package/lib/util/content-type.js +2 -0
  24. package/lib/util/content-type.js.map +1 -1
  25. package/package.json +85 -22
  26. package/src/cloudflare/bundle/bundle-worker.ts +59 -25
  27. package/src/cloudflare/react-router.ts +1 -1
  28. package/src/cloudflare/website.ts +1 -0
  29. package/src/cloudflare/worker-metadata.ts +6 -1
  30. package/src/cloudflare/worker.ts +63 -16
  31. package/src/cloudflare/wrangler.json.ts +10 -10
  32. package/src/esbuild/bundle.ts +2 -9
  33. package/src/util/content-type.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../src/util/content-type.ts"],"names":[],"mappings":"AAgCA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE"}
1
+ {"version":3,"file":"content-type.d.ts","sourceRoot":"","sources":["../../src/util/content-type.ts"],"names":[],"mappings":"AAkCA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE"}
@@ -5,6 +5,7 @@ const mimeTypes = {
5
5
  ".htm": "text/html",
6
6
  ".css": "text/css",
7
7
  ".js": "application/javascript",
8
+ ".mjs": "application/javascript+module",
8
9
  ".json": "application/json",
9
10
  ".xml": "application/xml",
10
11
  ".txt": "text/plain",
@@ -27,6 +28,7 @@ const mimeTypes = {
27
28
  ".webm": "video/webm",
28
29
  ".mp3": "audio/mpeg",
29
30
  ".wav": "audio/wav",
31
+ ".wasm": "application/wasm",
30
32
  };
31
33
  /**
32
34
  * Gets the content type for a file based on its extension
@@ -1 +1 @@
1
- {"version":3,"file":"content-type.js","sourceRoot":"","sources":["../../src/util/content-type.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,oBAAoB;AACpB,MAAM,SAAS,GAA2B;IACxC,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,wBAAwB;IAC/B,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,iBAAiB;IACzB,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,+BAA+B;IACvC,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,WAAW;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACzD,CAAC"}
1
+ {"version":3,"file":"content-type.js","sourceRoot":"","sources":["../../src/util/content-type.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,oBAAoB;AACpB,MAAM,SAAS,GAA2B;IACxC,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,+BAA+B;IACvC,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,eAAe;IACtB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,iBAAiB;IACzB,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,+BAA+B;IACvC,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,kBAAkB;CAC5B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AACzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemy",
3
- "version": "0.22.2",
3
+ "version": "0.22.3",
4
4
  "type": "module",
5
5
  "module": "./lib/index.js",
6
6
  "scripts": {
@@ -13,27 +13,90 @@
13
13
  "src"
14
14
  ],
15
15
  "exports": {
16
- ".": "./lib/index.js",
17
- "./ai": "./lib/ai/index.js",
18
- "./aws": "./lib/aws/index.js",
19
- "./aws/control": "./lib/aws/control/index.js",
20
- "./aws/oidc": "./lib/aws/oidc/index.js",
21
- "./cloudflare": "./lib/cloudflare/index.js",
22
- "./dns": "./lib/dns/index.js",
23
- "./esbuild": "./lib/esbuild/index.js",
24
- "./fs": "./lib/fs/index.js",
25
- "./github": "./lib/github/index.js",
26
- "./neon": "./lib/neon/index.js",
27
- "./os": "./lib/os/index.js",
28
- "./sentry": "./lib/sentry/index.js",
29
- "./stripe": "./lib/stripe/index.js",
30
- "./upstash": "./lib/upstash/index.js",
31
- "./vercel": "./lib/vercel/index.js",
32
- "./shadcn": "./lib/web/shadcn.js",
33
- "./web/astro": "./lib/web/astro.js",
34
- "./web/tailwind": "./lib/web/tailwind.js",
35
- "./web/vite": "./lib/web/vite.js",
36
- "./web/vitepress": "./lib/web/vitepress/index.js"
16
+ ".": {
17
+ "bun": "./src/index.ts",
18
+ "import": "./lib/index.js"
19
+ },
20
+ "./ai": {
21
+ "bun": "./src/ai/index.ts",
22
+ "import": "./lib/ai/index.js"
23
+ },
24
+ "./aws": {
25
+ "bun": "./src/aws/index.ts",
26
+ "import": "./lib/aws/index.js"
27
+ },
28
+ "./aws/control": {
29
+ "bun": "./src/aws/control/index.ts",
30
+ "import": "./lib/aws/control/index.js"
31
+ },
32
+ "./aws/oidc": {
33
+ "bun": "./src/aws/oidc/index.ts",
34
+ "import": "./lib/aws/oidc/index.js"
35
+ },
36
+ "./cloudflare": {
37
+ "bun": "./src/cloudflare/index.ts",
38
+ "import": "./lib/cloudflare/index.js"
39
+ },
40
+ "./dns": {
41
+ "bun": "./src/dns/index.ts",
42
+ "import": "./lib/dns/index.js"
43
+ },
44
+ "./esbuild": {
45
+ "bun": "./src/esbuild/index.ts",
46
+ "import": "./lib/esbuild/index.js"
47
+ },
48
+ "./fs": {
49
+ "bun": "./src/fs/index.ts",
50
+ "import": "./lib/fs/index.js"
51
+ },
52
+ "./github": {
53
+ "bun": "./src/github/index.ts",
54
+ "import": "./lib/github/index.js"
55
+ },
56
+ "./neon": {
57
+ "bun": "./src/neon/index.ts",
58
+ "import": "./lib/neon/index.js"
59
+ },
60
+ "./os": {
61
+ "bun": "./src/os/index.ts",
62
+ "import": "./lib/os/index.js"
63
+ },
64
+ "./sentry": {
65
+ "bun": "./src/sentry/index.ts",
66
+ "import": "./lib/sentry/index.js"
67
+ },
68
+ "./stripe": {
69
+ "bun": "./src/stripe/index.ts",
70
+ "import": "./lib/stripe/index.js"
71
+ },
72
+ "./upstash": {
73
+ "bun": "./src/upstash/index.ts",
74
+ "import": "./lib/upstash/index.js"
75
+ },
76
+ "./vercel": {
77
+ "bun": "./src/vercel/index.ts",
78
+ "import": "./lib/vercel/index.js"
79
+ },
80
+ "./shadcn": {
81
+ "bun": "./src/web/shadcn.ts",
82
+ "import": "./lib/web/shadcn.js"
83
+ },
84
+ "./web/astro": {
85
+ "bun": "./src/web/astro.ts",
86
+ "import": "./lib/web/astro.js"
87
+ },
88
+ "./web/tailwind": {
89
+ "bun": "./src/web/tailwind.ts",
90
+ "import": "./lib/web/tailwind.js"
91
+ },
92
+ "./web/vite": {
93
+ "bun": "./src/web/vite.ts",
94
+ "import": "./lib/web/vite.js"
95
+ },
96
+ "./web/vitepress": {
97
+ "bun": "./src/web/vitepress/index.ts",
98
+ "import": "./lib/web/vitepress/index.js"
99
+ }
37
100
  },
38
101
  "dependencies": {
39
102
  "unenv": "2.0.0-rc.15"
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs/promises";
2
+ import path from "node:path";
2
3
  import { Bundle } from "../../esbuild/bundle.ts";
3
4
  import type { Bindings } from "../bindings.ts";
4
5
  import type { WorkerProps } from "../worker.ts";
@@ -12,13 +13,17 @@ import { getNodeJSCompatMode } from "./nodejs-compat-mode.ts";
12
13
  import { nodeJsCompatPlugin } from "./nodejs-compat.ts";
13
14
  import { wasmPlugin } from "./wasm-plugin.ts";
14
15
 
16
+ export type NoBundleResult = {
17
+ [fileName: string]: Buffer;
18
+ };
19
+
15
20
  export async function bundleWorkerScript<B extends Bindings>(
16
21
  props: WorkerProps<B> & {
17
22
  entrypoint: string;
18
23
  compatibilityDate: string;
19
24
  compatibilityFlags: string[];
20
25
  },
21
- ) {
26
+ ): Promise<string | NoBundleResult> {
22
27
  const projectRoot = props.projectRoot ?? process.cwd();
23
28
 
24
29
  const nodeJsCompatMode = await getNodeJSCompatMode(
@@ -33,6 +38,40 @@ export async function bundleWorkerScript<B extends Bindings>(
33
38
  }
34
39
  const main = props.entrypoint;
35
40
 
41
+ if (props.noBundle) {
42
+ const rootDir = path.dirname(path.resolve(main));
43
+ const rules = (
44
+ props.rules ?? [
45
+ {
46
+ globs: ["**/*.js", "**/*.mjs", "**/*.wasm"],
47
+ },
48
+ ]
49
+ ).flatMap((rule) => rule.globs);
50
+ const files = Array.from(
51
+ new Set(
52
+ (
53
+ await Promise.all(
54
+ rules.map((rule) =>
55
+ Array.fromAsync(
56
+ fs.glob(rule, {
57
+ cwd: rootDir,
58
+ }),
59
+ ),
60
+ ),
61
+ )
62
+ ).flat(),
63
+ ),
64
+ );
65
+ return Object.fromEntries(
66
+ await Promise.all(
67
+ files.map(async (file) => [
68
+ file,
69
+ await fs.readFile(path.resolve(rootDir, file)),
70
+ ]),
71
+ ),
72
+ );
73
+ }
74
+
36
75
  try {
37
76
  const bundle = await Bundle("bundle", {
38
77
  entryPoint: main,
@@ -42,34 +81,29 @@ export async function bundleWorkerScript<B extends Bindings>(
42
81
  minify: false,
43
82
  ...(props.bundle || {}),
44
83
  conditions: ["workerd", "worker", "browser"],
45
- options: {
46
- absWorkingDir: projectRoot,
47
- ...(props.bundle?.options || {}),
48
- keepNames: true, // Important for Durable Object classes
49
- loader: {
50
- ".sql": "text",
51
- ".json": "json",
52
- ...props.bundle?.loader,
53
- ...props.bundle?.options?.loader,
54
- },
55
- plugins: [
56
- wasmPlugin,
57
- ...(props.bundle?.plugins ?? []),
58
- ...(nodeJsCompatMode === "v2" ? [await nodeJsCompatPlugin()] : []),
59
- ...(props.bundle?.alias
60
- ? [
61
- createAliasPlugin({
62
- alias: props.bundle?.alias,
63
- projectRoot,
64
- }),
65
- ]
66
- : []),
67
- ],
84
+ absWorkingDir: projectRoot,
85
+ keepNames: true, // Important for Durable Object classes
86
+ loader: {
87
+ ".sql": "text",
88
+ ".json": "json",
89
+ ...props.bundle?.loader,
68
90
  },
91
+ plugins: [
92
+ wasmPlugin,
93
+ ...(props.bundle?.plugins ?? []),
94
+ ...(nodeJsCompatMode === "v2" ? [await nodeJsCompatPlugin()] : []),
95
+ ...(props.bundle?.alias
96
+ ? [
97
+ createAliasPlugin({
98
+ alias: props.bundle?.alias,
99
+ projectRoot,
100
+ }),
101
+ ]
102
+ : []),
103
+ ],
69
104
  external: [
70
105
  ...(nodeJsCompatMode === "als" ? external_als : external),
71
106
  ...(props.bundle?.external ?? []),
72
- ...(props.bundle?.options?.external ?? []),
73
107
  ],
74
108
  });
75
109
  if (bundle.content) {
@@ -18,7 +18,7 @@ export async function ReactRouter<B extends Bindings>(
18
18
  const defaultAssets = path.join("build", "client");
19
19
  return Website(id, {
20
20
  ...props,
21
- // Alchemy should bundle the result of `vite built`, not the user's main
21
+ // Alchemy should bundle the result of `vite build`, not the user's main
22
22
  // TODO: we probably need bundling to properly handle WASM/rules
23
23
  main: path.join(props.cwd ?? process.cwd(), "build", "server", "index.js"),
24
24
  wrangler: {
@@ -131,6 +131,7 @@ export default {
131
131
  await Exec("build", {
132
132
  cwd,
133
133
  command: props.command,
134
+ env: props.env,
134
135
  });
135
136
 
136
137
  return (await Worker("worker", {
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  import type { Context } from "../context.ts";
2
3
  import { slugify } from "../util/slugify.ts";
3
4
  import {
@@ -525,7 +526,11 @@ export async function prepareWorkerMetadata<B extends Bindings>(
525
526
 
526
527
  // Determine if we're using ESM or service worker format
527
528
  const isEsModule = props.format !== "cjs"; // Default to ESM unless CJS is specified
528
- const scriptName = isEsModule ? "worker.js" : "script";
529
+ const scriptName = props.noBundle
530
+ ? path.basename(props.entrypoint!)
531
+ : isEsModule
532
+ ? "worker.js"
533
+ : "script";
529
534
 
530
535
  if (isEsModule) {
531
536
  // For ES modules format
@@ -9,6 +9,7 @@ import { Scope } from "../scope.ts";
9
9
  import { Secret, secret } from "../secret.ts";
10
10
  import { serializeScope } from "../serde.ts";
11
11
  import type { type } from "../type.ts";
12
+ import { getContentType } from "../util/content-type.ts";
12
13
  import { withExponentialBackoff } from "../util/retry.ts";
13
14
  import { slugify } from "../util/slugify.ts";
14
15
  import { CloudflareApiError, handleApiError } from "./api-error.ts";
@@ -26,7 +27,10 @@ import {
26
27
  } from "./bindings.ts";
27
28
  import type { Bound } from "./bound.ts";
28
29
  import { isBucket } from "./bucket.ts";
29
- import { bundleWorkerScript } from "./bundle/bundle-worker.ts";
30
+ import {
31
+ type NoBundleResult,
32
+ bundleWorkerScript,
33
+ } from "./bundle/bundle-worker.ts";
30
34
  import { isD1Database } from "./d1-database.ts";
31
35
  import {
32
36
  DurableObjectNamespace,
@@ -225,14 +229,38 @@ export interface InlineWorkerProps<
225
229
  > extends BaseWorkerProps<B, RPC> {
226
230
  script: string;
227
231
  entrypoint?: undefined;
232
+ noBundle?: false;
228
233
  }
229
234
 
230
235
  export interface EntrypointWorkerProps<
231
236
  B extends Bindings | undefined = Bindings,
232
237
  RPC extends Rpc.WorkerEntrypointBranded = Rpc.WorkerEntrypointBranded,
233
238
  > extends BaseWorkerProps<B, RPC> {
234
- entrypoint: string;
235
239
  script?: undefined;
240
+ /**
241
+ * The entrypoint for the worker script.
242
+ */
243
+ entrypoint: string;
244
+
245
+ /**
246
+ * Whether to disable bundling of the worker script.
247
+ *
248
+ * If true, the worker script and any files it imports will be deployed in the Worker.
249
+ *
250
+ * @default false
251
+ */
252
+ noBundle?: boolean;
253
+
254
+ /**
255
+ * Rules for adding additional files to the bundle.
256
+ *
257
+ * If {@link noBundle} is false | undefined, this will be ignored.
258
+ *
259
+ * @default - all .js, .mjs, and .wasm files under the entrypoint directory
260
+ */
261
+ rules?: {
262
+ globs: string[];
263
+ }[];
236
264
  }
237
265
 
238
266
  /**
@@ -695,6 +723,10 @@ export const _Worker = Resource(
695
723
  id: string,
696
724
  props: WorkerProps<B>,
697
725
  ): Promise<Worker<B>> {
726
+ if (props.noBundle && !props.entrypoint) {
727
+ throw new Error("entrypoint must be provided when noBundle is true");
728
+ }
729
+
698
730
  // Create Cloudflare API client with automatic account discovery
699
731
  const api = await createCloudflareApi(props);
700
732
 
@@ -713,7 +745,7 @@ export const _Worker = Resource(
713
745
  const oldTags = oldMetadata?.default_environment?.script?.tags;
714
746
 
715
747
  // Get the script content - either from props.script, or by bundling
716
- const scriptContent =
748
+ const scriptBundle =
717
749
  props.script ??
718
750
  (await bundleWorkerScript({
719
751
  ...props,
@@ -767,7 +799,7 @@ export const _Worker = Resource(
767
799
  assetUploadResult,
768
800
  );
769
801
 
770
- await putWorker(api, workerName, scriptContent, scriptMetadata);
802
+ await putWorker(api, workerName, scriptBundle, scriptMetadata);
771
803
 
772
804
  for (const workflow of workflowsBindings) {
773
805
  await upsertWorkflow(api, {
@@ -824,16 +856,18 @@ export const _Worker = Resource(
824
856
  }
825
857
  }
826
858
 
827
- return { scriptContent, scriptMetadata, workerUrl, now };
859
+ return { scriptBundle, scriptMetadata, workerUrl, now };
828
860
  };
829
861
 
830
862
  if (this.phase === "delete") {
831
863
  // Delete any queue consumers attached to this worker first
832
864
  await deleteQueueConsumers(this, api, workerName);
833
865
 
866
+ // @ts-ignore
834
867
  await uploadWorkerScript({
835
868
  ...props,
836
869
  entrypoint: undefined,
870
+ noBundle: false,
837
871
  script:
838
872
  props.format === "cjs"
839
873
  ? "addEventListener('fetch', event => { event.respondWith(new Response('hello world')); });"
@@ -960,7 +994,7 @@ export async function deleteWorker<B extends Bindings>(
960
994
  export async function putWorker(
961
995
  api: CloudflareApi,
962
996
  workerName: string,
963
- scriptContent: string,
997
+ scriptBundle: string | NoBundleResult,
964
998
  scriptMetadata: WorkerMetadata,
965
999
  ) {
966
1000
  return withExponentialBackoff(
@@ -971,16 +1005,29 @@ export async function putWorker(
971
1005
  // Create FormData for the upload
972
1006
  const formData = new FormData();
973
1007
 
974
- // Add the actual script content as a named file part
975
- formData.append(
976
- scriptName,
977
- new Blob([scriptContent], {
978
- type: scriptMetadata.main_module
979
- ? "application/javascript+module"
980
- : "application/javascript",
981
- }),
982
- scriptName,
983
- );
1008
+ function addFile(fileName: string, content: Buffer | string) {
1009
+ const contentType = getContentType(fileName) ?? "application/null";
1010
+ formData.append(
1011
+ fileName,
1012
+ new Blob([content], {
1013
+ type:
1014
+ contentType === "application/javascript" &&
1015
+ scriptMetadata.main_module
1016
+ ? "application/javascript+module"
1017
+ : contentType,
1018
+ }),
1019
+ fileName,
1020
+ );
1021
+ }
1022
+
1023
+ if (typeof scriptBundle === "string") {
1024
+ addFile(scriptName, scriptBundle);
1025
+ } else {
1026
+ for (const [fileName, content] of Object.entries(scriptBundle)) {
1027
+ // Add the actual script content as a named file part
1028
+ addFile(fileName, content);
1029
+ }
1030
+ }
984
1031
 
985
1032
  // Add metadata as JSON
986
1033
  formData.append(
@@ -1,13 +1,13 @@
1
- import type { Context } from "../context.js";
2
- import { StaticJsonFile } from "../fs/static-json-file.js";
3
- import { Resource } from "../resource.js";
4
- import { assertNever } from "../util/assert-never.js";
5
- import { Self, type Bindings } from "./bindings.js";
6
- import type { DurableObjectNamespace } from "./durable-object-namespace.js";
7
- import type { EventSource } from "./event-source.js";
8
- import { isQueueEventSource } from "./event-source.js";
9
- import { isQueue } from "./queue.js";
10
- import type { Worker, WorkerProps } from "./worker.js";
1
+ import type { Context } from "../context.ts";
2
+ import { StaticJsonFile } from "../fs/static-json-file.ts";
3
+ import { Resource } from "../resource.ts";
4
+ import { assertNever } from "../util/assert-never.ts";
5
+ import { Self, type Bindings } from "./bindings.ts";
6
+ import type { DurableObjectNamespace } from "./durable-object-namespace.ts";
7
+ import type { EventSource } from "./event-source.ts";
8
+ import { isQueueEventSource } from "./event-source.ts";
9
+ import { isQueue } from "./queue.ts";
10
+ import type { Worker, WorkerProps } from "./worker.ts";
11
11
 
12
12
  /**
13
13
  * Properties for wrangler.json configuration file
@@ -67,12 +67,6 @@ export interface BundleProps extends Partial<esbuild.BuildOptions> {
67
67
  * neutral: Platform-agnostic
68
68
  */
69
69
  platform?: "browser" | "node" | "neutral";
70
-
71
- /**
72
- * Additional esbuild options
73
- * Any other valid esbuild BuildOptions
74
- */
75
- options?: Partial<esbuild.BuildOptions>;
76
70
  }
77
71
 
78
72
  /**
@@ -185,10 +179,9 @@ export const Bundle = Resource(
185
179
  );
186
180
 
187
181
  export async function bundle(props: BundleProps) {
188
- const { entryPoint, options: _, ...rest } = props;
182
+ const { entryPoint, ...rest } = props;
189
183
  const options = {
190
184
  ...rest,
191
- ...props.options,
192
185
  write: !(props.outdir === undefined && props.outfile === undefined),
193
186
  // write:
194
187
  // props.outdir === undefined && props.outfile === undefined ? false : true,
@@ -201,7 +194,7 @@ export async function bundle(props: BundleProps) {
201
194
  target: props.target,
202
195
  minify: props.minify,
203
196
  sourcemap: props.sourcemap,
204
- external: [...(props.external ?? []), ...(props.options?.external ?? [])],
197
+ external: props.external,
205
198
  platform: props.platform,
206
199
  metafile: true,
207
200
  };
@@ -6,6 +6,7 @@ const mimeTypes: Record<string, string> = {
6
6
  ".htm": "text/html",
7
7
  ".css": "text/css",
8
8
  ".js": "application/javascript",
9
+ ".mjs": "application/javascript+module",
9
10
  ".json": "application/json",
10
11
  ".xml": "application/xml",
11
12
  ".txt": "text/plain",
@@ -28,6 +29,7 @@ const mimeTypes: Record<string, string> = {
28
29
  ".webm": "video/webm",
29
30
  ".mp3": "audio/mpeg",
30
31
  ".wav": "audio/wav",
32
+ ".wasm": "application/wasm",
31
33
  };
32
34
 
33
35
  /**