Skip to content

Commit

Permalink
prefer worker package export conditionals if available (#93)
Browse files Browse the repository at this point in the history
* feat(build): configure esbuild to prefer cloudflare-worker then worker package export conditionals if available

* also adding support for 'production' and 'development' exports conditionals

* remove 'cloudflare-worker' condition

* make 'module' and 'imports' conditions synonymous

* adding changeset

* remove "development" and "production" conditionals

* Update packages/wrangler/src/dev.tsx

Co-authored-by: Mateusz Burzyński <[email protected]>

* Update packages/wrangler/src/publish.ts

Co-authored-by: Mateusz Burzyński <[email protected]>

Co-authored-by: Sunil Pai <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2021
1 parent 3057681 commit e928f94
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
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
1 change: 1 addition & 0 deletions packages/wrangler/src/dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions packages/wrangler/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default async function publish(props: Props): Promise<void> {
format: "esm",
sourcemap: true,
metafile: true,
conditions: ["worker", "browser"],
loader: {
".js": "jsx",
},
Expand Down

0 comments on commit e928f94

Please sign in to comment.