Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer worker package export conditionals if available #93

Merged
merged 8 commits into from
Dec 15, 2021
5 changes: 5 additions & 0 deletions .changeset/three-cooks-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Improve support for package exports conditionals, including "worker" condition
8 changes: 8 additions & 0 deletions packages/wrangler/src/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,14 @@ function useEsbuild(props: {
...(jsxFactory && { jsxFactory }),
...(jsxFragment && { jsxFragment }),
external: ["__STATIC_CONTENT_MANIFEST"],
nicksrandall marked this conversation as resolved.
Show resolved Hide resolved
conditions: [
"worker",
"browser",
"development",
nicksrandall marked this conversation as resolved.
Show resolved Hide resolved
"module",
"imports",
"default",
],
plugins: [moduleCollector.plugin],
// TODO: import.meta.url
watch: {
Expand Down
9 changes: 9 additions & 0 deletions packages/wrangler/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ export default async function publish(props: Props): Promise<void> {
format: "esm",
sourcemap: true,
metafile: true,
mainFields: ["browser", "module", "main"],
conditions: [
"worker",
"browser",
envName === "production" ? "production" : false,
nicksrandall marked this conversation as resolved.
Show resolved Hide resolved
"module",
"imports",
"default",
].filter(Boolean) as string[],
loader: {
".js": "jsx",
},
Expand Down