From 7a431a058451a75b900090fde425aca84ca99415 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Tue, 16 Jun 2026 13:42:39 +0300 Subject: [PATCH] chore(npm): remove obsolete ESM-only package build --- integrationTests/node/index.mjs | 10 +- integrationTests/node/package.json | 3 +- integrationTests/ts/esm.ts | 10 +- integrationTests/ts/package.json | 1 - integrationTests/webpack/entry-esm.mjs | 4 +- integrationTests/webpack/package.json | 1 - resources/build-npm.ts | 171 ++++++++++--------------- resources/integration-test.ts | 6 - 8 files changed, 82 insertions(+), 124 deletions(-) diff --git a/integrationTests/node/index.mjs b/integrationTests/node/index.mjs index 0c4337dd7a..9afc604151 100644 --- a/integrationTests/node/index.mjs +++ b/integrationTests/node/index.mjs @@ -1,13 +1,13 @@ import assert from 'node:assert'; import { readFileSync } from 'node:fs'; -import { graphqlSync } from 'graphql-esm'; -import { astFromValue, buildSchema } from 'graphql-esm/utilities'; -import { version } from 'graphql-esm/version'; +import { graphqlSync } from 'graphql'; +import { astFromValue, buildSchema } from 'graphql/utilities'; +import { version } from 'graphql/version'; assert.deepStrictEqual( - version + '+esm', - JSON.parse(readFileSync('./node_modules/graphql-esm/package.json')).version, + version, + JSON.parse(readFileSync('./node_modules/graphql/package.json')).version, ); const schema = buildSchema('type Query { hello: String }'); diff --git a/integrationTests/node/package.json b/integrationTests/node/package.json index 8271998588..2d2665ed9a 100644 --- a/integrationTests/node/package.json +++ b/integrationTests/node/package.json @@ -6,7 +6,6 @@ "test": "node test.js" }, "dependencies": { - "graphql": "file:../graphql.tgz", - "graphql-esm": "file:../graphql-esm.tgz" + "graphql": "file:../graphql.tgz" } } diff --git a/integrationTests/ts/esm.ts b/integrationTests/ts/esm.ts index bb7158f363..e9998b31ed 100644 --- a/integrationTests/ts/esm.ts +++ b/integrationTests/ts/esm.ts @@ -1,11 +1,7 @@ -import type { ExecutionResult } from 'graphql-esm/execution'; +import type { ExecutionResult } from 'graphql/execution'; -import { graphqlSync } from 'graphql-esm'; -import { - GraphQLString, - GraphQLSchema, - GraphQLObjectType, -} from 'graphql-esm/type'; +import { graphqlSync } from 'graphql'; +import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type'; const queryType: GraphQLObjectType = new GraphQLObjectType({ name: 'Query', diff --git a/integrationTests/ts/package.json b/integrationTests/ts/package.json index 3c9e860700..0f8900dfe0 100644 --- a/integrationTests/ts/package.json +++ b/integrationTests/ts/package.json @@ -7,7 +7,6 @@ }, "dependencies": { "graphql": "file:../graphql.tgz", - "graphql-esm": "file:../graphql-esm.tgz", "@types/node": "~24.0.14", "typescript-4.9": "npm:typescript@4.9.x", "typescript-5.0": "npm:typescript@5.0.x", diff --git a/integrationTests/webpack/entry-esm.mjs b/integrationTests/webpack/entry-esm.mjs index 5a04dc1ada..be4a2a448d 100644 --- a/integrationTests/webpack/entry-esm.mjs +++ b/integrationTests/webpack/entry-esm.mjs @@ -1,5 +1,5 @@ -import { graphqlSync } from 'graphql-esm'; -import { buildSchema } from 'graphql-esm/utilities/buildASTSchema'; +import { graphqlSync } from 'graphql'; +import { buildSchema } from 'graphql/utilities/buildASTSchema'; const schema = buildSchema('type Query { hello: String }'); diff --git a/integrationTests/webpack/package.json b/integrationTests/webpack/package.json index 66dd836f1e..74a2502ff7 100644 --- a/integrationTests/webpack/package.json +++ b/integrationTests/webpack/package.json @@ -7,7 +7,6 @@ }, "dependencies": { "graphql": "file:../graphql.tgz", - "graphql-esm": "file:../graphql-esm.tgz", "webpack": "5.x.x", "webpack-cli": "4.x.x" } diff --git a/resources/build-npm.ts b/resources/build-npm.ts index d832dad3a3..632a36fc24 100644 --- a/resources/build-npm.ts +++ b/resources/build-npm.ts @@ -28,14 +28,10 @@ const devTypeFiles = [ ] as const; console.log('\n./npmDist'); -await buildPackage('./npmDist', false); +await buildPackage('./npmDist'); showDirStats('./npmDist'); -console.log('\n./npmEsmDist'); -await buildPackage('./npmEsmDist', true); -showDirStats('./npmEsmDist'); - -async function buildPackage(outDir: string, isESMOnly: boolean): Promise { +async function buildPackage(outDir: string): Promise { const devDir = path.join(outDir, '__dev__'); fs.rmSync(outDir, { recursive: true, force: true }); @@ -79,113 +75,88 @@ async function buildPackage(outDir: string, isESMOnly: boolean): Promise { 'Publish tag and version tag should match!', ); - if (isESMOnly) { - packageJSON.exports = {}; - - const { emittedTSFiles } = emitTSFiles({ outDir, extension: '.js' }); + delete packageJSON.type; + packageJSON.main = 'index.js'; + packageJSON.module = 'index.mjs'; + packageJSON.types = 'index.d.ts'; - for (const filepath of emittedTSFiles) { - if (path.basename(filepath) === 'index.js') { - const relativePath = './' + path.relative('./npmEsmDist', filepath); - packageJSON.exports[path.dirname(relativePath)] = relativePath; - } + const { emittedTSFiles } = emitTSFiles({ + outDir, + module: 'commonjs', + moduleResolution: 'node10', + extension: '.js', + }); + emitTSFiles({ outDir, extension: '.mjs' }); + + packageJSON.exports = {}; + for (const prodFile of emittedTSFiles) { + const { dir, base, name, ext } = path.parse(prodFile); + + if (ext === '.map') { + continue; + } else if (path.basename(dir) === 'dev') { + packageJSON.exports['./dev'] = buildPlatformConditionalExports( + './dev', + 'index', + ); + continue; } - packageJSON.exports['./*.js'] = './*.js'; - packageJSON.exports['./*'] = './*.js'; - - packageJSON.publishConfig.tag += '-esm'; - packageJSON.version += '+esm'; - } else { - delete packageJSON.type; - packageJSON.main = 'index.js'; - packageJSON.module = 'index.mjs'; - packageJSON.types = 'index.d.ts'; - - const { emittedTSFiles } = emitTSFiles({ - outDir, - module: 'commonjs', - moduleResolution: 'node10', - extension: '.js', - }); - emitTSFiles({ outDir, extension: '.mjs' }); - - packageJSON.exports = {}; - for (const prodFile of emittedTSFiles) { - const { dir, base, name, ext } = path.parse(prodFile); - - if (ext === '.map') { - continue; - } else if (path.basename(dir) === 'dev') { - packageJSON.exports['./dev'] = buildPlatformConditionalExports( - './dev', - 'index', - ); - continue; - } + const relativePathToProd = path.relative(prodFile, outDir); - const relativePathToProd = path.relative(prodFile, outDir); + const { name: innerName, ext: innerExt } = path.parse(name); - const { name: innerName, ext: innerExt } = path.parse(name); + if (innerExt === '.d') { + const relativePathAndName = path.relative(outDir, `${dir}/${innerName}`); - if (innerExt === '.d') { - const relativePathAndName = path.relative( - outDir, - `${dir}/${innerName}`, + for (const [typeExt, targetExt] of devTypeFiles) { + const line = `export * from '${relativePathToProd}/${relativePathAndName}${targetExt}';`; + writeGeneratedFile( + path.join(devDir, path.relative(outDir, `${dir}/${name}${typeExt}`)), + line, ); - - for (const [typeExt, targetExt] of devTypeFiles) { - const line = `export * from '${relativePathToProd}/${relativePathAndName}${targetExt}';`; - writeGeneratedFile( - path.join( - devDir, - path.relative(outDir, `${dir}/${name}${typeExt}`), - ), - line, - ); - } - continue; } + continue; + } - const relativePathAndName = path.relative(outDir, `${dir}/${name}`); - - writeGeneratedFile( - path.join(devDir, path.relative(outDir, `${dir}/${name}.js`)), - buildCJSDevModeStub( - `${relativePathToProd}/devMode.js`, - `${relativePathToProd}/${relativePathAndName}.js`, - ), - ); - - writeGeneratedFile( - path.join(devDir, path.relative(outDir, `${dir}/${name}.mjs`)), - buildESMDevModeStub( - `${relativePathToProd}/devMode.mjs`, - `${relativePathToProd}/${relativePathAndName}.mjs`, + const relativePathAndName = path.relative(outDir, `${dir}/${name}`); + + writeGeneratedFile( + path.join(devDir, path.relative(outDir, `${dir}/${name}.js`)), + buildCJSDevModeStub( + `${relativePathToProd}/devMode.js`, + `${relativePathToProd}/${relativePathAndName}.js`, + ), + ); + + writeGeneratedFile( + path.join(devDir, path.relative(outDir, `${dir}/${name}.mjs`)), + buildESMDevModeStub( + `${relativePathToProd}/devMode.mjs`, + `${relativePathToProd}/${relativePathAndName}.mjs`, + ), + ); + + if (base === 'index.js') { + const dirname = path.dirname(relativePathAndName); + packageJSON.exports[dirname === '.' ? dirname : `./${dirname}`] = { + development: buildPlatformConditionalExports( + './__dev__', + relativePathAndName, ), - ); - - if (base === 'index.js') { - const dirname = path.dirname(relativePathAndName); - packageJSON.exports[dirname === '.' ? dirname : `./${dirname}`] = { - development: buildPlatformConditionalExports( - './__dev__', - relativePathAndName, - ), - default: buildPlatformConditionalExports('.', relativePathAndName), - }; - } + default: buildPlatformConditionalExports('.', relativePathAndName), + }; } + } - const globEntryPoints = { - development: buildPlatformConditionalExports('./__dev__', '*'), - default: buildPlatformConditionalExports('.', '*'), - }; - packageJSON.exports['./*.js'] = globEntryPoints; - packageJSON.exports['./*'] = globEntryPoints; + const globEntryPoints = { + development: buildPlatformConditionalExports('./__dev__', '*'), + default: buildPlatformConditionalExports('.', '*'), + }; + packageJSON.exports['./*.js'] = globEntryPoints; + packageJSON.exports['./*'] = globEntryPoints; - packageJSON.sideEffects = ['__dev__/*']; - } + packageJSON.sideEffects = ['__dev__/*']; const packageJsonPath = `./${outDir}/package.json`; const prettified = await prettify( diff --git a/resources/integration-test.ts b/resources/integration-test.ts index fd4ce1e3b1..4afd27627f 100644 --- a/resources/integration-test.ts +++ b/resources/integration-test.ts @@ -20,12 +20,6 @@ describe('Integration Tests', () => { const archiveName = npm({ cwd: tmpDirPath(), quiet: true }).pack(distDir); fs.renameSync(tmpDirPath(archiveName), tmpDirPath('graphql.tgz')); - const esmDistDir = localRepoPath('npmEsmDist'); - const archiveEsmName = npm({ cwd: tmpDirPath(), quiet: true }).pack( - esmDistDir, - ); - fs.renameSync(tmpDirPath(archiveEsmName), tmpDirPath('graphql-esm.tgz')); - npm().run('build:deno'); fs.cpSync(localRepoPath('denoDist'), tmpDirPath('graphql-deno-dist'), { recursive: true,