File tree 6 files changed +27
-0
lines changed
6 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,11 @@ const BuildCommand = Command.extend({
220
220
commandOptions . vendorChunk = ! commandOptions . buildOptimizer ;
221
221
}
222
222
223
+ // Force commonjs module format for TS on dev watch builds.
224
+ if ( commandOptions . target === 'development' && commandOptions . watch === true ) {
225
+ commandOptions . forceTsCommonjs = true ;
226
+ }
227
+
223
228
const BuildTask = require ( '../tasks/build' ) . default ;
224
229
225
230
const buildTask = new BuildTask ( {
Original file line number Diff line number Diff line change @@ -135,6 +135,11 @@ const ServeCommand = Command.extend({
135
135
commandOptions . vendorChunk = ! commandOptions . buildOptimizer ;
136
136
}
137
137
138
+ // Force commonjs module format for TS on dev builds.
139
+ if ( commandOptions . target === 'development' ) {
140
+ commandOptions . forceTsCommonjs = true ;
141
+ }
142
+
138
143
// Default evalSourcemaps to true for serve. This makes rebuilds faster.
139
144
commandOptions . evalSourcemaps = true ;
140
145
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export interface TestOptions {
24
24
environment ?: string ;
25
25
app ?: string ;
26
26
preserveSymlinks ?: boolean ;
27
+ forceTsCommonjs ?: boolean ;
27
28
}
28
29
29
30
@@ -134,6 +135,13 @@ const TestCommand = Command.extend({
134
135
// if not watching ensure karma is doing a single run
135
136
commandOptions . singleRun = true ;
136
137
}
138
+
139
+ // Don't force commonjs for code coverage builds, some setups need es2015 for it.
140
+ // https://github.com/angular/angular-cli/issues/5526
141
+ if ( ! commandOptions . codeCoverage ) {
142
+ commandOptions . forceTsCommonjs = true ;
143
+ }
144
+
137
145
return testTask . run ( commandOptions ) ;
138
146
}
139
147
} ) ;
Original file line number Diff line number Diff line change @@ -30,4 +30,5 @@ export interface BuildOptions {
30
30
buildOptimizer ?: boolean ;
31
31
namedChunks ?: boolean ;
32
32
subresourceIntegrity ?: boolean ;
33
+ forceTsCommonjs ?: boolean ;
33
34
}
Original file line number Diff line number Diff line change @@ -21,10 +21,17 @@ const webpackLoader: string = g['angularCliIsLocal']
21
21
function _createAotPlugin ( wco : WebpackConfigOptions , options : any ) {
22
22
const { appConfig, projectRoot, buildOptions } = wco ;
23
23
options . compilerOptions = options . compilerOptions || { } ;
24
+
24
25
if ( wco . buildOptions . preserveSymlinks ) {
25
26
options . compilerOptions . preserveSymlinks = true ;
26
27
}
27
28
29
+ // Forcing commonjs seems to drastically improve rebuild speeds on webpack.
30
+ // Dev builds on watch mode will set this option to true.
31
+ if ( wco . buildOptions . forceTsCommonjs ) {
32
+ options . compilerOptions . module = 'commonjs' ;
33
+ }
34
+
28
35
// Read the environment, and set it in the compiler host.
29
36
let hostReplacementPaths : any = { } ;
30
37
// process environment file replacement
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ export default Task.extend({
44
44
poll : options . poll ,
45
45
environment : options . environment ,
46
46
preserveSymlinks : options . preserveSymlinks ,
47
+ forceTsCommonjs : options . forceTsCommonjs ,
47
48
app : options . app
48
49
} ;
49
50
You can’t perform that action at this time.
0 commit comments