From b396029d391a4f270dbe721b50c3d0de40f1541c Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 13 Oct 2017 14:52:44 -0700 Subject: [PATCH] build(aio): patch @angular/cli to use esm builds of rxjs (#19702) -rw-r--r-- 1 iminar eng 14942 Oct 13 14:52 dist/0.b19e913fbdd6507d346b.chunk.js -rw-r--r-- 1 iminar eng 1535 Oct 13 14:52 dist/inline.6ca24f1c3b848103b041.bundle.js -rw-r--r-- 1 iminar eng 567802 Oct 13 14:52 dist/main.c8183a2c0116782ca366.bundle.js -rw-r--r-- 1 iminar eng 37402 Oct 13 14:52 dist/polyfills.f8409a9eb69060ac1aa6.bundle.js PR Close #19702 --- aio/package.json | 2 +- aio/tools/cli-patches/patch.js | 10 ++++++++++ aio/tools/cli-patches/rxjs-esm-aliases.patch | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 aio/tools/cli-patches/patch.js create mode 100644 aio/tools/cli-patches/rxjs-esm-aliases.patch diff --git a/aio/package.json b/aio/package.json index 86421aa59e..75ad33f241 100644 --- a/aio/package.json +++ b/aio/package.json @@ -52,7 +52,7 @@ "generate-zips": "node ./tools/example-zipper/generateZips", "sw-manifest": "ngu-sw-manifest --dist dist --in ngsw-manifest.json --out dist/ngsw-manifest.json", "sw-copy": "cp node_modules/@angular/service-worker/bundles/worker-basic.min.js dist/", - "postinstall": "uglifyjs node_modules/lunr/lunr.js -c -m -o src/assets/js/lunr.min.js --source-map", + "postinstall": "node tools/cli-patches/patch.js && uglifyjs node_modules/lunr/lunr.js -c -m -o src/assets/js/lunr.min.js --source-map", "build-ie-polyfills": "node node_modules/webpack/bin/webpack.js -p src/ie-polyfills.js src/generated/ie-polyfills.min.js", "~~check-env": "node scripts/check-environment", "~~build": "ng build --target=production --environment=stable -sm --build-optimizer", diff --git a/aio/tools/cli-patches/patch.js b/aio/tools/cli-patches/patch.js new file mode 100644 index 0000000000..0943b40a68 --- /dev/null +++ b/aio/tools/cli-patches/patch.js @@ -0,0 +1,10 @@ +const fs = require('fs'); +const sh = require('shelljs'); + +const PATCH_LOCK = 'node_modules/@angular/cli/models/webpack-configs/.patched'; + +if (!fs.existsSync(PATCH_LOCK)) { + sh.exec('patch -p0 -i tools/cli-patches/rxjs-esm-aliases.patch'); + sh.touch(PATCH_LOCK); +} + diff --git a/aio/tools/cli-patches/rxjs-esm-aliases.patch b/aio/tools/cli-patches/rxjs-esm-aliases.patch new file mode 100644 index 0000000000..841cdffa6f --- /dev/null +++ b/aio/tools/cli-patches/rxjs-esm-aliases.patch @@ -0,0 +1,11 @@ +--- node_modules/@angular/cli/models/webpack-configs/common.js 2017-10-13 14:21:57.000000000 -0700 ++++ node_modules/@angular/cli/models/webpack-configs/common.js 2017-10-13 14:31:30.000000000 -0700 +@@ -135,6 +135,7 @@ + extensions: ['.ts', '.js'], + modules: ['node_modules', nodeModules], + symlinks: !buildOptions.preserveSymlinks ++ ,alias: require('rxjs/_esm5/path-mapping')(path.resolve(__dirname, '..', '..', '..', '..', '..', 'node_modules')) + }, + resolveLoader: { + modules: [nodeModules, 'node_modules'] +