Skip to content

Commit cc44407

Browse files
committed
Support enhanced resolve (#7169)
* fix(@ngtools/webpack): support [email protected] Followup to #7123 * fix(@angular/cli): unpin webpack 3.3.0 Followup to #7130
1 parent 3a555da commit cc44407

File tree

4 files changed

+155
-13
lines changed

4 files changed

+155
-13
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"diff": "^3.1.0",
5252
"ember-cli-normalize-entity-name": "^1.0.0",
5353
"ember-cli-string-utils": "^1.0.0",
54-
"enhanced-resolve": "3.3.0",
54+
"enhanced-resolve": "^3.4.1",
5555
"exports-loader": "^0.6.3",
5656
"extract-text-webpack-plugin": "^2.1.0",
5757
"file-loader": "^0.10.0",

packages/@ngtools/webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
"npm": ">= 3.0.0"
2626
},
2727
"dependencies": {
28-
"enhanced-resolve": "3.3.0",
2928
"loader-utils": "^1.0.2",
3029
"magic-string": "^0.22.3",
3130
"source-map": "^0.5.6"
3231
},
3332
"peerDependencies": {
33+
"enhanced-resolve": "^3.1.0",
3434
"typescript": "^2.0.2",
3535
"webpack": "^2.2.0 || ^3.0.0"
3636
}

packages/@ngtools/webpack/src/compiler_host.ts

+38-6
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,49 @@ export class WebpackCompilerHost implements ts.CompilerHost {
152152
return;
153153
}
154154

