diff --git a/.env b/.env new file mode 100644 index 0000000..32c1811 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +# https://github.com/webpack/webpack/issues/14532 +NODE_OPTIONS=--openssl-legacy-provider diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b0963a..4189143 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,11 +33,7 @@ jobs: run: pnpm build - name: Test - env: - # This can't be added to the package.json script because we also test Node.js v16 - # https://github.com/webpack/webpack/issues/14532 - NODE_OPTIONS: --openssl-legacy-provider run: pnpm test - name: Test Node.js v16 - run: pnpm --use-node-version=16.19.0 test + run: pnpm --use-node-version=16.19.0 tsx tests diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..3bd3b7d --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +shell-emulator=true diff --git a/package.json b/package.json index 9410c18..9273791 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ }, "scripts": { "build": "pkgroll --target=node16.19.0", - "test": "tsx tests", - "dev": "tsx watch --conditions=development tests", + "test": "tsx --env-file=.env tests", + "dev": "tsx watch --env-file=.env --conditions=development tests", "lint": "lintroll --cache .", "type-check": "tsc --noEmit", "prepack": "pnpm build && clean-pkg-json" diff --git a/tests/specs/tsconfig.ts b/tests/specs/tsconfig.ts index e517a10..57e6a28 100644 --- a/tests/specs/tsconfig.ts +++ b/tests/specs/tsconfig.ts @@ -5,6 +5,8 @@ import { createFixture } from 'fs-fixture'; import { execa } from 'execa'; import { tsconfigJson } from '../utils.js'; +const require = createRequire(import.meta.url); + const webpackCli = path.resolve('node_modules/webpack-cli/bin/cli.js'); const esbuildLoader = path.resolve('dist/index.cjs'); @@ -73,7 +75,6 @@ export default testSuite(({ describe }) => { cwd: fixture.path, }); - const require = createRequire(import.meta.url); expect( require(path.join(fixture.path, 'dist/main.js')), ).toStrictEqual([true, false, true]); @@ -127,7 +128,6 @@ export default testSuite(({ describe }) => { cwd: fixture.path, }); - const require = createRequire(import.meta.url); expect( require(path.join(fixture.path, 'dist/main.js')), ).toStrictEqual([true, false]); @@ -186,7 +186,6 @@ export default testSuite(({ describe }) => { expect(stdout).toMatch('does not match its "include" patterns'); - const require = createRequire(import.meta.url); expect( require(path.join(fixture.path, 'dist/main.js')), ).toStrictEqual([true, true]);