-
Notifications
You must be signed in to change notification settings - Fork 2k
enable conditional exports #4448
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
db79ea3
add support for conditional exports
yaacovCR a24135f
remove types field
yaacovCR 2af035e
f
yaacovCR 230e868
f
yaacovCR c5b51c1
f
yaacovCR 6171965
add upgrade guide blurb
yaacovCR 66eb7b3
MD
yaacovCR 3389554
standardize
yaacovCR d40d248
f
yaacovCR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ words: | |
|
||
# TODO: contribute upstream | ||
- deno | ||
- denoland | ||
- hashbang | ||
- Rspack | ||
- Rollup | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import assert from 'node:assert'; | ||
|
||
import { GraphQLObjectType as ESMGraphQLObjectType } from 'graphql'; | ||
|
||
import { CJSGraphQLObjectType, cjsPath } from './cjs-importer.cjs'; | ||
|
||
const moduleSync = process.env.MODULE_SYNC === 'true'; | ||
const expectedExtension = moduleSync ? '.mjs' : '.js'; | ||
assert.ok( | ||
cjsPath.endsWith(expectedExtension), | ||
`require('graphql') should resolve to a file with extension "${expectedExtension}", but got "${cjsPath}".`, | ||
); | ||
|
||
const isSameModule = ESMGraphQLObjectType === CJSGraphQLObjectType; | ||
assert.strictEqual( | ||
isSameModule, | ||
true, | ||
'ESM and CJS imports should be the same module instances.', | ||
); | ||
|
||
console.log('Module identity and path checks passed.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const { GraphQLObjectType } = require('graphql'); | ||
|
||
const cjsPath = require.resolve('graphql'); | ||
|
||
// eslint-disable-next-line import/no-commonjs | ||
module.exports = { | ||
CJSGraphQLObjectType: GraphQLObjectType, | ||
cjsPath, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"description": "graphql-js should be loaded correctly on different versions of Node.js, Deno and Bun", | ||
"private": true, | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"dependencies": { | ||
"graphql": "file:../graphql.tgz" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import childProcess from 'node:child_process'; | ||
|
||
const nodeTests = [ | ||
// Old node versions, require => CJS | ||
{ version: '20.18.0', moduleSync: false }, | ||
{ version: '22.11.0', moduleSync: false }, | ||
// New node versions, module-sync => ESM | ||
{ version: '20.19.0', moduleSync: true }, | ||
{ version: '22.12.0', moduleSync: true }, | ||
{ version: '24.0.0', moduleSync: true }, | ||
]; | ||
|
||
for (const { version, moduleSync } of nodeTests) { | ||
console.log(`Testing on node@${version} (moduleSync: ${moduleSync}) ...`); | ||
childProcess.execSync( | ||
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app --env MODULE_SYNC=${moduleSync} node:${version}-slim node ./check.mjs`, | ||
{ stdio: 'inherit' }, | ||
); | ||
} | ||
|
||
console.log('Testing on bun (moduleSync: true) ...'); | ||
childProcess.execSync( | ||
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app --env MODULE_SYNC=true oven/bun:alpine bun ./check.mjs`, | ||
{ stdio: 'inherit' }, | ||
); | ||
|
||
console.log('Testing on deno (moduleSync: false) ...'); | ||
childProcess.execSync( | ||
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app --env MODULE_SYNC=false denoland/alpine-2.4.1 deno run --allow-read --allow-env ./check.mjs`, | ||
{ stdio: 'inherit' }, | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"dependencies": { | ||
"graphql": "file:../graphql.tgz", | ||
"graphql-esm": "file:../graphql-esm.tgz", | ||
"@types/node": "~24.0.10", | ||
"typescript-4.9": "npm:[email protected]", | ||
"typescript-5.0": "npm:[email protected]", | ||
"typescript-5.1": "npm:[email protected]", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.