155+
/**
156+
* storageDataSetter is a temporary hack to address these two issues:
157+
* - https://github.com/angular/angular-cli/issues/7113
158+
* - https://github.com/angular/angular-cli/issues/7136
159+
*
160+
* This way we set values correctly in both a Map (enhanced-resove>=3.4.0) and
161+
* object (enhanced-resolve >= 3.1.0 <3.4.0).
162+
*
163+
* The right solution is to create a virtual filesystem by decorating the filesystem,
164+
* instead of injecting data into the private cache of the filesystem.
165+
*
166+
* Doing it the right way should fix other related bugs, but meanwhile we hack it since:
167+
* - it's affecting a lot of users.
168+
* - the real solution is non-trivial.
169+
*/
170+
function storageDataSetter(data: Map<string, any> | {[k: string]: any}, k: string, v: any) {
171+
172+
if (data instanceof Map) {
173+
data.set(k, v);
174+
} else {
175+
data[k] = v;
176+
}
177+
}
178+
179+
180+
155181
const isWindows = process.platform.startsWith('win');
156182
for (const fileName of this.getChangedFilePaths()) {
157183
const stats = this._files[fileName];
158184
if (stats) {
159185
// If we're on windows, we need to populate with the proper path separator.
160186
const path = isWindows ? fileName.replace(/\//g, '\\') : fileName;
161-
fs._statStorage.data[path] = [null, stats];
162-
fs._readFileStorage.data[path] = [null, stats.content];
187+
// fs._statStorage.data[path] = [null, stats];
188+
// fs._readFileStorage.data[path] = [null, stats.content];
189+
storageDataSetter(fs._statStorage.data, path, [null, stats]);
190+
storageDataSetter(fs._readFileStorage.data, path, [null, stats.content]);
163191
} else {
164192
// Support removing files as well.
165193
const path = isWindows ? fileName.replace(/\//g, '\\') : fileName;
166-
fs._statStorage.data[path] = [new Error(), null];
167-
fs._readFileStorage.data[path] = [new Error(), null];
194+
// fs._statStorage.data[path] = [new Error(), null];
195+
// fs._readFileStorage.data[path] = [new Error(), null];
196+
storageDataSetter(fs._statStorage.data, path, [new Error(), null]);
197+
storageDataSetter(fs._readFileStorage.data, path, [new Error(), null]);
168198
}
169199
}
170200
for (const dirName of Object.keys(this._changedDirs)) {
@@ -173,8 +203,10 @@ export class WebpackCompilerHost implements ts.CompilerHost {
173203
const files = this.getFiles(dirName);
174204
// If we're on windows, we need to populate with the proper path separator.
175205
const path = isWindows ? dirName.replace(/\//g, '\\') : dirName;
176-
fs._statStorage.data[path] = [null, stats];
177-
fs._readdirStorage.data[path] = [null, files.concat(dirs)];
206+
// fs._statStorage.data[path] = [null, stats];
207+
// fs._readdirStorage.data[path] = [null, files.concat(dirs)];
208+
storageDataSetter(fs._statStorage.data, path, [null, stats]);
209+
storageDataSetter(fs._readFileStorage.data, path, [null, files.concat(dirs)]);
178210
}
179211
}
180212

yarn.lock

+115-5
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,10 @@ camelcase@^3.0.0:
663663
version "3.0.0"
664664
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a"
665665

666+
camelcase@^4.1.0:
667+
version "4.1.0"
668+
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
669+
666670
caniuse-api@^1.5.2:
667671
version "1.6.1"
668672
resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-1.6.1.tgz#b534e7c734c4f81ec5fbe8aca2ad24354b962c6c"
@@ -1514,7 +1518,7 @@ [email protected], enhanced-resolve@^3.0.0:
15141518
graceful-fs "^4.1.2"
15151519
memory-fs "^0.4.0"
15161520
object-assign "^4.0.1"
1517-
tapable "^0.2.5"
1521+
tapable "^0.2.7"
15181522

15191523
ensure-posix-path@^1.0.0:
15201524
version "1.0.2"
@@ -1741,6 +1745,18 @@ evp_bytestokey@^1.0.0:
17411745
dependencies:
17421746
create-hash "^1.1.1"
17431747

1748+
execa@^0.7.0:
1749+
version "0.7.0"
1750+
resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777"
1751+
dependencies:
1752+
cross-spawn "^5.0.1"
1753+
get-stream "^3.0.0"
1754+
is-stream "^1.1.0"
1755+
npm-run-path "^2.0.0"
1756+
p-finally "^1.0.0"
1757+
signal-exit "^3.0.0"
1758+
strip-eof "^1.0.0"
1759+
17441760
exit-hook@^1.0.0:
17451761
version "1.1.1"
17461762
resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8"
@@ -1919,6 +1935,12 @@ find-up@^1.0.0:
19191935
path-exists "^2.0.0"
19201936
pinkie-promise "^2.0.0"
19211937

1938+
find-up@^2.0.0:
1939+
version "2.1.0"
1940+
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
1941+
dependencies:
1942+
locate-path "^2.0.0"
1943+
19221944
flat-cache@^1.2.1:
19231945
version "1.2.2"
19241946
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.2.2.tgz#fa86714e72c21db88601761ecf2f555d1abc6b96"
@@ -2076,6 +2098,10 @@ get-stdin@^4.0.1:
20762098
version "4.0.1"
20772099
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe"
20782100

2101+
get-stream@^3.0.0:
2102+
version "3.0.0"
2103+
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14"
2104+
20792105
getpass@^0.1.1:
20802106
version "0.1.7"
20812107
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
@@ -2682,6 +2708,10 @@ is-resolvable@^1.0.0:
26822708
dependencies:
26832709
tryit "^1.0.1"
26842710

2711+
is-stream@^1.1.0:
2712+
version "1.1.0"
2713+
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
2714+
26852715
is-subset@^0.1.1:
26862716
version "0.1.1"
26872717
resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6"
@@ -3000,6 +3030,13 @@ loader-utils@^1.0.1, loader-utils@^1.0.2, loader-utils@^1.1.0:
30003030
emojis-list "^2.0.0"
30013031
json5 "^0.5.0"
30023032

3033+
locate-path@^2.0.0:
3034+
version "2.0.0"
3035+
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
3036+
dependencies:
3037+
p-locate "^2.0.0"
3038+
path-exists "^3.0.0"
3039+
30033040
lodash._reinterpolate@~3.0.0:
30043041
version "3.0.0"
30053042
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
@@ -3113,6 +3150,12 @@ [email protected]:
31133150
version "0.3.0"
31143151
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
31153152

3153+
mem@^1.1.0:
3154+
version "1.1.0"
3155+
resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76"
3156+
dependencies:
3157+
mimic-fn "^1.0.0"
3158+
31163159
memory-fs@^0.4.0, memory-fs@^0.4.1, memory-fs@~0.4.1:
31173160
version "0.4.1"
31183161
resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552"
@@ -3431,6 +3474,12 @@ npm-run-all@^4.0.0:
34313474
shell-quote "^1.6.1"
34323475
string.prototype.padend "^3.0.0"
34333476

3477+
npm-run-path@^2.0.0:
3478+
version "2.0.2"
3479+
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
3480+
dependencies:
3481+
path-key "^2.0.0"
3482+
34343483
npm-run@^4.1.0:
34353484
version "4.1.2"
34363485
resolved "https://registry.yarnpkg.com/npm-run/-/npm-run-4.1.2.tgz#1030e1ec56908c89fcc3fa366d03a2c2ba98eb99"
@@ -3579,6 +3628,14 @@ os-locale@^1.4.0:
35793628
dependencies:
35803629
lcid "^1.0.0"
35813630

3631+
os-locale@^2.0.0:
3632+
version "2.1.0"
3633+
resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2"
3634+
dependencies:
3635+
execa "^0.7.0"
3636+
lcid "^1.0.0"
3637+
mem "^1.1.0"
3638+
35823639
os-tmpdir@^1.0.0, os-tmpdir@~1.0.1:
35833640
version "1.0.2"
35843641
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
@@ -3643,6 +3700,10 @@ path-exists@^2.0.0:
36433700
dependencies:
36443701
pinkie-promise "^2.0.0"
36453702

3703+
path-exists@^3.0.0:
3704+
version "3.0.0"
3705+
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
3706+
36463707
path-is-absolute@^1.0.0:
36473708
version "1.0.1"
36483709
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
@@ -3651,6 +3712,10 @@ path-is-inside@^1.0.1:
36513712
version "1.0.2"
36523713
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
36533714

3715+
path-key@^2.0.0:
3716+
version "2.0.1"
3717+
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
3718+
36543719
path-parse@^1.0.5:
36553720
version "1.0.5"
36563721
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
@@ -4161,6 +4226,13 @@ read-pkg-up@^1.0.1:
41614226
find-up "^1.0.0"
41624227
read-pkg "^1.0.0"
41634228

4229+
read-pkg-up@^2.0.0:
4230+
version "2.0.0"
4231+
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be"
4232+
dependencies:
4233+
find-up "^2.0.0"
4234+
read-pkg "^2.0.0"
4235+
41644236
read-pkg@^1.0.0, read-pkg@^1.1.0:
41654237
version "1.1.0"
41664238
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28"
@@ -4890,6 +4962,10 @@ strip-bom@^3.0.0:
48904962
version "3.0.0"
48914963
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
48924964

4965+
strip-eof@^1.0.0:
4966+
version "1.0.0"
4967+
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
4968+
48934969
strip-indent@^1.0.1:
48944970
version "1.0.1"
48954971
resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2"
@@ -4929,7 +5005,7 @@ supports-color@^2.0.0:
49295005
version "2.0.0"
49305006
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
49315007

4932-
supports-color@^3.1.0, supports-color@^3.1.1, supports-color@^3.2.3:
5008+
supports-color@^3.1.1, supports-color@^3.2.3:
49335009
version "3.2.3"
49345010
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6"
49355011
dependencies:
@@ -4941,6 +5017,12 @@ supports-color@^4.0.0:
49415017
dependencies:
49425018
has-flag "^2.0.0"
49435019

5020+
supports-color@^4.2.1:
5021+
version "4.2.1"
5022+
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.1.tgz#65a4bb2631e90e02420dba5554c375a4754bb836"
5023+
dependencies:
5024+
has-flag "^2.0.0"
5025+
49445026
svgo@^0.7.0:
49455027
version "0.7.2"
49465028
resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5"
@@ -4972,9 +5054,9 @@ table@^3.7.8:
49725054
slice-ansi "0.0.4"
49735055
string-width "^2.0.0"
49745056

4975-
tapable@^0.2.5, tapable@~0.2.5:
4976-
version "0.2.6"
4977-
resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.6.tgz#206be8e188860b514425375e6f1ae89bfb01fd8d"
5057+
tapable@^0.2.7:
5058+
version "0.2.7"
5059+
resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.7.tgz#e46c0daacbb2b8a98b9b0cea0f4052105817ed5c"
49785060

49795061
tar-pack@^3.4.0:
49805062
version "3.4.0"
@@ -5454,6 +5536,10 @@ which-module@^1.0.0:
54545536
version "1.0.0"
54555537
resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f"
54565538

5539+
which-module@^2.0.0:
5540+
version "2.0.0"
5541+
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
5542+
54575543
which@1, which@^1.2.10, which@^1.2.9:
54585544
version "1.2.14"
54595545
resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"
@@ -5531,6 +5617,12 @@ yargs-parser@^5.0.0:
55315617
dependencies:
55325618
camelcase "^3.0.0"
55335619

5620+
yargs-parser@^7.0.0:
5621+
version "7.0.0"
5622+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-7.0.0.tgz#8d0ac42f16ea55debd332caf4c4038b3e3f5dfd9"
5623+
dependencies:
5624+
camelcase "^4.1.0"
5625+
55345626
yargs@^6.0.0:
55355627
version "6.6.0"
55365628
resolved "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz#782ec21ef403345f830a808ca3d513af56065208"
@@ -5567,6 +5659,24 @@ yargs@^7.0.0:
55675659
y18n "^3.2.1"
55685660
yargs-parser "^5.0.0"
55695661

5662+
yargs@^8.0.2:
5663+
version "8.0.2"
5664+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360"
5665+
dependencies:
5666+
camelcase "^4.1.0"
5667+
cliui "^3.2.0"
5668+
decamelize "^1.1.1"
5669+
get-caller-file "^1.0.1"
5670+
os-locale "^2.0.0"
5671+
read-pkg-up "^2.0.0"
5672+
require-directory "^2.1.1"
5673+
require-main-filename "^1.0.1"
5674+
set-blocking "^2.0.0"
5675+
string-width "^2.0.0"
5676+
which-module "^2.0.0"
5677+
y18n "^3.2.1"
5678+
yargs-parser "^7.0.0"
5679+
55705680
yargs@~3.10.0:
55715681
version "3.10.0"
55725682
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1"

0 commit comments

Comments
 (0)