Skip to content

Commit

Permalink
fix(@angular/cli): use RxJS ES2015 path alias when targeting ES2015
Browse files Browse the repository at this point in the history
  • Loading branch information
sarunint authored and hansl committed Oct 29, 2017
1 parent 3159690 commit 082c570
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/@angular/cli/models/webpack-configs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export function getCommonConfig(wco: WebpackConfigOptions) {
const appRoot = path.resolve(projectRoot, appConfig.root);
const nodeModules = path.resolve(projectRoot, 'node_modules');

const projectTs = requireProjectModule(projectRoot, 'typescript');

let extraPlugins: any[] = [];
let extraRules: any[] = [];
let entryPoints: { [key: string]: string[] } = {};
Expand Down Expand Up @@ -161,9 +163,16 @@ export function getCommonConfig(wco: WebpackConfigOptions) {

// Load rxjs path aliases.
// https://github.com/ReactiveX/rxjs/blob/master/doc/lettable-operators.md#build-and-treeshaking

const supportES2015 =
wco.tsConfig.options.target !== projectTs.ScriptTarget.ES3 &&
wco.tsConfig.options.target !== projectTs.ScriptTarget.ES5;

let alias = {};
try {
const rxjsPathMappingImport = 'rxjs/_esm5/path-mapping';
const rxjsPathMappingImport = supportES2015
? 'rxjs/_esm2015/path-mapping'
: 'rxjs/_esm5/path-mapping';
const rxPaths = requireProjectModule(projectRoot, rxjsPathMappingImport);
alias = rxPaths(nodeModules);
} catch (e) { }
Expand Down

0 comments on commit 082c570

Please sign in to comment.