Skip to content

Commit 9ab73d8

Browse files
committed
fix-export-default-worker
2 parents 9d273ff + e79744e commit 9ab73d8

33 files changed

Lines changed: 516 additions & 405 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@
33
### Features
44

55
### Fixes
6-
- `[jest-worker, jest-haste-map, jest-runner, jest-reporters]` Fix: jest-worker: should not expose `.default` babel interop ([#10623] (https://github.com/facebook/jest/pull/10623))
7-
- `[jest-runner, jest-runtime]` fix: `require.main` undefined with `createRequire()` ([#10610](https://github.com/facebook/jest/pull/10610))
8-
- `[jest-validate]` Show suggestion only when unrecognized cli param is longer than 1 character ([#10604](https://github.com/facebook/jest/pull/10604))
9-
- `[jest-validate]` Validate `testURL` as CLI option ([#10595](https://github.com/facebook/jest/pull/10595))
106

117
### Chore & Maintenance
128

139
### Performance
1410

11+
## 26.5.3
12+
13+
### Features
14+
15+
- `[jest-runtime]` add support for dynamic `import()` from CommonJS ([#10620](https://github.com/facebook/jest/pull/10620))
16+
- `[jest-worker, jest-haste-map, jest-runner, jest-reporters]` Fix: jest-worker: should not expose `.default` babel interop ([#10623] (https://github.com/facebook/jest/pull/10623))
17+
18+
### Fixes
19+
20+
- `[jest-runner, jest-runtime]` `require.main` should not be `undefined` with `createRequire()` ([#10610](https://github.com/facebook/jest/pull/10610))
21+
- `[jest-runtime]` add missing `module.path` property ([#10615](https://github.com/facebook/jest/pull/10615))
22+
- `[jest-runtime]` Add `mainModule` instance variable to runtime ([#10621](https://github.com/facebook/jest/pull/10621))
23+
- `[jest-runtime]` Evaluate Node core modules on dynamic `import()` ([#10622](https://github.com/facebook/jest/pull/10622))
24+
- `[jest-validate]` Show suggestion only when unrecognized cli param is longer than 1 character ([#10604](https://github.com/facebook/jest/pull/10604))
25+
- `[jest-validate]` Validate `testURL` as CLI option ([#10595](https://github.com/facebook/jest/pull/10595))
26+
1527
## 26.5.2
1628

1729
### Fixes

e2e/__tests__/__snapshots__/nativeEsm.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`on node ^12.16.0 || >=13.7.0 runs test with native ESM 1`] = `
44
Test Suites: 1 passed, 1 total
5-
Tests: 12 passed, 12 total
5+
Tests: 14 passed, 14 total
66
Snapshots: 0 total
77
Time: <<REPLACED>>
88
Ran all test suites.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
import runJest from '../runJest';
9+
10+
test('`require.main` on using `jest.isolateModules` should not be undefined', () => {
11+
const {exitCode} = runJest('require-main-isolate-modules');
12+
13+
expect(exitCode).toBe(0);
14+
});

e2e/native-esm/__tests__/native-esm.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ test('should support importing node core modules', () => {
4949
});
5050
});
5151

52+
test('should support importing node core modules dynamically', async () => {
53+
// it's important that this module has _not_ been imported at the top level
54+
const assert = await import('assert');
55+
56+
expect(typeof assert.strictEqual).toBe('function');
57+
});
58+
5259
test('dynamic import should work', async () => {
5360
const {double: importedDouble} = await import('../index');
5461

@@ -62,6 +69,11 @@ test('import cjs', async () => {
6269
expect(half(4)).toBe(2);
6370
});
6471

72+
test('import esm from cjs', async () => {
73+
const {default: halfPromise} = await import('../fromEsm.cjs');
74+
expect(await halfPromise(1)).toBe(2);
75+
});
76+
6577
test('require(cjs) and import(cjs) should share caches', async () => {
6678
const require = createRequire(import.meta.url);
6779

e2e/native-esm/fromEsm.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
module.exports = async num => {
9+
const {double} = await import('./dynamicImport');
10+
11+
return double(num);
12+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
let foo;
8+
9+
jest.isolateModules(() => (foo = require('../index')));
10+
11+
test('`require.main` on using `jest.isolateModules` should not be undefined', () => {
12+
expect(foo()).toEqual(1);
13+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
module.exports = 1;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
module.exports = () => require.main.require('../child');
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"jest": {
3+
"testEnvironment": "node"
4+
}
5+
}

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "26.5.2",
2+
"version": "26.5.3",
33
"npmClient": "yarn",
44
"packages": [
55
"packages/*"

0 commit comments

Comments
 (0)