Skip to content

Commit

Permalink
fix: binary scripts should use package exports (#12315)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 7, 2022
1 parent a9b7e8a commit 3a7e1c9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -7,7 +7,8 @@
### Fixes

- `[expect]` Add type definitions for asymmetric `closeTo` matcher ([#12304](https://github.com/facebook/jest/pull/12304))
- `[jest-repl]` Make module importable ([#12311](https://github.com/facebook/jest/pull/12311))
- `[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) & [#12315](https://github.com/facebook/jest/pull/12315))

### Chore & Maintenance

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/bin/jest.js
Expand Up @@ -13,5 +13,5 @@ if (!importLocal(__filename)) {
process.env.NODE_ENV = 'test';
}

require('../build/cli').run();
require('..').run();
}
2 changes: 1 addition & 1 deletion packages/jest-repl/bin/jest-repl.js
Expand Up @@ -10,4 +10,4 @@ if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}

require('../build/cli')();
require('..').repl();
2 changes: 1 addition & 1 deletion packages/jest-repl/bin/jest-runtime-cli.js
Expand Up @@ -10,4 +10,4 @@ if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'test';
}

require('../build/cli/runtime-cli').run();
require('..').runtime();
8 changes: 4 additions & 4 deletions packages/jest-repl/package.json
Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions 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';

0 comments on commit 3a7e1c9

Please sign in to comment.