Skip to content

Commit

Permalink
fix: point to correctly exported files in jest-repl (#12311)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Feb 6, 2022
1 parent e0f3d16 commit 47c7a5b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
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);
}

0 comments on commit 47c7a5b

Please sign in to comment.