Skip to content

Commit 0666f8d

Browse files
committed
deal with entry points [skip ci]
1 parent 568ff17 commit 0666f8d

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

packages/jest-circus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"default": "./build/index.js"
1616
},
1717
"./package.json": "./package.json",
18-
"./runner": "./runner.js"
18+
"./runner": "./build/runner.js"
1919
},
2020
"dependencies": {
2121
"@jest/environment": "^28.0.2",
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
*/
77

88
// Allow people to use `jest-circus/runner` as a runner.
9-
const runner = require('./build/legacy-code-todo-rewrite/jestAdapter').default;
10-
module.exports = runner;
9+
import runner from './legacy-code-todo-rewrite/jestAdapter';
10+
11+
export default runner;

packages/pretty-format/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"default": "./build/index.js"
1717
},
1818
"./package.json": "./package.json",
19-
"./ConvertAnsi": "./build/plugins/ConvertAnsi.js"
19+
"./ConvertAnsi": "./build/ConvertAnsi.js"
2020
},
2121
"author": "James Kyle <me@thejameskyle.com>",
2222
"dependencies": {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
export {test, serialize} from './plugins/ConvertAnsi';

scripts/buildUtils.mjs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ export function getPackages() {
6767
Object.assign(mem, {[curr.replace(/\.js$/, '')]: curr}),
6868
{},
6969
),
70-
...(pkg.name === 'jest-circus' ? {'./runner': './runner.js'} : {}),
70+
...(pkg.name === 'jest-circus' ? {'./runner': './build/runner.js'} : {}),
7171
...(pkg.name === 'expect'
7272
? {'./build/matchers': './build/matchers.js'}
7373
: {}),
7474
...(pkg.name === 'pretty-format'
75-
? {'./ConvertAnsi': './build/plugins/ConvertAnsi.js'}
75+
? {'./ConvertAnsi': './build/ConvertAnsi.js'}
7676
: {}),
7777
},
7878
`Package "${pkg.name}" does not export correct files`,
@@ -159,7 +159,7 @@ export function createWebpackConfigs() {
159159
});
160160
}
161161

162-
const extraEntries =
162+
const workerEntriesEntries =
163163
pkg.name === 'jest-worker'
164164
? {
165165
processChild: path.resolve(
@@ -179,14 +179,38 @@ export function createWebpackConfigs() {
179179
? {testWorker: path.resolve(packageDir, './src/testWorker.ts')}
180180
: {};
181181

182+
const extraEntryPoints =
183+
// skip expect for now
184+
pkg.name === 'expect'
185+
? {}
186+
: Object.keys(pkg.exports)
187+
.filter(
188+
key =>
189+
key !== '.' &&
190+
key !== './package.json' &&
191+
!key.startsWith('./bin'),
192+
)
193+
.reduce((previousValue, currentValue) => {
194+
return {
195+
...previousValue,
196+
// skip `./`
197+
[currentValue.slice(2)]: path.resolve(
198+
packageDir,
199+
'./src',
200+
`${currentValue}.ts`,
201+
),
202+
};
203+
}, {});
204+
182205
return {
183206
packageDir,
184207
pkg,
185208
webpackConfig: {
186209
devtool: false,
187210
entry: {
188211
index: input,
189-
...extraEntries,
212+
...workerEntriesEntries,
213+
...extraEntryPoints,
190214
},
191215
externals: nodeExternals(),
192216
mode: 'production',
@@ -208,7 +232,7 @@ export function createWebpackConfigs() {
208232
},
209233
path: path.resolve(packageDir, 'build'),
210234
},
211-
plugins: [new IgnoreDynamicRequire(extraEntries)],
235+
plugins: [new IgnoreDynamicRequire(workerEntriesEntries)],
212236
resolve: {
213237
extensions: ['.ts', '.js'],
214238
},

0 commit comments

Comments
 (0)