From 0443ccbf8f26fa1c00f52153ed28bb0c0550ad48 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 7 Feb 2022 02:06:42 +0100 Subject: [PATCH 1/3] fix: binary scripts should use package exports --- packages/jest-cli/bin/jest.js | 2 +- packages/jest-repl/bin/jest-repl.js | 2 +- packages/jest-repl/bin/jest-runtime-cli.js | 2 +- packages/jest-repl/package.json | 8 ++++---- packages/jest-repl/src/index.ts | 11 +++++++++++ 5 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 packages/jest-repl/src/index.ts diff --git a/packages/jest-cli/bin/jest.js b/packages/jest-cli/bin/jest.js index fc6308c8d2cf..146fb2c4019b 100755 --- a/packages/jest-cli/bin/jest.js +++ b/packages/jest-cli/bin/jest.js @@ -13,5 +13,5 @@ if (!importLocal(__filename)) { process.env.NODE_ENV = 'test'; } - require('../build/cli').run(); + require('..').run(); } diff --git a/packages/jest-repl/bin/jest-repl.js b/packages/jest-repl/bin/jest-repl.js index 36b7a229fd58..3a2251a559dd 100755 --- a/packages/jest-repl/bin/jest-repl.js +++ b/packages/jest-repl/bin/jest-repl.js @@ -10,4 +10,4 @@ if (process.env.NODE_ENV == null) { process.env.NODE_ENV = 'test'; } -require('../build/cli')(); +require('..').repl(); diff --git a/packages/jest-repl/bin/jest-runtime-cli.js b/packages/jest-repl/bin/jest-runtime-cli.js index c54353904cd7..ebbbcb649f36 100755 --- a/packages/jest-repl/bin/jest-runtime-cli.js +++ b/packages/jest-repl/bin/jest-runtime-cli.js @@ -10,4 +10,4 @@ if (process.env.NODE_ENV == null) { process.env.NODE_ENV = 'test'; } -require('../build/cli/runtime-cli').run(); +require('..').runtime(); diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index c2512a662ee7..3d09b2b15b1f 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -7,12 +7,12 @@ "directory": "packages/jest-repl" }, "license": "MIT", - "main": "./build/cli/index.js", - "types": "./build/cli/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", "exports": { ".": { - "types": "./build/cli/index.d.ts", - "default": "./build/cli/index.js" + "types": "./build/index.d.ts", + "default": "./build/index.js" }, "./package.json": "./package.json", "./bin/jest-repl": "./bin/jest-repl.js", diff --git a/packages/jest-repl/src/index.ts b/packages/jest-repl/src/index.ts new file mode 100644 index 000000000000..adf5259d1e22 --- /dev/null +++ b/packages/jest-repl/src/index.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import replImport = require('./cli'); + +export const repl = replImport; +export {run as runtime} from './cli/runtime-cli'; From 87d7c07c0d9e8b4c2ed795ea6a59524396db6447 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 7 Feb 2022 02:08:36 +0100 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1b0ebf8c0e8..e5abf57a1821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Fixes - `[expect]` Add type definitions for asymmetric `closeTo` matcher ([#12304](https://github.com/facebook/jest/pull/12304)) +- `[jest-cli]` Load binary via exported API ([#12315](https://github.com/facebook/jest/pull/12315)) - `[jest-repl]` Make module importable ([#12311](https://github.com/facebook/jest/pull/12311)) ### Chore & Maintenance From c5b34df1785cea5355007e9707a4adc95866961e Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 7 Feb 2022 02:10:26 +0100 Subject: [PATCH 3/3] moar changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5abf57a1821..40815a393f3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ - `[expect]` Add type definitions for asymmetric `closeTo` matcher ([#12304](https://github.com/facebook/jest/pull/12304)) - `[jest-cli]` Load binary via exported API ([#12315](https://github.com/facebook/jest/pull/12315)) -- `[jest-repl]` Make module importable ([#12311](https://github.com/facebook/jest/pull/12311)) +- `[jest-repl]` Make module importable ([#12311](https://github.com/facebook/jest/pull/12311) & [#12315](https://github.com/facebook/jest/pull/12315)) ### Chore & Maintenance