Skip to content

Commit 87ce4e9

Browse files
JiaLiPassionmhevery
authored andcommitted
fix(zone.js): zone-mix should import correct browser module (#31628)
Close #31626 PR Close #31628
1 parent 2bb9a65 commit 87ce4e9

4 files changed

Lines changed: 46 additions & 5 deletions

File tree

.circleci/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ jobs:
673673
# Run zone.js tools tests
674674
- run: yarn --cwd packages/zone.js promisetest
675675
- run: yarn --cwd packages/zone.js promisefinallytest
676+
- run: yarn bazel build //packages/zone.js:npm_package &&
677+
cp dist/bin/packages/zone.js/npm_package/dist/zone-mix.js ./packages/zone.js/test/extra/ &&
678+
cp dist/bin/packages/zone.js/npm_package/dist/zone-patch-electron.js ./packages/zone.js/test/extra/ &&
679+
yarn --cwd packages/zone.js electrontest
676680

677681
workflows:
678682
version: 2

packages/zone.js/lib/mix/rollup-mix.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import '../zone';
10-
import '../common/promise';
11-
import '../common/to-string';
12-
import '../browser/browser';
9+
import '../browser/rollup-main';
1310
import '../node/node';

packages/zone.js/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515
"test": "test"
1616
},
1717
"devDependencies": {
18+
"domino": "2.1.2",
1819
"mocha": "^3.1.2",
20+
"mock-require": "3.0.3",
1921
"promises-aplus-tests": "^2.1.2",
2022
"typescript": "~3.4.2"
2123
},
2224
"scripts": {
2325
"promisetest": "tsc -p . && node ./promise-test.js",
24-
"promisefinallytest": "tsc -p . && mocha promise.finally.spec.js"
26+
"promisefinallytest": "tsc -p . && mocha promise.finally.spec.js",
27+
"electrontest": "cd test/extra && node electron.js"
2528
},
2629
"repository": {
2730
"type": "git",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
var domino = require('domino');
9+
var mockRequire = require('mock-require');
10+
var nativeTimeout = setTimeout;
11+
require('./zone-mix');
12+
mockRequire('electron', {
13+
desktopCapturer: {getSources: function(callback) { nativeTimeout(callback); }},
14+
shell: {openExternal: function(callback) { nativeTimeout(callback); }},
15+
ipcRenderer: {on: function(callback) { nativeTimeout(callback); }},
16+
});
17+
require('./zone-patch-electron');
18+
var electron = require('electron');
19+
var zone = Zone.current.fork({name: 'zone'});
20+
zone.run(function() {
21+
electron.desktopCapturer.getSources(function() {
22+
if (Zone.current.name !== 'zone') {
23+
process.exit(1);
24+
}
25+
});
26+
electron.shell.openExternal(function() {
27+
console.log('shell', Zone.current.name);
28+
if (Zone.current.name !== 'zone') {
29+
process.exit(1);
30+
}
31+
});
32+
electron.ipcRenderer.on(function() {
33+
if (Zone.current.name !== 'zone') {
34+
process.exit(1);
35+
}
36+
});
37+
});

0 commit comments

Comments
 (0)