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

add "edge-light" exports condition #263

Merged
merged 2 commits into from
Apr 3, 2024
Merged

add "edge-light" exports condition #263

merged 2 commits into from
Apr 3, 2024

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Apr 2, 2024

I believe this should resolve #261 and #262.

I'm a bit hesitant to just slap a "worker" (which doesn't seem to be standardized?) on here, so I'm going for the more granular "edge-light"

@phryneas phryneas requested a review from a team as a code owner April 2, 2024 09:44
"resetApolloSingletons",
"built_for_ssr"
],
"edge-light,worker,browser": [
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the order of conditions that Next.js is using, so we check for that explicitly.

See

https://github.com/vercel/next.js/blob/bbd79ac9977e03010e09ff90d933f2ec614b031f/packages/next/src/build/webpack-config.ts#L96-L103

Copy link

github-actions bot commented Apr 2, 2024

size-limit report 📦

Path Size
{ ApolloNextAppProvider, NextSSRApolloClient, NextSSRInMemoryCache } from '@apollo/experimental-nextjs-app-support/ssr' (Browser ESM) 7.79 KB (+0.02% 🔺)
{ WrapApolloProvider, ApolloClient, InMemoryCache } from '@apollo/client-react-streaming' (Browser ESM) 1.41 KB (0%)
{ buildManualDataTransport } from '@apollo/client-react-streaming/manual-transport' (Browser ESM) 6.27 KB (+0.29% 🔺)
@apollo/client-react-streaming (Browser ESM) 2.14 KB (+0.92% 🔺)
@apollo/client-react-streaming (SSR ESM) 1.74 KB (+1.03% 🔺)
@apollo/client-react-streaming (RSC ESM) 1.02 KB (+2.46% 🔺)
@apollo/client-react-streaming/manual-transport (Browser ESM) 6.46 KB (+0.48% 🔺)
@apollo/client-react-streaming/manual-transport (SSR ESM) 6.34 KB (+0.35% 🔺)
@apollo/experimental-nextjs-app-support/ssr (Browser ESM) 8.41 KB (+0.13% 🔺)
@apollo/experimental-nextjs-app-support/ssr (SSR ESM) 8.33 KB (+0.31% 🔺)
@apollo/experimental-nextjs-app-support/ssr (RSC ESM) 857 B (+2.15% 🔺)
@apollo/experimental-nextjs-app-support/rsc (RSC ESM) 278 B (+6.52% 🔺)

Copy link

relativeci bot commented Apr 2, 2024

Job #93: Bundle Size — 1.01MiB (0%).

133141c(current) vs 9fc65d3 main#92(baseline)

Warning

Bundle contains 1 duplicate package – View duplicate packages

Bundle metrics  Change 1 change
                 Current
Job #93
     Baseline
Job #92
No change  Initial JS 890.59KiB 890.59KiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 22.25% 0.04%
No change  Chunks 24 24
No change  Assets 45 45
No change  Modules 512 512
No change  Duplicate Modules 30 30
No change  Duplicate Code 1.29% 1.29%
No change  Packages 29 29
No change  Duplicate Packages 1 1
Bundle size by type  no changes
                 Current
Job #93
     Baseline
Job #92
Not changed  JS 1023.85KiB 1023.85KiB
Not changed  Other 5.99KiB 5.99KiB

View job #93 reportView pr/edge branch activityView project dashboard

@phryneas
Copy link
Member Author

phryneas commented Apr 2, 2024

/release:pr

Copy link

github-actions bot commented Apr 2, 2024

A new release has been made for this PR. You can install the package you need using one of

  • npm i @apollo/experimental-nextjs-app-support@0.0.0-commit-84f7c8d
  • npm i @apollo/client-react-streaming@0.0.0-commit-84f7c8d

Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

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

Changes look good. I was mainly curious about what the bundle_for_x was for 🙂

@@ -43,6 +43,11 @@ export default defineConfig((options) => {
entry: {
[output]: input,
},
footer(ctx) {
return {
js: ctx.format === 'esm' ? `export const built_for_${env} = true;` : `exports.built_for_${env} = true;`
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I'm understanding the significance of the build_for_<env> variable here. Could you explain that?

Copy link
Member Author

@phryneas phryneas Apr 3, 2024

Choose a reason for hiding this comment

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

Sometimes the SSR and Browser bundle have the same shape, so I'm deliberately giving them different shapes by adding an additional environment-specific export, so I can safely distinguish between them in the package-shape.json test.

Especially for the edge-light condition, I needed a way to safely distinguish between the SSR build and the Browser build, because they "looked the same".

@phryneas phryneas merged commit b297bc5 into main Apr 3, 2024
16 checks passed
@phryneas phryneas deleted the pr/edge branch April 3, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window is not defined error in dev logs
2 participants