1
- import { expectFileToMatch , writeFile } from '../../utils/fs' ;
1
+ import { expectFileToMatch , rimraf , writeFile } from '../../utils/fs' ;
2
+ import { gitClean } from '../../utils/git' ;
2
3
import { installWorkspacePackages } from '../../utils/packages' ;
3
4
import { ng } from '../../utils/process' ;
4
5
import { updateJsonFile } from '../../utils/project' ;
5
6
import { expectToFail } from '../../utils/utils' ;
6
7
7
8
export default async function ( ) {
8
- // Force duplicate modules
9
- await updateJsonFile ( 'package.json' , ( json ) => {
10
- json . dependencies = {
11
- ...json . dependencies ,
12
- 'tslib' : '2.0.0' ,
13
- 'tslib-1' :
'npm:[email protected] ' ,
14
- 'tslib-1-copy' :
'npm:[email protected] ' ,
15
- } ;
16
- } ) ;
9
+ try {
10
+ // Force duplicate modules
11
+ await updateJsonFile ( 'package.json' , ( json ) => {
12
+ json . dependencies = {
13
+ ...json . dependencies ,
14
+ 'tslib' : '2.0.0' ,
15
+ 'tslib-1' :
'npm:[email protected] ' ,
16
+ 'tslib-1-copy' :
'npm:[email protected] ' ,
17
+ } ;
18
+ } ) ;
17
19
18
- await installWorkspacePackages ( ) ;
20
+ await installWorkspacePackages ( ) ;
19
21
20
- await writeFile (
21
- './src/main.ts' ,
22
- `
22
+ await writeFile (
23
+ './src/main.ts' ,
24
+ `
23
25
import { __assign as __assign_0 } from 'tslib';
24
26
import { __assign as __assign_1 } from 'tslib-1';
25
27
import { __assign as __assign_2 } from 'tslib-1-copy';
@@ -30,29 +32,34 @@ export default async function () {
30
32
__assign_2,
31
33
})
32
34
` ,
33
- ) ;
34
-
35
- const { stderr } = await ng (
36
- 'build' ,
37
- '--verbose' ,
38
- '--no-vendor-chunk' ,
39
- '--no-progress' ,
40
- '--configuration=development' ,
41
- ) ;
42
- const outFile = 'dist/test-project/main.js' ;
35
+ ) ;
43
36
44
- if ( / \[ D e d u p e M o d u l e R e s o l v e P l u g i n \] : .+ t s l i b - 1 - c o p y .+ - > .+ t s l i b - 1 .+ / . test ( stderr ) ) {
45
- await expectFileToMatch ( outFile , './node_modules/tslib-1/tslib.es6.js' ) ;
46
- await expectToFail ( ( ) =>
47
- expectFileToMatch ( outFile , './node_modules/tslib-1-copy/tslib.es6.js' ) ,
37
+ const { stderr } = await ng (
38
+ 'build' ,
39
+ '--verbose' ,
40
+ '--no-vendor-chunk' ,
41
+ '--no-progress' ,
42
+ '--configuration=development' ,
48
43
) ;
49
- } else if ( / \[ D e d u p e M o d u l e R e s o l v e P l u g i n \] : .+ t s l i b - 1 .+ - > .+ t s l i b - 1 - c o p y .+ / . test ( stderr ) ) {
50
- await expectFileToMatch ( outFile , './node_modules/tslib-1-copy/tslib.es6.js' ) ;
51
- await expectToFail ( ( ) => expectFileToMatch ( outFile , './node_modules/tslib-1/tslib.es6.js' ) ) ;
52
- } else {
53
- console . error ( `\n\n\n${ stderr } \n\n\n` ) ;
54
- throw new Error ( 'Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.' ) ;
55
- }
44
+ const outFile = 'dist/test-project/main.js' ;
56
45
57
- await expectFileToMatch ( outFile , './node_modules/tslib/tslib.es6.js' ) ;
46
+ if ( / \[ D e d u p e M o d u l e R e s o l v e P l u g i n \] : .+ t s l i b - 1 - c o p y .+ - > .+ t s l i b - 1 .+ / . test ( stderr ) ) {
47
+ await expectFileToMatch ( outFile , './node_modules/tslib-1/tslib.es6.js' ) ;
48
+ await expectToFail ( ( ) =>
49
+ expectFileToMatch ( outFile , './node_modules/tslib-1-copy/tslib.es6.js' ) ,
50
+ ) ;
51
+ } else if ( / \[ D e d u p e M o d u l e R e s o l v e P l u g i n \] : .+ t s l i b - 1 .+ - > .+ t s l i b - 1 - c o p y .+ / . test ( stderr ) ) {
52
+ await expectFileToMatch ( outFile , './node_modules/tslib-1-copy/tslib.es6.js' ) ;
53
+ await expectToFail ( ( ) => expectFileToMatch ( outFile , './node_modules/tslib-1/tslib.es6.js' ) ) ;
54
+ } else {
55
+ console . error ( `\n\n\n${ stderr } \n\n\n` ) ;
56
+ throw new Error ( 'Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.' ) ;
57
+ }
58
+
59
+ await expectFileToMatch ( outFile , './node_modules/tslib/tslib.es6.js' ) ;
60
+ } finally {
61
+ await rimraf ( 'node_modules/tslib' ) ;
62
+ await gitClean ( ) ;
63
+ await installWorkspacePackages ( ) ;
64
+ }
58
65
}
0 commit comments