Skip to content

Commit

Permalink
Merge pull request #263 from apollographql/pr/edge
Browse files Browse the repository at this point in the history
add "edge-light" exports condition
  • Loading branch information
phryneas authored Apr 3, 2024
2 parents 9fc65d3 + 133141c commit b297bc5
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 20 deletions.
39 changes: 33 additions & 6 deletions packages/client-react-streaming/package-shape.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"InMemoryCache",
"RemoveMultipartDirectivesLink",
"SSRMultipartLink",
"registerApolloClient"
"registerApolloClient",
"built_for_rsc"
],
"browser": [
"ApolloClient",
Expand All @@ -16,7 +17,8 @@
"RemoveMultipartDirectivesLink",
"SSRMultipartLink",
"WrapApolloProvider",
"resetApolloSingletons"
"resetApolloSingletons",
"built_for_browser"
],
"node": [
"ApolloClient",
Expand All @@ -26,12 +28,37 @@
"RemoveMultipartDirectivesLink",
"SSRMultipartLink",
"WrapApolloProvider",
"resetApolloSingletons"
"resetApolloSingletons",
"built_for_ssr"
],
"edge-light,worker,browser": [
"ApolloClient",
"DataTransportContext",
"DebounceMultipartResponsesLink",
"InMemoryCache",
"RemoveMultipartDirectivesLink",
"SSRMultipartLink",
"WrapApolloProvider",
"resetApolloSingletons",
"built_for_ssr"
]
},
"@apollo/client-react-streaming/manual-transport": {
"react-server": [],
"browser": ["buildManualDataTransport", "resetManualSSRApolloSingletons"],
"node": ["buildManualDataTransport", "resetManualSSRApolloSingletons"]
"react-server": ["built_for_other"],
"browser": [
"buildManualDataTransport",
"resetManualSSRApolloSingletons",
"built_for_browser"
],
"node": [
"buildManualDataTransport",
"resetManualSSRApolloSingletons",
"built_for_ssr"
],
"edge-light,worker,browser": [
"buildManualDataTransport",
"resetManualSSRApolloSingletons",
"built_for_ssr"
]
}
}
4 changes: 4 additions & 0 deletions packages/client-react-streaming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@
"require": {
"types": "./dist/combined.d.cts",
"react-server": "./dist/index.rsc.cjs",
"edge-light": "./dist/index.ssr.cjs",
"browser": "./dist/index.browser.cjs",
"node": "./dist/index.ssr.cjs"
},
"import": {
"types": "./dist/combined.d.ts",
"react-server": "./dist/index.rsc.js",
"edge-light": "./dist/index.ssr.js",
"browser": "./dist/index.browser.js",
"node": "./dist/index.ssr.js"
}
Expand All @@ -62,12 +64,14 @@
"require": {
"types": "./dist/manual-transport.ssr.d.cts",
"react-server": "./dist/empty.cjs",
"edge-light": "./dist/manual-transport.ssr.cjs",
"browser": "./dist/manual-transport.browser.cjs",
"node": "./dist/manual-transport.ssr.cjs"
},
"import": {
"types": "./dist/manual-transport.ssr.d.ts",
"react-server": "./dist/empty.js",
"edge-light": "./dist/manual-transport.ssr.js",
"browser": "./dist/manual-transport.browser.js",
"node": "./dist/manual-transport.ssr.js"
}
Expand Down
5 changes: 5 additions & 0 deletions packages/client-react-streaming/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;`
}
},
};
}

Expand Down
31 changes: 25 additions & 6 deletions packages/experimental-nextjs-app-support/package-shape.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"react-server": [
"DebounceMultipartResponsesLink",
"RemoveMultipartDirectivesLink",
"SSRMultipartLink"
"SSRMultipartLink",
"built_for_rsc"
],
"browser": [
"ApolloNextAppProvider",
Expand All @@ -17,7 +18,8 @@
"useFragment",
"useQuery",
"useReadQuery",
"useSuspenseQuery"
"useSuspenseQuery",
"built_for_browser"
],
"node": [
"ApolloNextAppProvider",
Expand All @@ -31,12 +33,29 @@
"useFragment",
"useQuery",
"useReadQuery",
"useSuspenseQuery"
"useSuspenseQuery",
"built_for_ssr"
],
"edge-light,worker,browser": [
"ApolloNextAppProvider",
"DebounceMultipartResponsesLink",
"NextSSRApolloClient",
"NextSSRInMemoryCache",
"RemoveMultipartDirectivesLink",
"SSRMultipartLink",
"resetNextSSRApolloSingletons",
"useBackgroundQuery",
"useFragment",
"useQuery",
"useReadQuery",
"useSuspenseQuery",
"built_for_ssr"
]
},
"@apollo/experimental-nextjs-app-support/rsc": {
"react-server": ["registerApolloClient"],
"browser": [],
"node": []
"react-server": ["registerApolloClient", "built_for_rsc"],
"browser": ["built_for_other"],
"node": ["built_for_other"],
"edge-light,worker,browser": ["built_for_other"]
}
}
8 changes: 4 additions & 4 deletions packages/experimental-nextjs-app-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
"require": {
"types": "./dist/rsc/index.d.cts",
"react-server": "./dist/rsc/index.cjs",
"browser": "./dist/empty.cjs",
"node": "./dist/empty.cjs"
"default": "./dist/empty.cjs"
},
"import": {
"types": "./dist/rsc/index.d.ts",
"react-server": "./dist/rsc/index.js",
"browser": "./dist/empty.js",
"node": "./dist/empty.js"
"default": "./dist/empty.js"
}
},
"./ssr": {
"require": {
"types": "./dist/ssr/index.ssr.d.cts",
"react-server": "./dist/ssr/index.rsc.cjs",
"edge-light": "./dist/ssr/index.ssr.cjs",
"browser": "./dist/ssr/index.browser.cjs",
"node": "./dist/ssr/index.ssr.cjs"
},
"import": {
"types": "./dist/ssr/index.ssr.d.ts",
"react-server": "./dist/ssr/index.rsc.js",
"edge-light": "./dist/ssr/index.ssr.js",
"browser": "./dist/ssr/index.browser.js",
"node": "./dist/ssr/index.ssr.js"
}
Expand Down
8 changes: 8 additions & 0 deletions packages/experimental-nextjs-app-support/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ 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;`,
};
},
};
}

