-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@ngtools/webpack): better ctor parameters in AOT (#4428)
We missed a few cases that were generating errors. Sorry. Fixes #4427
- Loading branch information
Showing
4 changed files
with
72 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {Injectable, Inject, ViewContainerRef} from '@angular/core'; | ||
import {DOCUMENT} from '@angular/platform-browser'; | ||
|
||
|
||
@Injectable() | ||
export class MyInjectable { | ||
constructor(public viewContainer: ViewContainerRef, @Inject(DOCUMENT) public doc) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import {normalize} from 'path'; | ||
import {createProjectFromAsset} from '../../../utils/assets'; | ||
import {exec} from '../../../utils/process'; | ||
import {expectFileSizeToBeUnder, replaceInFile} from '../../../utils/fs'; | ||
import {expectFileSizeToBeUnder, replaceInFile, expectFileToMatch} from '../../../utils/fs'; | ||
|
||
|
||
export default function(skipCleaning: () => void) { | ||
return Promise.resolve() | ||
.then(() => createProjectFromAsset('webpack/test-app')) | ||
.then(() => exec(normalize('node_modules/.bin/webpack'), '-p')) | ||
.then(() => expectFileSizeToBeUnder('dist/app.main.js', 420000)) | ||
.then(() => expectFileSizeToBeUnder('dist/0.app.main.js', 40000)) | ||
.then(() => expectFileSizeToBeUnder('dist/0.app.main.js', 10000)) | ||
// test resource urls without ./ | ||
.then(() => replaceInFile('app/app.component.ts', | ||
'./app.component.html', 'app.component.html')) | ||
.then(() => replaceInFile('app/app.component.ts', | ||
'./app.component.scss', 'app.component.scss')) | ||
.then(() => exec(normalize('node_modules/.bin/webpack'), '-p')) | ||
// test | ||
// test the inclusion of metadata | ||
// This build also test resource URLs without ./ | ||
.then(() => exec(normalize('node_modules/.bin/webpack'))) | ||
.then(() => expectFileToMatch('dist/app.main.js', | ||
new RegExp('MyInjectable.ctorParameters = .*' | ||
+ 'type: .*ViewContainerRef.*' | ||
+ 'type: undefined, decorators.*Inject.*args: .*DOCUMENT.*')) | ||
.then(() => expectFileToMatch('dist/app.main.js', | ||
new RegExp('AppComponent.ctorParameters = .*MyInjectable')) | ||
.then(() => skipCleaning()); | ||
} |