Skip to content

Commit 0d5fc17

Browse files
committed
deal with entry points [skip ci]
1 parent 0737ce4 commit 0d5fc17

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

packages/jest-circus/package.json

+1-1
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.0-alpha.8",

packages/jest-circus/runner.js packages/jest-circus/src/runner.ts

+3-2
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

+1-1
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 <[email protected]>",
2222
"dependencies": {
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.js

+29-5
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ function getPackages() {
6262
Object.assign(mem, {[curr.replace(/\.js$/, '')]: curr}),
6363
{},
6464
),
65-
...(pkg.name === 'jest-circus' ? {'./runner': './runner.js'} : {}),
65+
...(pkg.name === 'jest-circus' ? {'./runner': './build/runner.js'} : {}),
6666
...(pkg.name === 'expect'
6767
? {'./build/matchers': './build/matchers.js'}
6868
: {}),
6969
...(pkg.name === 'pretty-format'
70-
? {'./ConvertAnsi': './build/plugins/ConvertAnsi.js'}
70+
? {'./ConvertAnsi': './build/ConvertAnsi.js'}
7171
: {}),
7272
},
7373
`Package "${pkg.name}" does not export correct files`,
@@ -163,7 +163,7 @@ function createWebpackConfigs() {
163163
});
164164
}
165165

166-
const extraEntries =
166+
const workerEntriesEntries =
167167
pkg.name === 'jest-worker'
168168
? {
169169
processChild: path.resolve(
@@ -183,14 +183,38 @@ function createWebpackConfigs() {
183183
? {testWorker: path.resolve(packageDir, './src/testWorker.ts')}
184184
: {};
185185

186+
const extraEntryPoints =
187+
// skip expect for now
188+
pkg.name === 'expect'
189+
? {}
190+
: Object.keys(pkg.exports)
191+
.filter(
192+
key =>
193+
key !== '.' &&
194+
key !== './package.json' &&
195+
!key.startsWith('./bin'),
196+
)
197+
.reduce((previousValue, currentValue) => {
198+
return {
199+
...previousValue,
200+
// skip `./`
201+
[currentValue.slice(2)]: path.resolve(
202+
packageDir,
203+
'./src',
204+
`${currentValue}.ts`,
205+
),
206+
};
207+
}, {});
208+
186209
return {
187210
packageDir,
188211
pkg,
189212
webpackConfig: {
190213
devtool: false,
191214
entry: {
192215
index: input,
193-
...extraEntries,
216+
...workerEntriesEntries,
217+
...extraEntryPoints,
194218
},
195219
externals: nodeExternals(),
196220
mode: 'production',
@@ -212,7 +236,7 @@ function createWebpackConfigs() {
212236
},
213237
path: path.resolve(packageDir, 'build'),
214238
},
215-
plugins: [new IgnoreDynamicRequire(extraEntries)],
239+
plugins: [new IgnoreDynamicRequire(workerEntriesEntries)],
216240
resolve: {
217241
extensions: ['.ts', '.js'],
218242
},

0 commit comments

Comments
 (0)