diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eb466ffdd77..a82011774c0b 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-repl]` Make module importable ([#12311](https://github.com/facebook/jest/pull/12311)) ### Chore & Maintenance diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index 3d09b2b15b1f..c2512a662ee7 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/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", diff --git a/scripts/build.js b/scripts/build.js index 576474296a13..9a1d99c0cdd6 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -20,6 +20,7 @@ 'use strict'; +const assert = require('assert'); const fs = require('fs'); const path = require('path'); const babel = require('@babel/core'); @@ -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`); } @@ -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); }