Skip to content

Commit

Permalink
deal with entry points [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Apr 27, 2022
1 parent 0737ce4 commit 0d5fc17
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/jest-circus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"default": "./build/index.js"
},
"./package.json": "./package.json",
"./runner": "./runner.js"
"./runner": "./build/runner.js"
},
"dependencies": {
"@jest/environment": "^28.0.0-alpha.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
*/

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

export default runner;
2 changes: 1 addition & 1 deletion packages/pretty-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"default": "./build/index.js"
},
"./package.json": "./package.json",
"./ConvertAnsi": "./build/plugins/ConvertAnsi.js"
"./ConvertAnsi": "./build/ConvertAnsi.js"
},
"author": "James Kyle <[email protected]>",
"dependencies": {
Expand Down
8 changes: 8 additions & 0 deletions packages/pretty-format/src/ConvertAnsi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export {test, serialize} from './plugins/ConvertAnsi';
34 changes: 29 additions & 5 deletions scripts/buildUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ function getPackages() {
Object.assign(mem, {[curr.replace(/\.js$/, '')]: curr}),
{},
),
...(pkg.name === 'jest-circus' ? {'./runner': './runner.js'} : {}),
...(pkg.name === 'jest-circus' ? {'./runner': './build/runner.js'} : {}),
...(pkg.name === 'expect'
? {'./build/matchers': './build/matchers.js'}
: {}),
...(pkg.name === 'pretty-format'
? {'./ConvertAnsi': './build/plugins/ConvertAnsi.js'}
? {'./ConvertAnsi': './build/ConvertAnsi.js'}
: {}),
},
`Package "${pkg.name}" does not export correct files`,
Expand Down Expand Up @@ -163,7 +163,7 @@ function createWebpackConfigs() {
});
}

const extraEntries =
const workerEntriesEntries =
pkg.name === 'jest-worker'
? {
processChild: path.resolve(
Expand All @@ -183,14 +183,38 @@ function createWebpackConfigs() {
? {testWorker: path.resolve(packageDir, './src/testWorker.ts')}
: {};

const extraEntryPoints =
// skip expect for now
pkg.name === 'expect'
? {}
: Object.keys(pkg.exports)
.filter(
key =>
key !== '.' &&
key !== './package.json' &&
!key.startsWith('./bin'),
)
.reduce((previousValue, currentValue) => {
return {
...previousValue,
// skip `./`
[currentValue.slice(2)]: path.resolve(
packageDir,
'./src',
`${currentValue}.ts`,
),
};
}, {});

return {
packageDir,
pkg,
webpackConfig: {
devtool: false,
entry: {
index: input,
...extraEntries,
...workerEntriesEntries,
...extraEntryPoints,
},
externals: nodeExternals(),
mode: 'production',
Expand All @@ -212,7 +236,7 @@ function createWebpackConfigs() {
},
path: path.resolve(packageDir, 'build'),
},
plugins: [new IgnoreDynamicRequire(extraEntries)],
plugins: [new IgnoreDynamicRequire(workerEntriesEntries)],
resolve: {
extensions: ['.ts', '.js'],
},
Expand Down

0 comments on commit 0d5fc17

Please sign in to comment.