Expand Down
16 changes: 12 additions & 4 deletions scripts/verify-package-shape.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ async function checkPackage(/** @type {string} */ pkg) {
* @param {string[]} shape
*/
async function verifyESM(condition, entryPoint, pkg, shape) {
console.log(`Checking ESM: ${entryPoint} with condition ${condition}`);
const conditionFlags = condition
.split(",")
.map((c) => `--conditions ${c}`)
.join(" ");
console.log(`Checking ESM: ${entryPoint} with ${conditionFlags}`);
const child = exec(
`node --input-type=module --conditions ${condition} --eval 'console.log(JSON.stringify(Object.keys(await import("${entryPoint}"))))'`,
`node --input-type=module ${conditionFlags} --eval 'console.log(JSON.stringify(Object.keys(await import("${entryPoint}"))))'`,
{
cwd: dirname(pkg),
}
Expand All @@ -61,9 +65,13 @@ async function verifyESM(condition, entryPoint, pkg, shape) {
* @param {string[]} shape
*/
async function verifyCJS(condition, entryPoint, pkg, shape) {
console.log(`Checking CJS: ${entryPoint} with condition ${condition}`);
const conditionFlags = condition
.split(",")
.map((c) => `--conditions ${c}`)
.join(" ");
console.log(`Checking CJS: ${entryPoint} with ${conditionFlags}`);
const child = exec(
`node --input-type=commonjs --conditions ${condition} --eval 'console.log(JSON.stringify(Object.keys(require("${entryPoint}"))))'`,
`node --input-type=commonjs ${conditionFlags} --eval 'console.log(JSON.stringify(Object.keys(require("${entryPoint}"))))'`,
{
cwd: dirname(pkg),
}
Expand Down

0 comments on commit b297bc5

Please sign in to comment.