Skip to content

Commit 082c570

Browse files
saruninthansl
authored andcommitted
fix(@angular/cli): use RxJS ES2015 path alias when targeting ES2015
1 parent 3159690 commit 082c570

File tree

1 file changed

+10
-1
lines changed
  • packages/@angular/cli/models/webpack-configs

1 file changed

+10
-1
lines changed

packages/@angular/cli/models/webpack-configs/common.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
3030
const appRoot = path.resolve(projectRoot, appConfig.root);
3131
const nodeModules = path.resolve(projectRoot, 'node_modules');
3232

33+
const projectTs = requireProjectModule(projectRoot, 'typescript');
34+
3335
let extraPlugins: any[] = [];
3436
let extraRules: any[] = [];
3537
let entryPoints: { [key: string]: string[] } = {};
@@ -161,9 +163,16 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
161163

162164
// Load rxjs path aliases.
163165
// https://github.com/ReactiveX/rxjs/blob/master/doc/lettable-operators.md#build-and-treeshaking
166+
167+
const supportES2015 =
168+
wco.tsConfig.options.target !== projectTs.ScriptTarget.ES3 &&
169+
wco.tsConfig.options.target !== projectTs.ScriptTarget.ES5;
170+
164171
let alias = {};
165172
try {
166-
const rxjsPathMappingImport = 'rxjs/_esm5/path-mapping';
173+
const rxjsPathMappingImport = supportES2015
174+
? 'rxjs/_esm2015/path-mapping'
175+
: 'rxjs/_esm5/path-mapping';
167176
const rxPaths = requireProjectModule(projectRoot, rxjsPathMappingImport);
168177
alias = rxPaths(nodeModules);
169178
} catch (e) { }

0 commit comments

Comments
 (0)