Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: point to correctly exported files in jest-repl #12311

Merged
merged 2 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### 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))

### Chore & Maintenance

Expand Down
8 changes: 4 additions & 4 deletions packages/jest-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"directory": "packages/jest-repl"
},
"license": "MIT",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"main": "./build/cli/index.js",
"types": "./build/cli/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
"types": "./build/cli/index.d.ts",
"default": "./build/cli/index.js"
},
"./package.json": "./package.json",
"./bin/jest-repl": "./bin/jest-repl.js",
Expand Down
14 changes: 10 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

'use strict';

const assert = require('assert');
const fs = require('fs');
const path = require('path');
const babel = require('@babel/core');
Expand Down Expand Up @@ -56,15 +57,20 @@ function getBuildPath(file, buildFolder) {
return path.resolve(pkgBuildPath, relativeToSrcPath).replace(/\.ts$/, '.js');
}

function buildNodePackage(p) {
const srcDir = path.resolve(p, SRC_DIR);
function buildNodePackage({packageDir, pkg}) {
const srcDir = path.resolve(packageDir, SRC_DIR);
const pattern = path.resolve(srcDir, '**/*');
const files = glob.sync(pattern, {nodir: true});

process.stdout.write(adjustToTerminalWidth(`${path.basename(p)}\n`));
process.stdout.write(adjustToTerminalWidth(`${pkg.name}\n`));

files.forEach(file => buildFile(file, true));

assert.ok(
fs.existsSync(path.resolve(packageDir, pkg.main)),
`Main file "${pkg.main}" in ${pkg.name} should exist`,
);

process.stdout.write(`${OK}\n`);
}

Expand Down Expand Up @@ -142,5 +148,5 @@ if (files.length) {
} else {
const packages = getPackages();
process.stdout.write(chalk.inverse(' Building packages \n'));
packages.map(({packageDir}) => packageDir).forEach(buildNodePackage);
packages.forEach(buildNodePackage);
}