From 2fb7aa9bb5cc7b4fcea5319c5573f685fa0c0f57 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 8 Feb 2022 09:32:46 +0100 Subject: [PATCH] chore: ensure all exported files have a consistent filename --- CHANGELOG.md | 2 ++ packages/jest-core/package.json | 8 ++++---- packages/jest-core/src/{jest.ts => index.ts} | 0 packages/jest/package.json | 8 ++++---- packages/jest/src/{jest.ts => index.ts} | 0 scripts/buildUtils.js | 19 +++++++++++++++++++ 6 files changed, 29 insertions(+), 8 deletions(-) rename packages/jest-core/src/{jest.ts => index.ts} (100%) rename packages/jest/src/{jest.ts => index.ts} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88e1df1ab09c..45f215642604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ### Chore & Maintenance - `[*]` [**BREAKING**] Drop support for Node v10 and v15 and target first LTS `16.13.0` ([#12220](https://github.com/facebook/jest/pull/12220)) +- `[@jest/core]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329)) +- `[jest]` Use `index.ts` instead of `jest.ts` as main export ([#12329](https://github.com/facebook/jest/pull/12329)) ### Performance diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 36d372064557..cf37a0bd46c4 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -2,12 +2,12 @@ "name": "@jest/core", "description": "Delightful JavaScript Testing.", "version": "27.5.1", - "main": "./build/jest.js", - "types": "./build/jest.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", "exports": { ".": { - "types": "./build/jest.d.ts", - "default": "./build/jest.js" + "types": "./build/index.d.ts", + "default": "./build/index.js" }, "./package.json": "./package.json" }, diff --git a/packages/jest-core/src/jest.ts b/packages/jest-core/src/index.ts similarity index 100% rename from packages/jest-core/src/jest.ts rename to packages/jest-core/src/index.ts diff --git a/packages/jest/package.json b/packages/jest/package.json index e03d8287cd05..c3c8b1af8825 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -2,12 +2,12 @@ "name": "jest", "description": "Delightful JavaScript Testing.", "version": "27.5.1", - "main": "./build/jest.js", - "types": "./build/jest.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", "exports": { ".": { - "types": "./build/jest.d.ts", - "default": "./build/jest.js" + "types": "./build/index.d.ts", + "default": "./build/index.js" }, "./package.json": "./package.json", "./bin/jest": "./bin/jest.js" diff --git a/packages/jest/src/jest.ts b/packages/jest/src/index.ts similarity index 100% rename from packages/jest/src/jest.ts rename to packages/jest/src/index.ts diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index b645f5ac8531..2b5e7eba7cdf 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -74,6 +74,25 @@ module.exports.getPackages = function getPackages() { `Package "${pkg.name}" does not export correct files`, ); + if (pkg.types) { + assert.strictEqual( + pkg.main, + './build/index.js', + `Package "${pkg.name}" should have "./build/index.js" as main`, + ); + assert.strictEqual( + pkg.types, + './build/index.d.ts', + `Package "${pkg.name}" should have "./build/index.d.ts" as types`, + ); + } else { + assert.strictEqual( + pkg.main, + './index.js', + `Package "${pkg.name}" should have "./index.js" as main`, + ); + } + if (pkg.bin) { Object.entries(pkg.bin).forEach(([binName, binPath]) => { const fullBinPath = path.resolve(packageDir, binPath);