diff --git a/.changeset/three-cooks-type.md b/.changeset/three-cooks-type.md new file mode 100644 index 000000000000..1821c286957e --- /dev/null +++ b/.changeset/three-cooks-type.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +Improve support for package exports conditionals, including "worker" condition diff --git a/packages/wrangler/src/dev.tsx b/packages/wrangler/src/dev.tsx index a09e3f3ca791..715555feaf9e 100644 --- a/packages/wrangler/src/dev.tsx +++ b/packages/wrangler/src/dev.tsx @@ -374,6 +374,7 @@ function useEsbuild(props: { ...(jsxFactory && { jsxFactory }), ...(jsxFragment && { jsxFragment }), external: ["__STATIC_CONTENT_MANIFEST"], + conditions: ["worker", "browser"], plugins: [moduleCollector.plugin], // TODO: import.meta.url watch: { diff --git a/packages/wrangler/src/publish.ts b/packages/wrangler/src/publish.ts index 31eb8f1f74a0..79b4478f4d25 100644 --- a/packages/wrangler/src/publish.ts +++ b/packages/wrangler/src/publish.ts @@ -99,6 +99,7 @@ export default async function publish(props: Props): Promise { format: "esm", sourcemap: true, metafile: true, + conditions: ["worker", "browser"], loader: { ".js": "jsx", },