From 4d0cf1aac81766baee08b137b78707b120f690ef Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 29 Apr 2020 17:47:40 +0200 Subject: [PATCH] chore: add `exports` field to all packages --- CHANGELOG.md | 2 ++ e2e/custom-resolver/resolver.js | 6 +----- packages/babel-jest/package.json | 11 +++++++---- packages/babel-plugin-jest-hoist/package.json | 11 +++++++---- packages/babel-preset-jest/package.json | 9 ++++++--- packages/diff-sequences/package.json | 11 +++++++---- packages/expect/package.json | 12 ++++++++---- packages/jest-changed-files/package.json | 11 +++++++---- packages/jest-circus/package.json | 12 ++++++++---- packages/jest-cli/package.json | 12 ++++++++---- packages/jest-config/package.json | 11 +++++++---- packages/jest-console/package.json | 11 +++++++---- packages/jest-core/package.json | 11 +++++++---- .../jest-create-cache-key-function/package.json | 11 +++++++---- packages/jest-diff/package.json | 11 +++++++---- packages/jest-docblock/package.json | 11 +++++++---- packages/jest-each/package.json | 11 +++++++---- packages/jest-environment-jsdom/package.json | 11 +++++++---- packages/jest-environment-node/package.json | 11 +++++++---- packages/jest-environment/package.json | 11 +++++++---- packages/jest-fake-timers/package.json | 11 +++++++---- packages/jest-get-type/package.json | 11 +++++++---- packages/jest-globals/package.json | 8 ++++++-- packages/jest-haste-map/package.json | 11 +++++++---- packages/jest-jasmine2/package.json | 11 +++++++---- packages/jest-leak-detector/package.json | 11 +++++++---- packages/jest-matcher-utils/package.json | 11 +++++++---- packages/jest-message-util/package.json | 11 +++++++---- packages/jest-mock/package.json | 11 +++++++---- packages/jest-phabricator/package.json | 11 +++++++---- packages/jest-regex-util/package.json | 11 +++++++---- packages/jest-repl/package.json | 12 ++++++++---- packages/jest-reporters/package.json | 11 +++++++---- packages/jest-resolve-dependencies/package.json | 11 +++++++---- packages/jest-resolve/package.json | 11 +++++++---- packages/jest-runner/package.json | 11 +++++++---- packages/jest-runtime/package.json | 12 ++++++++---- packages/jest-serializer/package.json | 11 +++++++---- packages/jest-snapshot/package.json | 11 +++++++---- packages/jest-snapshot/src/printSnapshot.ts | 1 + packages/jest-source-map/package.json | 11 +++++++---- packages/jest-test-result/package.json | 11 +++++++---- packages/jest-test-sequencer/package.json | 11 +++++++---- packages/jest-transform/package.json | 11 +++++++---- packages/jest-types/package.json | 11 +++++++---- packages/jest-util/package.json | 11 +++++++---- packages/jest-validate/package.json | 11 +++++++---- packages/jest-watcher/package.json | 11 +++++++---- packages/jest-worker/package.json | 11 +++++++---- packages/jest/package.json | 12 ++++++++---- packages/pretty-format/package.json | 11 +++++++---- packages/test-utils/package.json | 8 ++++++-- scripts/buildUtils.js | 17 +++++++++++++++++ 53 files changed, 367 insertions(+), 196 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a42439c24887..a1af45e7164c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Chore & Maintenance +- `[*]` [**BREAKING**] Add `exports` field to all `package.json`s ([#9921](https://github.com/facebook/jest/pull/9921)) + ### Performance ## 26.6.2 diff --git a/e2e/custom-resolver/resolver.js b/e2e/custom-resolver/resolver.js index 13f64c0d2a4a..c84e87938a14 100644 --- a/e2e/custom-resolver/resolver.js +++ b/e2e/custom-resolver/resolver.js @@ -5,10 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -const { - default: defaultResolver, -} = require('jest-resolve/build/defaultResolver'); - const exportedModules = new Map([ ['foo', 'foo'], ['bar', 'bar'], @@ -20,6 +16,6 @@ module.exports = (name, options) => { if (resolution) { return `${__dirname}/${resolution}.js`; } else { - return defaultResolver(name, options); + return options.defaultResolver(name, options); } }; diff --git a/packages/babel-jest/package.json b/packages/babel-jest/package.json index 9c565c153363..128ad5af4d49 100644 --- a/packages/babel-jest/package.json +++ b/packages/babel-jest/package.json @@ -8,8 +8,12 @@ "directory": "packages/babel-jest" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/transform": "^26.6.2", "@jest/types": "^26.6.2", @@ -33,6 +37,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/babel-plugin-jest-hoist/package.json b/packages/babel-plugin-jest-hoist/package.json index 6b9c68659920..67e30ee37b12 100644 --- a/packages/babel-plugin-jest-hoist/package.json +++ b/packages/babel-plugin-jest-hoist/package.json @@ -10,8 +10,12 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@babel/template": "^7.3.3", "@babel/types": "^7.3.3", @@ -29,6 +33,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/babel-preset-jest/package.json b/packages/babel-preset-jest/package.json index 62c8b6c31c5c..7e51004a539f 100644 --- a/packages/babel-preset-jest/package.json +++ b/packages/babel-preset-jest/package.json @@ -7,7 +7,11 @@ "directory": "packages/babel-preset-jest" }, "license": "MIT", - "main": "index.js", + "main": "./index.js", + "exports": { + ".": "./index.js", + "./package.json": "./package.json" + }, "dependencies": { "babel-plugin-jest-hoist": "^26.6.2", "babel-preset-current-node-syntax": "^1.0.0" @@ -20,6 +24,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/diff-sequences/package.json b/packages/diff-sequences/package.json index 011217b3c285..33cce9606b9c 100644 --- a/packages/diff-sequences/package.json +++ b/packages/diff-sequences/package.json @@ -18,8 +18,12 @@ "engines": { "node": ">= 10.14.2" }, - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "scripts": { "perf": "node --expose-gc perf/index.js" }, @@ -30,6 +34,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/expect/package.json b/packages/expect/package.json index 239dcee15248..5e1e23b950e1 100644 --- a/packages/expect/package.json +++ b/packages/expect/package.json @@ -7,8 +7,13 @@ "directory": "packages/expect" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json", + "./build/utils": "./build/utils.js" + }, "dependencies": { "@jest/types": "^26.6.2", "ansi-styles": "^4.0.0", @@ -28,6 +33,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-changed-files/package.json b/packages/jest-changed-files/package.json index a9f62a5e3944..9cb757e442a2 100644 --- a/packages/jest-changed-files/package.json +++ b/packages/jest-changed-files/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-changed-files" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "execa": "^4.0.0", @@ -19,6 +23,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index d07c8c06f5be..b02f546472f7 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -7,8 +7,13 @@ "directory": "packages/jest-circus" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json", + "./runner": "./runner.js" + }, "dependencies": { "@babel/traverse": "^7.1.0", "@jest/environment": "^26.6.2", @@ -50,6 +55,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index 65498ca31163..316359deabc6 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -2,8 +2,13 @@ "name": "jest-cli", "description": "Delightful JavaScript Testing.", "version": "26.6.2", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json", + "./bin/jest": "./bin/jest.js" + }, "dependencies": { "@jest/core": "^26.6.2", "@jest/test-result": "^26.6.2", @@ -71,6 +76,5 @@ ], "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 218bb154c054..3ae90fe4b6d2 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-config" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "peerDependencies": { "ts-node": ">=9.0.0" }, @@ -50,6 +54,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-console/package.json b/packages/jest-console/package.json index 1e990d7e1320..5b4e836b73d6 100644 --- a/packages/jest-console/package.json +++ b/packages/jest-console/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-console" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "@types/node": "*", @@ -26,6 +30,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 90dcfc564fd8..ed17b4720391 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -2,8 +2,12 @@ "name": "@jest/core", "description": "Delightful JavaScript Testing.", "version": "26.6.2", - "main": "build/jest.js", - "types": "build/jest.d.ts", + "main": "./build/jest.js", + "types": "./build/jest.d.ts", + "exports": { + ".": "./build/jest.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/console": "^26.6.2", "@jest/reporters": "^26.6.2", @@ -84,6 +88,5 @@ ], "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-create-cache-key-function/package.json b/packages/jest-create-cache-key-function/package.json index 904e9a44b1d6..03e6d01b6745 100644 --- a/packages/jest-create-cache-key-function/package.json +++ b/packages/jest-create-cache-key-function/package.json @@ -16,10 +16,13 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-diff/package.json b/packages/jest-diff/package.json index 2c90b4bbb71c..720183e47385 100644 --- a/packages/jest-diff/package.json +++ b/packages/jest-diff/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-diff" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "chalk": "^4.0.0", "diff-sequences": "^26.6.2", @@ -24,6 +28,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-docblock/package.json b/packages/jest-docblock/package.json index 49bb6d46c723..2c1f6dcc502b 100644 --- a/packages/jest-docblock/package.json +++ b/packages/jest-docblock/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-docblock" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "detect-newline": "^3.0.0" }, @@ -20,6 +24,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-each/package.json b/packages/jest-each/package.json index daa428307661..0516b414504c 100644 --- a/packages/jest-each/package.json +++ b/packages/jest-each/package.json @@ -2,8 +2,12 @@ "name": "jest-each", "version": "26.6.2", "description": "Parameterised tests for Jest", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "repository": { "type": "git", "url": "https://github.com/facebook/jest.git", @@ -29,6 +33,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index 5322b3f3e009..29f0555d9f1b 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-environment-jsdom" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/environment": "^26.6.2", "@jest/fake-timers": "^26.6.2", @@ -27,6 +31,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-environment-node/package.json b/packages/jest-environment-node/package.json index 85e14a2ce09f..7e99b972d771 100644 --- a/packages/jest-environment-node/package.json +++ b/packages/jest-environment-node/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-environment-node" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/environment": "^26.6.2", "@jest/fake-timers": "^26.6.2", @@ -25,6 +29,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json index 955d0388b771..e05688134484 100644 --- a/packages/jest-environment/package.json +++ b/packages/jest-environment/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-environment" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/fake-timers": "^26.6.2", "@jest/types": "^26.6.2", @@ -20,6 +24,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-fake-timers/package.json b/packages/jest-fake-timers/package.json index 5c3d132012ee..d97ccd8555b1 100644 --- a/packages/jest-fake-timers/package.json +++ b/packages/jest-fake-timers/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-fake-timers" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "@sinonjs/fake-timers": "^6.0.1", @@ -26,6 +30,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-get-type/package.json b/packages/jest-get-type/package.json index 8f82ed5b44f8..0498eac92f9a 100644 --- a/packages/jest-get-type/package.json +++ b/packages/jest-get-type/package.json @@ -11,10 +11,13 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-globals/package.json b/packages/jest-globals/package.json index e7c04e2bd5bd..cffde23215cb 100644 --- a/packages/jest-globals/package.json +++ b/packages/jest-globals/package.json @@ -10,8 +10,12 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/environment": "^26.6.2", "@jest/types": "^26.6.2", diff --git a/packages/jest-haste-map/package.json b/packages/jest-haste-map/package.json index 535b54d669e6..9f8b523bf75e 100644 --- a/packages/jest-haste-map/package.json +++ b/packages/jest-haste-map/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-haste-map" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "@types/graceful-fs": "^4.1.2", @@ -41,6 +45,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-jasmine2/package.json b/packages/jest-jasmine2/package.json index 36fa8621eba8..0176a1303137 100644 --- a/packages/jest-jasmine2/package.json +++ b/packages/jest-jasmine2/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-jasmine2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@babel/traverse": "^7.1.0", "@jest/environment": "^26.6.2", @@ -38,6 +42,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-leak-detector/package.json b/packages/jest-leak-detector/package.json index 63e93fe836f1..25df0fd0d5f2 100644 --- a/packages/jest-leak-detector/package.json +++ b/packages/jest-leak-detector/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-leak-detector" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "jest-get-type": "^26.3.0", "pretty-format": "^26.6.2" @@ -22,6 +26,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-matcher-utils/package.json b/packages/jest-matcher-utils/package.json index 3edfea85e108..1cf2a644caf2 100644 --- a/packages/jest-matcher-utils/package.json +++ b/packages/jest-matcher-utils/package.json @@ -11,8 +11,12 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "chalk": "^4.0.0", "jest-diff": "^26.6.2", @@ -25,6 +29,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-message-util/package.json b/packages/jest-message-util/package.json index 69672f77e6cd..f5b8f75c4fbe 100644 --- a/packages/jest-message-util/package.json +++ b/packages/jest-message-util/package.json @@ -10,8 +10,12 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@babel/code-frame": "^7.0.0", "@jest/types": "^26.6.2", @@ -30,6 +34,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-mock/package.json b/packages/jest-mock/package.json index 9852044b9634..87f2dd8567e6 100644 --- a/packages/jest-mock/package.json +++ b/packages/jest-mock/package.json @@ -14,10 +14,13 @@ "@types/node": "*" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-phabricator/package.json b/packages/jest-phabricator/package.json index d19b542aed7e..80249bb6b211 100644 --- a/packages/jest-phabricator/package.json +++ b/packages/jest-phabricator/package.json @@ -6,7 +6,11 @@ "url": "https://github.com/facebook/jest.git", "directory": "packages/jest-phabricator" }, - "types": "build/index.d.ts", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/test-result": "^26.6.2" }, @@ -14,9 +18,8 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", + "main": "./build/index.js", "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-regex-util/package.json b/packages/jest-regex-util/package.json index 0886157f4865..43158cbb15b5 100644 --- a/packages/jest-regex-util/package.json +++ b/packages/jest-regex-util/package.json @@ -13,10 +13,13 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-repl/package.json b/packages/jest-repl/package.json index ffe078571f14..ce5d369ec0ff 100644 --- a/packages/jest-repl/package.json +++ b/packages/jest-repl/package.json @@ -7,8 +7,13 @@ "directory": "packages/jest-repl" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json", + "./bin/jest-repl": "./bin/jest-repl.js" + }, "dependencies": { "@jest/transform": "^26.6.2", "@jest/types": "^26.6.2", @@ -28,6 +33,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-reporters/package.json b/packages/jest-reporters/package.json index 15021ce44df9..c07af82d6de4 100644 --- a/packages/jest-reporters/package.json +++ b/packages/jest-reporters/package.json @@ -2,8 +2,12 @@ "name": "@jest/reporters", "description": "Jest's reporters", "version": "26.6.2", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@bcoe/v8-coverage": "^0.2.3", "@jest/console": "^26.6.2", @@ -62,6 +66,5 @@ "license": "MIT", "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-resolve-dependencies/package.json b/packages/jest-resolve-dependencies/package.json index a41cc693682b..47bfa352276f 100644 --- a/packages/jest-resolve-dependencies/package.json +++ b/packages/jest-resolve-dependencies/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-resolve-dependencies" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "jest-regex-util": "^26.0.0", @@ -25,6 +29,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-resolve/package.json b/packages/jest-resolve/package.json index f989f5df4c22..e46b600388a9 100644 --- a/packages/jest-resolve/package.json +++ b/packages/jest-resolve/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-resolve" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "chalk": "^4.0.0", @@ -29,6 +33,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json index 892940e47057..9527ee04d7cf 100644 --- a/packages/jest-runner/package.json +++ b/packages/jest-runner/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-runner" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/console": "^26.6.2", "@jest/environment": "^26.6.2", @@ -42,6 +46,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-runtime/package.json b/packages/jest-runtime/package.json index aa86ba5c4caf..17e183e7d714 100644 --- a/packages/jest-runtime/package.json +++ b/packages/jest-runtime/package.json @@ -7,8 +7,13 @@ "directory": "packages/jest-runtime" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json", + "./bin/jest-runtime": "./bin/jest-runtime.js" + }, "dependencies": { "@jest/console": "^26.6.2", "@jest/environment": "^26.6.2", @@ -54,6 +59,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-serializer/package.json b/packages/jest-serializer/package.json index ff39cd75deec..37e0851ed348 100644 --- a/packages/jest-serializer/package.json +++ b/packages/jest-serializer/package.json @@ -17,10 +17,13 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-snapshot/package.json b/packages/jest-snapshot/package.json index 4cc7a60e2176..b51f495ef69f 100644 --- a/packages/jest-snapshot/package.json +++ b/packages/jest-snapshot/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-snapshot" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@babel/types": "^7.0.0", "@jest/types": "^26.6.2", @@ -42,6 +46,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-snapshot/src/printSnapshot.ts b/packages/jest-snapshot/src/printSnapshot.ts index 2cb0732027b3..cae43b41ebf5 100644 --- a/packages/jest-snapshot/src/printSnapshot.ts +++ b/packages/jest-snapshot/src/printSnapshot.ts @@ -11,6 +11,7 @@ import chalk = require('chalk'); // Temporary hack because getObjectSubset has known limitations, // is not in the public interface of the expect package, // and the long-term goal is to use a non-serialization diff. +// Make sure to remove file from `exports` in `expect/package.json`. import {getObjectSubset} from 'expect/build/utils'; import { DIFF_DELETE, diff --git a/packages/jest-source-map/package.json b/packages/jest-source-map/package.json index 053b4a134767..ebe25370e88c 100644 --- a/packages/jest-source-map/package.json +++ b/packages/jest-source-map/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-source-map" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "callsites": "^3.0.0", "graceful-fs": "^4.2.4", @@ -22,6 +26,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-test-result/package.json b/packages/jest-test-result/package.json index 895a4546278d..2a751f9e5f75 100644 --- a/packages/jest-test-result/package.json +++ b/packages/jest-test-result/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-test-result" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/console": "^26.6.2", "@jest/types": "^26.6.2", @@ -20,6 +24,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-test-sequencer/package.json b/packages/jest-test-sequencer/package.json index 2107d2cccc30..e2f9232aa990 100644 --- a/packages/jest-test-sequencer/package.json +++ b/packages/jest-test-sequencer/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-test-sequencer" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/test-result": "^26.6.2", "graceful-fs": "^4.2.4", @@ -24,6 +28,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-transform/package.json b/packages/jest-transform/package.json index 97b3f9a43312..828e040d4732 100644 --- a/packages/jest-transform/package.json +++ b/packages/jest-transform/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-transform" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@babel/core": "^7.1.0", "@jest/types": "^26.6.2", @@ -42,6 +46,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-types/package.json b/packages/jest-types/package.json index 30b59d905514..60795fc01191 100644 --- a/packages/jest-types/package.json +++ b/packages/jest-types/package.json @@ -10,8 +10,12 @@ "node": ">= 10.14.2" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", @@ -21,6 +25,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 774976a9aec7..dfe0074319ce 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-util" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "@types/node": "*", @@ -27,6 +31,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-validate/package.json b/packages/jest-validate/package.json index 6b837ddd24ad..fe4dfa39fc0f 100644 --- a/packages/jest-validate/package.json +++ b/packages/jest-validate/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-validate" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "camelcase": "^6.0.0", @@ -25,6 +29,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-watcher/package.json b/packages/jest-watcher/package.json index d467b6504985..e032557fa6d9 100644 --- a/packages/jest-watcher/package.json +++ b/packages/jest-watcher/package.json @@ -2,8 +2,12 @@ "name": "jest-watcher", "description": "Delightful JavaScript Testing.", "version": "26.6.2", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/test-result": "^26.6.2", "@jest/types": "^26.6.2", @@ -28,6 +32,5 @@ "license": "MIT", "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest-worker/package.json b/packages/jest-worker/package.json index 4711fb3fce2e..5ef9176cc178 100644 --- a/packages/jest-worker/package.json +++ b/packages/jest-worker/package.json @@ -7,8 +7,12 @@ "directory": "packages/jest-worker" }, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@types/node": "*", "merge-stream": "^2.0.0", @@ -25,6 +29,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/jest/package.json b/packages/jest/package.json index fa6d2c3bcc55..88966416b150 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -2,8 +2,13 @@ "name": "jest", "description": "Delightful JavaScript Testing.", "version": "26.6.2", - "main": "build/jest.js", - "types": "build/jest.d.ts", + "main": "./build/jest.js", + "types": "./build/jest.d.ts", + "exports": { + ".": "./build/jest.js", + "./package.json": "./package.json", + "./bin/jest": "./bin/jest.js" + }, "dependencies": { "@jest/core": "^26.6.2", "import-local": "^3.0.2", @@ -47,6 +52,5 @@ ], "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index ebe330375b05..d12a4750904e 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -8,8 +8,12 @@ }, "license": "MIT", "description": "Stringify any JavaScript value.", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "author": "James Kyle ", "dependencies": { "@jest/types": "^26.6.2", @@ -32,6 +36,5 @@ }, "publishConfig": { "access": "public" - }, - "gitHead": "170eee11d03b0ed5c60077982fdbc3bafd403638" + } } diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index d9a0f51e85e4..308118e78671 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -3,8 +3,12 @@ "version": "26.6.2", "private": true, "license": "MIT", - "main": "build/index.js", - "types": "build/index.d.ts", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": "./build/index.js", + "./package.json": "./package.json" + }, "dependencies": { "@jest/types": "^26.6.2", "@types/jest": "*", diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index 979636c24016..df0ba0e61c3a 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -42,6 +42,23 @@ module.exports.getPackages = function getPackages() { : nodeEngineRequirement, `Engine requirement in ${pkg.name} should match root`, ); + + assert.ok(pkg.exports, `Package ${pkg.name} is missing \`exports\` field`); + assert.deepStrictEqual( + pkg.exports, + { + '.': pkg.main, + './package.json': './package.json', + ...Object.values(pkg.bin || {}).reduce( + (mem, curr) => + Object.assign(mem, {[curr.replace(/\.js$/, '')]: curr}), + {}, + ), + ...(pkg.name === 'jest-circus' ? {'./runner': './runner.js'} : {}), + ...(pkg.name === 'expect' ? {'./build/utils': './build/utils.js'} : {}), + }, + `Package ${pkg.name} does not export correct files`, + ); }); return packages;