From d295901a05ccb4aafb414546f4a990b352bf28b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20S=C3=A1ez?= Date: Sun, 7 Nov 2021 12:16:16 -0300 Subject: [PATCH] first requested changes --- integrationTests/ts-esm/package.json | 3 +- integrationTests/ts/package.json | 3 +- integrationTests/webpack/webpack.config.json | 4 +- package-lock.json | 83 -------------------- package.json | 3 +- resources/build-npm-esm.js | 9 --- resources/build-npm.js | 17 ++-- 7 files changed, 13 insertions(+), 109 deletions(-) delete mode 100644 resources/build-npm-esm.js diff --git a/integrationTests/ts-esm/package.json b/integrationTests/ts-esm/package.json index a5028303596..2c98c6957fd 100644 --- a/integrationTests/ts-esm/package.json +++ b/integrationTests/ts-esm/package.json @@ -9,7 +9,6 @@ "typescript-4.2": "npm:typescript@4.2.x", "typescript-4.3": "npm:typescript@4.3.x", "typescript-4.4": "npm:typescript@4.4.x", - "typescript-4.5": "npm:typescript@4.5.1-rc", - "typescript-next": "npm:typescript@next" + "typescript-4.5": "npm:typescript@4.5.1-rc" } } diff --git a/integrationTests/ts/package.json b/integrationTests/ts/package.json index c832ee38dc7..9fc71009d1f 100644 --- a/integrationTests/ts/package.json +++ b/integrationTests/ts/package.json @@ -10,7 +10,6 @@ "typescript-4.2": "npm:typescript@4.2.x", "typescript-4.3": "npm:typescript@4.3.x", "typescript-4.4": "npm:typescript@4.4.x", - "typescript-4.5": "npm:typescript@4.5.1-rc", - "typescript-next": "npm:typescript@next" + "typescript-4.5": "npm:typescript@4.5.1-rc" } } diff --git a/integrationTests/webpack/webpack.config.json b/integrationTests/webpack/webpack.config.json index 003109d291f..830b2bd52dc 100644 --- a/integrationTests/webpack/webpack.config.json +++ b/integrationTests/webpack/webpack.config.json @@ -2,8 +2,6 @@ "mode": "production", "entry": "./entry.js", "output": { - "library": { - "type": "commonjs2" - } + "libraryTarget": "commonjs2" } } diff --git a/package-lock.json b/package-lock.json index e9a17bc3e96..83efee6395b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ "@babel/plugin-transform-typescript": "7.15.8", "@babel/preset-env": "7.15.8", "@babel/register": "7.15.3", - "@types/babel__core": "^7.1.16", "@types/chai": "4.2.22", "@types/mocha": "9.0.0", "@types/node": "16.11.1", @@ -2114,47 +2113,6 @@ "node": ">= 8" } }, - "node_modules/@types/babel__core": { - "version": "7.1.16", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.16.tgz", - "integrity": "sha512-EAEHtisTMM+KaKwfWdC3oyllIqswlznXCIVCt7/oRNrh+DhgT4UEBNC/jlADNjvw7UnfbcdkGQcPVZ1xYiLcrQ==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0", - "@types/babel__generator": "*", - "@types/babel__template": "*", - "@types/babel__traverse": "*" - } - }, - "node_modules/@types/babel__generator": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.3.tgz", - "integrity": "sha512-/GWCmzJWqV7diQW54smJZzWbSFf4QYtF71WCKhcx6Ru/tFyQIY2eiiITcCAeuPbNSvT9YCGkVMqqvSk2Z0mXiA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.0.0" - } - }, - "node_modules/@types/babel__template": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", - "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", - "dev": true, - "dependencies": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "node_modules/@types/babel__traverse": { - "version": "7.14.2", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.14.2.tgz", - "integrity": "sha512-K2waXdXBi2302XUdcHcR1jCeU0LL4TD9HRs/gk0N2Xvrht+G/BfJa4QObBQZfhMdxiCpV3COl5Nfq4uKTeTnJA==", - "dev": true, - "dependencies": { - "@babel/types": "^7.3.0" - } - }, "node_modules/@types/chai": { "version": "4.2.22", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.22.tgz", @@ -8881,47 +8839,6 @@ "fastq": "^1.6.0" } }, - "@types/babel__core": { - "version": "7.1.16", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.16.tgz", - "integrity": "sha512-EAEHtisTMM+KaKwfWdC3oyllIqswlznXCIVCt7/oRNrh+DhgT4UEBNC/jlADNjvw7UnfbcdkGQcPVZ1xYiLcrQ==", - "dev": true, - "requires": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0", - "@types/babel__generator": "*", - "@types/babel__template": "*", - "@types/babel__traverse": "*" - } - }, - "@types/babel__generator": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.3.tgz", - "integrity": "sha512-/GWCmzJWqV7diQW54smJZzWbSFf4QYtF71WCKhcx6Ru/tFyQIY2eiiITcCAeuPbNSvT9YCGkVMqqvSk2Z0mXiA==", - "dev": true, - "requires": { - "@babel/types": "^7.0.0" - } - }, - "@types/babel__template": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", - "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", - "dev": true, - "requires": { - "@babel/parser": "^7.1.0", - "@babel/types": "^7.0.0" - } - }, - "@types/babel__traverse": { - "version": "7.14.2", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.14.2.tgz", - "integrity": "sha512-K2waXdXBi2302XUdcHcR1jCeU0LL4TD9HRs/gk0N2Xvrht+G/BfJa4QObBQZfhMdxiCpV3COl5Nfq4uKTeTnJA==", - "dev": true, - "requires": { - "@babel/types": "^7.3.0" - } - }, "@types/chai": { "version": "4.2.22", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.22.tgz", diff --git a/package.json b/package.json index c7da9c56a4a..bea13222554 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "prettier:check": "prettier --check .", "check:spelling": "cspell --cache --no-progress '**/*'", "check:integrations": "npm run build:npm && npm run build:deno && mocha --full-trace integrationTests/*-test.js", - "build:npm": "node resources/build-npm.js && node resources/build-npm-esm.js", + "build:npm": "node resources/build-npm.js && node resources/build-npm.js --esm-only", "build:deno": "node resources/build-deno.js", "gitpublish:npm": "bash ./resources/gitpublish.sh npm npmDist", "gitpublish:deno": "bash ./resources/gitpublish.sh deno denoDist" @@ -56,7 +56,6 @@ "@babel/plugin-transform-typescript": "7.15.8", "@babel/preset-env": "7.15.8", "@babel/register": "7.15.3", - "@types/babel__core": "^7.1.16", "@types/chai": "4.2.22", "@types/mocha": "9.0.0", "@types/node": "16.11.1", diff --git a/resources/build-npm-esm.js b/resources/build-npm-esm.js deleted file mode 100644 index 7b32c02a3fe..00000000000 --- a/resources/build-npm-esm.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -const { buildNPM } = require('./build-npm.js'); - -if (require.main === module) { - buildNPM({ - isFullESM: true, - }); -} diff --git a/resources/build-npm.js b/resources/build-npm.js index 92a373f47ed..de037310f76 100644 --- a/resources/build-npm.js +++ b/resources/build-npm.js @@ -15,21 +15,23 @@ const prettierConfig = JSON.parse( fs.readFileSync(require.resolve('../.prettierrc'), 'utf-8'), ); +const isESMOnly = process.argv.includes('--esm-only'); + if (require.main === module) { buildNPM(); } exports.buildNPM = buildNPM; -function buildNPM({ isFullESM = false } = {}) { - const distDirectory = isFullESM ? './npmEsmDist' : './npmDist'; +function buildNPM() { + const distDirectory = isESMOnly ? './npmEsmDist' : './npmDist'; fs.rmSync(distDirectory, { recursive: true, force: true }); fs.mkdirSync(distDirectory); const srcFiles = readdirRecursive('./src', { ignoreDir: /^__.*__$/ }); - const packageJSON = buildPackageJSON(srcFiles, { isFullESM }); + const packageJSON = buildPackageJSON(srcFiles); for (const filepath of srcFiles) { const srcPath = path.join('./src', filepath); @@ -37,7 +39,7 @@ function buildNPM({ isFullESM = false } = {}) { fs.mkdirSync(path.dirname(destPath), { recursive: true }); if (filepath.endsWith('.ts')) { - if (isFullESM) { + if (isESMOnly) { const js = filepath === 'version.ts' ? babelTransform(getVersionFileBody(packageJSON.version), { @@ -85,7 +87,7 @@ function buildNPM({ isFullESM = false } = {}) { assert(packageJSON.types === undefined, 'Unexpected "types" in package.json'); - if (isFullESM) { + if (isESMOnly) { packageJSON.typesVersions = { '>=4.2.0': { '*': ['*'], @@ -150,7 +152,6 @@ function buildPackageJSON( * @type {string[]} */ srcFiles, - { isFullESM = false } = {}, ) { /** * @type {Record} @@ -163,7 +164,7 @@ function buildPackageJSON( delete packageJSON.scripts; delete packageJSON.devDependencies; - if (isFullESM) { + if (isESMOnly) { delete packageJSON.module; packageJSON.version = `${packageJSON.version}-esm`; @@ -199,7 +200,7 @@ function buildPackageJSON( packageJSON.publishConfig = { tag: publishTag }; } - if (isFullESM) { + if (isESMOnly) { /** * This allows imports without explicit extensions and index imports * Like `import("graphql/language/parser")` and `import("graphql/utilities")`