From 5b2fab434885aa9a6549be92d1d268b895d35cb3 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Mon, 28 Oct 2024 12:18:16 -0700 Subject: [PATCH 1/9] chore: Merged from main --- package.json | 1 + src/common.ts | 2 +- src/gaxios.ts | 6 +++--- src/index.ts | 8 ++++---- src/interceptor.ts | 2 +- src/retry.ts | 2 +- src/util.ts | 17 ----------------- tsconfig.json | 10 +++------- 8 files changed, 14 insertions(+), 34 deletions(-) delete mode 100644 src/util.ts diff --git a/package.json b/package.json index 29d085c7..5880ba67 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A simple common HTTP client specifically for Google APIs and services.", "main": "build/src/index.js", "types": "build/src/index.d.ts", + "type": "module", "files": [ "build/src" ], diff --git a/src/common.ts b/src/common.ts index 1d840e80..c20d32db 100644 --- a/src/common.ts +++ b/src/common.ts @@ -14,7 +14,7 @@ import {Agent} from 'http'; import {URL} from 'url'; -import {pkg} from './util'; +import {pkg} from './util.cjs'; import extend from 'extend'; import {Readable} from 'stream'; diff --git a/src/gaxios.ts b/src/gaxios.ts index 33918109..e6efc2c4 100644 --- a/src/gaxios.ts +++ b/src/gaxios.ts @@ -25,10 +25,10 @@ import { GaxiosPromise, GaxiosResponse, defaultErrorRedactor, -} from './common'; -import {getRetryConfig} from './retry'; +} from './common.js'; +import {getRetryConfig} from './retry.js'; import {Readable} from 'stream'; -import {GaxiosInterceptorManager} from './interceptor'; +import {GaxiosInterceptorManager} from './interceptor.js'; /* eslint-disable @typescript-eslint/no-explicit-any */ diff --git a/src/index.ts b/src/index.ts index c563eac6..1b98e087 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {GaxiosOptions} from './common'; -import {Gaxios} from './gaxios'; +import {GaxiosOptions} from './common.js'; +import {Gaxios} from './gaxios.js'; export { GaxiosError, @@ -20,9 +20,9 @@ export { GaxiosResponse, GaxiosOptionsPrepared, RetryConfig, -} from './common'; +} from './common.js'; export {Gaxios, GaxiosOptions}; -export * from './interceptor'; +export * from './interceptor.js'; /** * The default instance used when the `request` method is directly diff --git a/src/interceptor.ts b/src/interceptor.ts index 9ccfad86..2e8e0689 100644 --- a/src/interceptor.ts +++ b/src/interceptor.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {GaxiosError, GaxiosOptionsPrepared, GaxiosResponse} from './common'; +import {GaxiosError, GaxiosOptionsPrepared, GaxiosResponse} from './common.js'; /** * Interceptors that can be run for requests or responses. These interceptors run asynchronously. diff --git a/src/retry.ts b/src/retry.ts index ba792c59..1faf9aff 100644 --- a/src/retry.ts +++ b/src/retry.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import {GaxiosError, RetryConfig} from './common'; +import {GaxiosError, RetryConfig} from './common.js'; export async function getRetryConfig(err: GaxiosError) { let config = getConfig(err); diff --git a/src/util.ts b/src/util.ts deleted file mode 100644 index 1428c3bc..00000000 --- a/src/util.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2023 Google LLC -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -export const pkg: { - name: string; - version: string; -} = require('../../package.json'); diff --git a/tsconfig.json b/tsconfig.json index 3538ab11..65f327ab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,8 @@ { - "extends": "./node_modules/gts/tsconfig-google.json", + "extends": "./tsconfig.base.json", "compilerOptions": { - "lib": ["es2023", "dom"], - "rootDir": ".", - "outDir": "build", - "esModuleInterop": true, + "outDir": "build/esm", "module": "Node16", "moduleResolution": "Node16" - }, - "include": ["src/*.ts", "test/*.ts", "browser-test/*.ts", "system-test/*.ts"] + } } From cb36907c2576709ca6b4fad1157095030695688b Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Mon, 28 Oct 2024 19:05:29 -0700 Subject: [PATCH 2/9] feat!: Dual-Support ESM & CJS --- package.json | 30 +++-- src/common.ts | 7 +- src/util.cts | 19 +++ system-test/fixtures/sample/package.json | 3 +- system-test/test.install.ts | 149 +++++++++++++++++------ test/test.getch.ts | 9 +- test/test.index.ts | 2 +- test/test.retry.ts | 2 +- tsconfig.base.json | 9 ++ tsconfig.cjs.json | 8 ++ tsconfig.json | 5 +- 11 files changed, 184 insertions(+), 59 deletions(-) create mode 100644 src/util.cts create mode 100644 tsconfig.base.json create mode 100644 tsconfig.cjs.json diff --git a/package.json b/package.json index 5880ba67..398fada3 100644 --- a/package.json +++ b/package.json @@ -2,18 +2,30 @@ "name": "gaxios", "version": "6.7.1", "description": "A simple common HTTP client specifically for Google APIs and services.", - "main": "build/src/index.js", - "types": "build/src/index.d.ts", - "type": "module", + "main": "build/cjs/src/index.js", + "types": "build/cjs/src/index.d.ts", "files": [ - "build/src" + "build/" ], + "exports": { + ".": { + "import": { + "types": "./build/esm/src/index.d.ts", + "default": "./build/esm/src/index.js" + }, + "require": { + "types": "./build/cjs/src/index.d.ts", + "default": "./build/cjs/src/index.js" + } + } + }, "scripts": { "lint": "gts check", - "test": "c8 mocha build/test", + "test": "c8 mocha build/esm/test", "presystem-test": "npm run compile", - "system-test": "mocha build/system-test --timeout 80000", - "compile": "tsc -p .", + "system-test": "mocha build/esm/system-test --timeout 80000", + "compile": "tsc -b ./tsconfig.json ./tsconfig.cjs.json", + "postcompile": "node -e 'fs.writeFileSync(`./build/esm/package.json`, JSON.stringify({type: \"module\"}))'", "fix": "gts fix", "prepare": "npm run compile", "pretest": "npm run compile", @@ -25,8 +37,7 @@ "predocs-test": "npm run docs", "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "prelint": "cd samples; npm link ../; npm install", - "clean": "gts clean", - "precompile": "gts clean" + "clean": "gts clean" }, "repository": "googleapis/gaxios", "keywords": [ @@ -76,6 +87,7 @@ "ncp": "^2.0.0", "nock": "^14.0.0-beta.13", "null-loader": "^4.0.0", + "pack-n-play": "^2.0.3", "puppeteer": "^23.0.0", "sinon": "^17.0.0", "stream-browserify": "^3.0.0", diff --git a/src/common.ts b/src/common.ts index c20d32db..a1d9c79f 100644 --- a/src/common.ts +++ b/src/common.ts @@ -13,10 +13,13 @@ import {Agent} from 'http'; import {URL} from 'url'; +import {Readable} from 'stream'; -import {pkg} from './util.cjs'; import extend from 'extend'; -import {Readable} from 'stream'; + +import util from './util.cjs'; + +const pkg = util.pkg; /** * TypeScript does not have this type available globally - however `@types/node` includes `undici-types`, which has it: diff --git a/src/util.cts b/src/util.cts new file mode 100644 index 00000000..9c201694 --- /dev/null +++ b/src/util.cts @@ -0,0 +1,19 @@ +// Copyright 2023 Google LLC +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +const pkg: { + name: string; + version: string; +} = require('../../../package.json'); + +export = {pkg}; diff --git a/system-test/fixtures/sample/package.json b/system-test/fixtures/sample/package.json index 41080a3b..9a683996 100644 --- a/system-test/fixtures/sample/package.json +++ b/system-test/fixtures/sample/package.json @@ -1,6 +1,7 @@ { "name": "gaxios-sample-fixture", - "description": "An app we're using to test the library. ", + "description": "An app we're using to test the library.", + "type": "commonjs", "scripts": { "check": "gts check", "clean": "gts clean", diff --git a/system-test/test.install.ts b/system-test/test.install.ts index 9f64c01a..62875dda 100644 --- a/system-test/test.install.ts +++ b/system-test/test.install.ts @@ -16,60 +16,131 @@ import assert from 'assert'; import execa from 'execa'; import fs from 'fs'; import mv from 'mv'; -import {ncp} from 'ncp'; +import ncp from 'ncp'; import path from 'path'; import tmp from 'tmp'; import {promisify} from 'util'; import {describe, it, before, after} from 'mocha'; +import {packNTest} from 'pack-n-play'; + +import {createServer, Server} from 'node:http'; + +import util from '../src/util.cjs'; + +/** + * Optionally keep the staging directory between tests. + */ +const KEEP_STAGING_DIRECTORY = false; -const keep = false; const mvp = promisify(mv) as {} as (...args: string[]) => Promise; const ncpp = promisify(ncp); -const stagingDir = tmp.dirSync({keep, unsafeCleanup: true}); -const stagingPath = stagingDir.name; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const pkg = require('../../package.json'); + +const pkg = util.pkg; describe('📦 pack and install', () => { - /** - * Create a staging directory with temp fixtures used to test on a fresh - * application. - */ - before('pack and install', async () => { - await execa('npm', ['pack']); - const tarball = `${pkg.name}-${pkg.version}.tgz`; - await mvp(tarball, `${stagingPath}/gaxios.tgz`); - await ncpp('system-test/fixtures/sample', `${stagingPath}/`); - await execa('npm', ['install'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); - }); + let stagingDir: tmp.DirResult; + let stagingPath: string; - it('should run the sample', async () => { - await execa('node', ['--throw-deprecation', 'build/src/index.js'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', + before(() => { + stagingDir = tmp.dirSync({ + keep: KEEP_STAGING_DIRECTORY, + unsafeCleanup: true, }); + stagingPath = stagingDir.name; }); - it('should be able to webpack the library', async () => { - // we expect npm install is executed in the before hook - await execa('npx', ['webpack'], { - cwd: `${stagingPath}/`, - stdio: 'inherit', - }); - const bundle = path.join(stagingPath, 'dist', 'bundle.min.js'); - const stat = fs.statSync(bundle); - assert(stat.size < 256 * 1024); - }).timeout(20000); - - /** - * CLEAN UP - remove the staging directory when done. - */ after('cleanup staging', () => { - if (!keep) { + if (!KEEP_STAGING_DIRECTORY) { stagingDir.removeCallback(); } }); + + describe('pack-n-play', () => { + let server: Server; + let url: string; + + before(async () => { + server = createServer((req, res) => { + res.writeHead(200, {'content-type': 'text/plain'}); + res.end(`Hello, ${req.headers['user-agent'] || 'World'}`); + }); + + await new Promise((resolve, reject) => { + server.on('error', reject); + server.listen(0, resolve); + }); + + const address = server.address()!; + + if (typeof address === 'string') { + url = address; + } else { + const base = new URL('http://localhost'); + base.host = address.address; + base.port = address.port.toString(); + + url = base.toString(); + } + }); + + after(() => { + server.close(); + }); + + it('supports ESM', async () => { + await packNTest({ + sample: { + description: 'import as ESM', + esm: ` + import {Gaxios} from 'gaxios'; + + const gaxios = new Gaxios(); + await gaxios.request({url: '${url}'}); + `, + }, + }); + }); + + it('supports CJS', async () => { + await packNTest({ + sample: { + description: 'require as CJS', + cjs: ` + const {Gaxios} = require('gaxios'); + + const gaxios = new Gaxios(); + gaxios.request({url: '${url}'}).then(console.log); + `, + }, + }); + }); + }); + + describe('webpack', () => { + /** + * Create a staging directory with temp fixtures used to test on a fresh + * application. + */ + before('pack and install', async () => { + await execa('npm', ['pack']); + const tarball = `${pkg.name}-${pkg.version}.tgz`; + await mvp(tarball, `${stagingPath}/gaxios.tgz`); + await ncpp('system-test/fixtures/sample', `${stagingPath}/`); + await execa('npm', ['install'], { + cwd: `${stagingPath}/`, + stdio: 'inherit', + }); + }); + + it('should be able to webpack the library', async () => { + // we expect npm install is executed in the before hook + await execa('npx', ['webpack'], { + cwd: `${stagingPath}/`, + stdio: 'inherit', + }); + const bundle = path.join(stagingPath, 'dist', 'bundle.min.js'); + const stat = fs.statSync(bundle); + assert(stat.size < 256 * 1024); + }).timeout(20000); + }); }); diff --git a/test/test.getch.ts b/test/test.getch.ts index bbf94775..e21c0e26 100644 --- a/test/test.getch.ts +++ b/test/test.getch.ts @@ -24,11 +24,14 @@ import { GaxiosOptions, GaxiosResponse, GaxiosPromise, -} from '../src'; -import {GAXIOS_ERROR_SYMBOL, GaxiosOptionsPrepared} from '../src/common'; -import {pkg} from '../src/util'; +} from '../src/index.js'; +import {GAXIOS_ERROR_SYMBOL, GaxiosOptionsPrepared} from '../src/common.js'; +import util from '../src/util.cjs'; + import fs from 'fs'; +const pkg = util.pkg; + nock.disableNetConnect(); const sandbox = sinon.createSandbox(); diff --git a/test/test.index.ts b/test/test.index.ts index de6eab4b..7f7f03e8 100644 --- a/test/test.index.ts +++ b/test/test.index.ts @@ -13,7 +13,7 @@ import assert from 'assert'; import {describe, it} from 'mocha'; -import * as main from '../src/index'; +import * as main from '../src/index.js'; describe('📝 main exports', () => { it('should export all the types', () => { diff --git a/test/test.retry.ts b/test/test.retry.ts index c8c37019..c025e336 100644 --- a/test/test.retry.ts +++ b/test/test.retry.ts @@ -14,7 +14,7 @@ import assert from 'assert'; import nock from 'nock'; import {describe, it, afterEach} from 'mocha'; -import {Gaxios, GaxiosError, GaxiosOptions, request} from '../src'; +import {Gaxios, GaxiosError, GaxiosOptions, request} from '../src/index.js'; nock.disableNetConnect(); diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 00000000..c3613ad8 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,9 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "lib": ["es2020", "dom"], + "esModuleInterop": true, + "rootDir": "." + }, + "include": ["src/*.*ts", "test/*.ts", "browser-test/*.ts", "system-test/*.ts"] +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 00000000..0829cb24 --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "module": "Node16", + "moduleResolution": "Node16", + "outDir": "build/cjs" + } +} diff --git a/tsconfig.json b/tsconfig.json index 65f327ab..da56c0c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "outDir": "build/esm", - "module": "Node16", - "moduleResolution": "Node16" + "module": "Preserve", + "outDir": "build/esm" } } From 06406ebb8beadc951d1376f8809f86b979307c6b Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Mon, 28 Oct 2024 19:17:58 -0700 Subject: [PATCH 3/9] test: fix --- test/test.getch.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/test.getch.ts b/test/test.getch.ts index e21c0e26..f583ee16 100644 --- a/test/test.getch.ts +++ b/test/test.getch.ts @@ -697,11 +697,12 @@ describe('🥁 configuration options', () => { describe('🎏 data handling', () => { it('should accpet a ReadableStream as request data', async () => { - const body = fs.createReadStream('package.json'); - // eslint-disable-next-line @typescript-eslint/no-var-requires - const contents = require('../../package.json'); - const scope = nock(url).post('/', contents).reply(200, {}); - const res = await request({url, method: 'POST', data: body}); + const scope = nock(url).post('/', 'test').reply(200, {}); + const res = await request({ + url, + method: 'POST', + data: Readable.from('test'), + }); scope.done(); assert.deepStrictEqual(res.data, {}); }); From 916aab2181f3b32ffab249659343958b273d5894 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Mon, 28 Oct 2024 19:27:12 -0700 Subject: [PATCH 4/9] docs: include `build/esm/src/` --- .jsdoc.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.jsdoc.js b/.jsdoc.js index bf72c506..d56c069b 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -22,18 +22,13 @@ module.exports = { template: './node_modules/jsdoc-fresh', recurse: true, verbose: true, - destination: './docs/' + destination: './docs/', }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], + plugins: ['plugins/markdown', 'jsdoc-region-tag'], source: { excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - ], - includePattern: '\\.js$' + include: ['build/esm/src/'], + includePattern: '\\.js$', }, templates: { copyright: 'Copyright 2019 Google, LLC.', @@ -42,10 +37,10 @@ module.exports = { systemName: 'gaxios', theme: 'lumen', default: { - outputSourceFiles: false - } + outputSourceFiles: false, + }, }, markdown: { - idInHeadings: true - } + idInHeadings: true, + }, }; From 10636b1b056af9bbf5ac2ed484a1bcfee2827ba2 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Mon, 28 Oct 2024 19:29:54 -0700 Subject: [PATCH 5/9] chore: escape fixes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 398fada3..41c33faa 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "presystem-test": "npm run compile", "system-test": "mocha build/esm/system-test --timeout 80000", "compile": "tsc -b ./tsconfig.json ./tsconfig.cjs.json", - "postcompile": "node -e 'fs.writeFileSync(`./build/esm/package.json`, JSON.stringify({type: \"module\"}))'", + "postcompile": "node -e 'fs.writeFileSync(\"./build/esm/package.json\", JSON.stringify({type: \"module\"}))'", "fix": "gts fix", "prepare": "npm run compile", "pretest": "npm run compile", From eec908eb27534887f8a0f24902388c85295ff564 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Mon, 28 Oct 2024 19:51:17 -0700 Subject: [PATCH 6/9] chore: create `utils` folder instead of inline scripting --- package.json | 2 +- utils/enable-esm.mjs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 utils/enable-esm.mjs diff --git a/package.json b/package.json index 41c33faa..ab7d8da8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "presystem-test": "npm run compile", "system-test": "mocha build/esm/system-test --timeout 80000", "compile": "tsc -b ./tsconfig.json ./tsconfig.cjs.json", - "postcompile": "node -e 'fs.writeFileSync(\"./build/esm/package.json\", JSON.stringify({type: \"module\"}))'", + "postcompile": "node utils/enable-esm.mjs", "fix": "gts fix", "prepare": "npm run compile", "pretest": "npm run compile", diff --git a/utils/enable-esm.mjs b/utils/enable-esm.mjs new file mode 100644 index 00000000..4d0f6ae6 --- /dev/null +++ b/utils/enable-esm.mjs @@ -0,0 +1,4 @@ +import fs from 'node:fs/promises'; + +// Enables all `.js` files in `build/esm` to be treated as ESM +await fs.writeFile('./build/esm/package.json', '{"type": "module"}'); From 92c510a91afb7f875c5607214327706c997e35c5 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Tue, 29 Oct 2024 14:12:44 -0700 Subject: [PATCH 7/9] docs: Suggest ESM > CJS --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0114e2f8..8b87327b 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ $ npm install gaxios ## Example ```js -const {request} = require('gaxios'); -const res = await request('https://www.googleapis.com/discovery/v1/apis/'); +import {request} from 'gaxios'; +const res = await request({url: 'https://google.com/'}); ``` ## Setting Defaults @@ -24,14 +24,16 @@ const res = await request('https://www.googleapis.com/discovery/v1/apis/'); Gaxios supports setting default properties both on the default instance, and on additional instances. This is often useful when making many requests to the same domain with the same base settings. For example: ```js -const gaxios = require('gaxios'); -gaxios.instance.defaults = { +import {request, instance} from 'gaxios'; + +instance.defaults = { baseURL: 'https://example.com' headers: { Authorization: 'SOME_TOKEN' } } -gaxios.request({url: '/data'}).then(...); + +await request({url: '/data'}); ``` Note that setting default values will take precedence From 13a79183268cafa70d953599e84eb30bd1bd734c Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Tue, 29 Oct 2024 14:13:12 -0700 Subject: [PATCH 8/9] chore: simplify `extends` import --- tsconfig.base.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index c3613ad8..31a5d2ff 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,5 +1,5 @@ { - "extends": "./node_modules/gts/tsconfig-google.json", + "extends": "gts/tsconfig-google.json", "compilerOptions": { "lib": ["es2020", "dom"], "esModuleInterop": true, From 60cd316cbd4acafd9562cd88a3bed2d091c6f656 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Wed, 30 Oct 2024 13:32:15 -0700 Subject: [PATCH 9/9] chore: combine `compile` && `postcompile` --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index ab7d8da8..e85911eb 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,7 @@ "test": "c8 mocha build/esm/test", "presystem-test": "npm run compile", "system-test": "mocha build/esm/system-test --timeout 80000", - "compile": "tsc -b ./tsconfig.json ./tsconfig.cjs.json", - "postcompile": "node utils/enable-esm.mjs", + "compile": "tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs", "fix": "gts fix", "prepare": "npm run compile", "pretest": "npm run compile",