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

Added edge-light and workerd conditions #3215

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/whiny-lemons-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@emotion/use-insertion-effect-with-fallbacks': minor
'@emotion/primitives': minor
'@emotion/styled': minor
'@emotion/cache': minor
'@emotion/react': minor
'@emotion/utils': minor
---

Added `edge-light` and `workerd` conditions to `package.json` manifest to better serve users using Vercel Edge and Cloudflare Workers.
34 changes: 28 additions & 6 deletions packages/cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@
"default": "./dist/emotion-cache.cjs.js"
},
"development": {
"edge-light": {
"module": "./dist/emotion-cache.development.edge-light.esm.js",
"import": "./dist/emotion-cache.development.edge-light.cjs.mjs",
"default": "./dist/emotion-cache.development.edge-light.cjs.js"
},
"worker": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do other libraries not use their browser builds for Service Workers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, there are no great guidelines for this and various tools are not exactly overly consistent and explicit when it comes to differentiating between browser and worker builds.

Webpack 5 docs have always suggested using the worker condition for (web)workers... so that's what we went with here.

But I'm also not sure if I have understood the intention behind your question. Could you elaborate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we found in the past is that some tools would pick up the browser condition when targeting workers so we had to use some earlier condition (worker) to "shadow" over the browser condition. Ideally, it would just fall through to the default condition and use that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering if it makes more sense to use browser builds. But if the browser builds access the DOM, they're not suited for Service Workers. Given that there's little guidance/standardization around this topic we'll probably just have to find out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye, so that's the main distinction that we have here - #is-browser could be called #can-use-dom. That's the only thing we care about atm. So we can't use the browser builds because they assume being able to access DOM

"module": "./dist/emotion-cache.development.worker.esm.js",
"import": "./dist/emotion-cache.development.worker.cjs.mjs",
"default": "./dist/emotion-cache.development.worker.cjs.js"
"module": "./dist/emotion-cache.development.edge-light.esm.js",
"import": "./dist/emotion-cache.development.edge-light.cjs.mjs",
"default": "./dist/emotion-cache.development.edge-light.cjs.js"
},
"workerd": {
"module": "./dist/emotion-cache.development.edge-light.esm.js",
"import": "./dist/emotion-cache.development.edge-light.cjs.mjs",
"default": "./dist/emotion-cache.development.edge-light.cjs.js"
},
"browser": {
"module": "./dist/emotion-cache.browser.development.esm.js",
Expand All @@ -25,10 +35,20 @@
"import": "./dist/emotion-cache.development.cjs.mjs",
"default": "./dist/emotion-cache.development.cjs.js"
},
"edge-light": {
"module": "./dist/emotion-cache.edge-light.esm.js",
"import": "./dist/emotion-cache.edge-light.cjs.mjs",
"default": "./dist/emotion-cache.edge-light.cjs.js"
},
"worker": {
"module": "./dist/emotion-cache.worker.esm.js",
"import": "./dist/emotion-cache.worker.cjs.mjs",
"default": "./dist/emotion-cache.worker.cjs.js"
"module": "./dist/emotion-cache.edge-light.esm.js",
"import": "./dist/emotion-cache.edge-light.cjs.mjs",
"default": "./dist/emotion-cache.edge-light.cjs.js"
},
"workerd": {
"module": "./dist/emotion-cache.edge-light.esm.js",
"import": "./dist/emotion-cache.edge-light.cjs.mjs",
"default": "./dist/emotion-cache.edge-light.cjs.js"
},
"browser": {
"module": "./dist/emotion-cache.browser.esm.js",
Expand All @@ -47,6 +67,8 @@
"default": "./src/conditions/false.js"
},
"#is-browser": {
"edge-light": "./src/conditions/false.js",
"workerd": "./src/conditions/false.js",
"worker": "./src/conditions/false.js",
"browser": "./src/conditions/true.js",
"default": "./src/conditions/is-browser.js"
Expand Down
1 change: 0 additions & 1 deletion packages/primitives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"./package.json": "./package.json",
"./macro": "./macro.js"
},
"imports": {},
"preconstruct": {
"exports": {
"extra": {
Expand Down
130 changes: 106 additions & 24 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@
"default": "./dist/emotion-react.cjs.js"
},
"development": {
"edge-light": {
"module": "./dist/emotion-react.development.edge-light.esm.js",
"import": "./dist/emotion-react.development.edge-light.cjs.mjs",
"default": "./dist/emotion-react.development.edge-light.cjs.js"
},
"worker": {
"module": "./dist/emotion-react.development.worker.esm.js",
"import": "./dist/emotion-react.development.worker.cjs.mjs",
"default": "./dist/emotion-react.development.worker.cjs.js"
"module": "./dist/emotion-react.development.edge-light.esm.js",
"import": "./dist/emotion-react.development.edge-light.cjs.mjs",
"default": "./dist/emotion-react.development.edge-light.cjs.js"
},
"workerd": {
"module": "./dist/emotion-react.development.edge-light.esm.js",
"import": "./dist/emotion-react.development.edge-light.cjs.mjs",
"default": "./dist/emotion-react.development.edge-light.cjs.js"
},
"browser": {
"module": "./dist/emotion-react.browser.development.esm.js",
Expand All @@ -24,10 +34,20 @@
"import": "./dist/emotion-react.development.cjs.mjs",
"default": "./dist/emotion-react.development.cjs.js"
},
"edge-light": {
"module": "./dist/emotion-react.edge-light.esm.js",
"import": "./dist/emotion-react.edge-light.cjs.mjs",
"default": "./dist/emotion-react.edge-light.cjs.js"
},
"worker": {
"module": "./dist/emotion-react.worker.esm.js",
"import": "./dist/emotion-react.worker.cjs.mjs",
"default": "./dist/emotion-react.worker.cjs.js"
"module": "./dist/emotion-react.edge-light.esm.js",
"import": "./dist/emotion-react.edge-light.cjs.mjs",
"default": "./dist/emotion-react.edge-light.cjs.js"
},
"workerd": {
"module": "./dist/emotion-react.edge-light.esm.js",
"import": "./dist/emotion-react.edge-light.cjs.mjs",
"default": "./dist/emotion-react.edge-light.cjs.js"
},
"browser": {
"module": "./dist/emotion-react.browser.esm.js",
Expand All @@ -44,10 +64,20 @@
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
},
"development": {
"edge-light": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.cjs.js"
},
"worker": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.worker.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.worker.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.worker.cjs.js"
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.cjs.js"
},
"workerd": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.edge-light.cjs.js"
},
"browser": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.development.esm.js",
Expand All @@ -58,10 +88,20 @@
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.development.cjs.js"
},
"edge-light": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.cjs.js"
},
"worker": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.cjs.js"
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.cjs.js"
},
"workerd": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.esm.js",
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.cjs.mjs",
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.edge-light.cjs.js"
},
"browser": {
"module": "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
Expand All @@ -78,10 +118,20 @@
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
},
"development": {
"edge-light": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.js"
},
"worker": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.worker.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.worker.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.worker.cjs.js"
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.js"
},
"workerd": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.edge-light.cjs.js"
},
"browser": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.development.esm.js",
Expand All @@ -92,10 +142,20 @@
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.development.cjs.js"
},
"edge-light": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.js"
},
"worker": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.cjs.js"
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.js"
},
"workerd": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.esm.js",
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.mjs",
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.edge-light.cjs.js"
},
"browser": {
"module": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
Expand All @@ -112,10 +172,20 @@
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
},
"development": {
"edge-light": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.cjs.js"
},
"worker": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.worker.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.worker.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.worker.cjs.js"
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.cjs.js"
},
"workerd": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.edge-light.cjs.js"
},
"browser": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.development.esm.js",
Expand All @@ -126,10 +196,20 @@
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.development.cjs.js"
},
"edge-light": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.cjs.js"
},
"worker": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.cjs.js"
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.cjs.js"
},
"workerd": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.esm.js",
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.cjs.mjs",
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.edge-light.cjs.js"
},
"browser": {
"module": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
Expand All @@ -156,6 +236,8 @@
"default": "./src/conditions/false.js"
},
"#is-browser": {
"edge-light": "./src/conditions/false.js",
"workerd": "./src/conditions/false.js",
"worker": "./src/conditions/false.js",
"browser": "./src/conditions/true.js",
"default": "./src/conditions/is-browser.js"
Expand Down
66 changes: 54 additions & 12 deletions packages/styled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@
"default": "./base/dist/emotion-styled-base.cjs.js"
},
"development": {
"edge-light": {
"module": "./base/dist/emotion-styled-base.development.edge-light.esm.js",
"import": "./base/dist/emotion-styled-base.development.edge-light.cjs.mjs",
"default": "./base/dist/emotion-styled-base.development.edge-light.cjs.js"
},
"worker": {
"module": "./base/dist/emotion-styled-base.development.worker.esm.js",
"import": "./base/dist/emotion-styled-base.development.worker.cjs.mjs",
"default": "./base/dist/emotion-styled-base.development.worker.cjs.js"
"module": "./base/dist/emotion-styled-base.development.edge-light.esm.js",
"import": "./base/dist/emotion-styled-base.development.edge-light.cjs.mjs",
"default": "./base/dist/emotion-styled-base.development.edge-light.cjs.js"
},
"workerd": {
"module": "./base/dist/emotion-styled-base.development.edge-light.esm.js",
"import": "./base/dist/emotion-styled-base.development.edge-light.cjs.mjs",
"default": "./base/dist/emotion-styled-base.development.edge-light.cjs.js"
},
"browser": {
"module": "./base/dist/emotion-styled-base.browser.development.esm.js",
Expand All @@ -65,10 +75,20 @@
"import": "./base/dist/emotion-styled-base.development.cjs.mjs",
"default": "./base/dist/emotion-styled-base.development.cjs.js"
},
"edge-light": {
"module": "./base/dist/emotion-styled-base.edge-light.esm.js",
"import": "./base/dist/emotion-styled-base.edge-light.cjs.mjs",
"default": "./base/dist/emotion-styled-base.edge-light.cjs.js"
},
"worker": {
"module": "./base/dist/emotion-styled-base.worker.esm.js",
"import": "./base/dist/emotion-styled-base.worker.cjs.mjs",
"default": "./base/dist/emotion-styled-base.worker.cjs.js"
"module": "./base/dist/emotion-styled-base.edge-light.esm.js",
"import": "./base/dist/emotion-styled-base.edge-light.cjs.mjs",
"default": "./base/dist/emotion-styled-base.edge-light.cjs.js"
},
"workerd": {
"module": "./base/dist/emotion-styled-base.edge-light.esm.js",
"import": "./base/dist/emotion-styled-base.edge-light.cjs.mjs",
"default": "./base/dist/emotion-styled-base.edge-light.cjs.js"
},
"browser": {
"module": "./base/dist/emotion-styled-base.browser.esm.js",
Expand All @@ -85,10 +105,20 @@
"default": "./dist/emotion-styled.cjs.js"
},
"development": {
"edge-light": {
"module": "./dist/emotion-styled.development.edge-light.esm.js",
"import": "./dist/emotion-styled.development.edge-light.cjs.mjs",
"default": "./dist/emotion-styled.development.edge-light.cjs.js"
},
"worker": {
"module": "./dist/emotion-styled.development.worker.esm.js",
"import": "./dist/emotion-styled.development.worker.cjs.mjs",
"default": "./dist/emotion-styled.development.worker.cjs.js"
"module": "./dist/emotion-styled.development.edge-light.esm.js",
"import": "./dist/emotion-styled.development.edge-light.cjs.mjs",
"default": "./dist/emotion-styled.development.edge-light.cjs.js"
},
"workerd": {
"module": "./dist/emotion-styled.development.edge-light.esm.js",
"import": "./dist/emotion-styled.development.edge-light.cjs.mjs",
"default": "./dist/emotion-styled.development.edge-light.cjs.js"
},
"browser": {
"module": "./dist/emotion-styled.browser.development.esm.js",
Expand All @@ -99,10 +129,20 @@
"import": "./dist/emotion-styled.development.cjs.mjs",
"default": "./dist/emotion-styled.development.cjs.js"
},
"edge-light": {
"module": "./dist/emotion-styled.edge-light.esm.js",
"import": "./dist/emotion-styled.edge-light.cjs.mjs",
"default": "./dist/emotion-styled.edge-light.cjs.js"
},
"worker": {
"module": "./dist/emotion-styled.worker.esm.js",
"import": "./dist/emotion-styled.worker.cjs.mjs",
"default": "./dist/emotion-styled.worker.cjs.js"
"module": "./dist/emotion-styled.edge-light.esm.js",
"import": "./dist/emotion-styled.edge-light.cjs.mjs",
"default": "./dist/emotion-styled.edge-light.cjs.js"
},
"workerd": {
"module": "./dist/emotion-styled.edge-light.esm.js",
"import": "./dist/emotion-styled.edge-light.cjs.mjs",
"default": "./dist/emotion-styled.edge-light.cjs.js"
},
"browser": {
"module": "./dist/emotion-styled.browser.esm.js",
Expand All @@ -128,6 +168,8 @@
"default": "./src/conditions/false.js"
},
"#is-browser": {
"edge-light": "./src/conditions/false.js",
"workerd": "./src/conditions/false.js",
"worker": "./src/conditions/false.js",
"browser": "./src/conditions/true.js",
"default": "./src/conditions/is-browser.js"
Expand Down
Loading
Loading