-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RC5]: Minified bundle breaks #10618
Comments
Solved: The problem is the order of the components in |
Experienced same problem and got up and running with the same solution. I am not, as of this moment, particularly a fan of this new behavior :-) and I heartily encourage the team to document it in the change log under "breaking changes". |
+1 |
1 similar comment
+1 |
@antonybudianto Which order did you change ? |
@robertoforlani Hopefully someone will have time to write a comprehensive explanation soon. In the meantime here is what I can do in a couple of minutes. In order to obtain a warning free and error-free working "production" build, you need to edit the NgModule app module definition for your program, specifically the declarations array. This array should contain a list of all of the components and directives in your application. Now for the harder part. You must perform a "topological sort" of this list, or for those who didn't study computer science formally or recently, you need to rearrange the order of this list such that the components are in reverse order of use, with the components used most "deeply" in your component hierarchy, listed first. For example, consider if you had five components in your program, A B C D E. If for example component A used component B in its template, and component B used component C in its template, and so on, then the dependencies between these components are A->B, B->C, C->D, D->E, E->F. In this case the correct order to list them in the declarations would be Fortunately, in most applications there is not such a deep dependency graph among all components. In many cases you will make this error go away just by editing that declarations list to (1) list all your components, and (2) list your directives and fine-grained small components the beginning, as a heuristic. |
Experienced almost the same problem. I have 2 directives (A and B) and 1 component (C). |
Thanks all -- this seems like a bug. @IgorMinar is investigating. |
I'm having hard time reproducing the problem. Can someone provide a repro? I tried @antonybudianto's repo but To clarify: the order of declarations should not matter. If changing the order changes the behavior then that's a bug that we'll fix. |
I created https://github.com/IgorMinar/declarations-bug-repro with cli but even that repo doesn’t repro the issue. could someone clone it and modify it to repro the issue? thanks |
I got a repro from @kylecordes: https://github.com/OasisDigital/rc5-declaration-order See comments in this file about declarations order. https://github.com/OasisDigital/rc5-declaration-order/blob/master/src/app/app.module.ts |
I managed to fix my application. |
@IgorMinar , sorry yesterday I pushed some commits to the branch, it should work as expected. |
If anyone wants to generate an arbitrarily large application to help prove out tools (and reveal issues like this one), I just updated my "angular2-stress-test" for rc.5 and NgModule: https://www.npmjs.com/package/angular2-stress-test
|
I faced similar issue in bundled release for https://sirajc.github.io/angular2-labs/ |
I also have this problem. Changing the declarations order did not fix it for me. |
@oocx try putting moduleId:module.id in each component |
Fixed it - I had this error in my unit tests, so I had to fix the declarations in my TestBed.configureTestingModule call instead of my app module. |
Same problem here, solved it with the mangle option set to false. |
Same problem here the fix from @gnujeremie solved it for me to!
|
Same problem, also happening when using Angular 2 with JavaScript ES5 (even with the normal version, not bundled). |
I updates the repro repo: https://github.com/OasisDigital/rc5-declaration-order to the latest CLI webpack.2, to verify the problem still occurs... as it is not clear to me whether this is really a core problem, or somehow a problem added by webpack or CLI. Yes, problem still occurs. |
I'm using angular 2 in an aspnet core app...which means that publishing to aws involves visual studio...which mean that I'm using the visual studio task runner to run webpack...which means I'm locked into "webpack -p" as the command for prod builds...which means UglifyJsPlugin runs with the default settings and I don't have the luxury of passing parameters such as keep_fnames: true. |
@jrood you should be able to configure that setting in your webpack.prod config file. |
@machmo unfortunately, even if I explicitly add "new webpack.optimize.UglifyJsPlugin({ mangle: {keep_fnames: true}})" to the plugin list, it's overridden by the one with no parameters generated by the -p flag. |
It turns out my problem actually was caused by webpack.optimize.OccurrenceOrderPlugin (webpack -h says that -p only does --optimize-minimize, but the online docs confirm that it also does --optimize-occurrence-order); |
-Set keep_fnames: true fixes the issue. Found the solutions here: mishoo/UglifyJS#999 angular/angular#10618 (comment)
-Set keep_fnames: true fixes the issue. Found the solutions here: mishoo/UglifyJS#999 angular/angular#10618 (comment)
-Set keep_fnames: true fixes the issue. Found the solutions here: mishoo/UglifyJS#999 angular/angular#10618 (comment)
I am getting the same problem even I have already included the following code in the webpack.config as described on angular.io new webpack.optimize.UglifyJsPlugin({
mangle: {
keep_fnames: true
},
}) My project using ASP.NET MVC 4 and Angular 2 is using for one of many single page app we are currently having. The error I am facing now is during the uglify process, the ngModel is becoming ngmodel (lower case)
Original <input type="checkbox" [(ngModel)]="showTrafficLayer" (ngModelChange)="mapService.setTraffic($event)" /> Uglify <input type=checkbox [(ngmodel)]=showTrafficLayer (ngmodelchange)=mapService.setTraffic($event) /> Have anyone faced this issue? |
@trungk18 I think you have to also configure your html-loader. Try this:
This workaround is from the Webpack production configuration in Angular docs. |
@tasos-ale check for htmlmin or any other loader. Seems it lowercase attributes in html files |
{
test: /\.html/,
loader: 'html-loader',
options: {
minimize: true,
removeAttributeQuotes: false,
caseSensitive: true,
customAttrSurround: [
[/#/, /(?:)/],
[/\*/, /(?:)/],
[/\[?\(?/, /(?:)/]
],
customAttrAssign: [/\)?\]?=/]
}
} This seems to do the trick for me. |
Seems This is because i don't use plugins that process user options, if no such I wrote own ) |
This issue seems to be back for me. Note, I've upgraded to Typescript 2.0.10 and Angular 2.4.0. The web-pack dev build works fine, but, the web-pack prod build results in the error. Again, it seems related to case-sensitivity, so if I have a property called appName in my component, after the prod build, Angular is looking for appname, which does not exist, and hence, results in the error. Any suggestions are appreciated. Here is my webpack.prod.js. var webpack = require('webpack'); const ENV = process.env.NODE_ENV = process.env.ENV = 'production'; module.exports = webpackMerge(commonConfig, {
}); |
@miladchamo which wbepack version do you use? |
@Martin-Wegner I am using the below for webpack. This is based on the angular.io webpack docs
|
I had no problems with this version... But I must use:
|
@Martin-Wegner that does not seem to work. Same error as mentioned before. |
@miladchamo do you have a little GitHub project which shows the problem? |
@Martin-Wegner I got this to work. I had to update package.json, to make sure I had updated versions for all dev dependencies. In addition, I had to change this dependency to 2.5.41, in order for the client-side build to work, as mentioned in angular/angular.io#3198
Thanks for your assistance along the way. That said, I am still concerned as to how minor versions in these dependencies, have such a significant impact, and it appears that the angular.io docs for webpack and angular https://angular.io/docs/ts/latest/guide/webpack.html are not being kept up to date entirely, or aren't being fully tested. This is the second time, I've run into an issue when following them. |
My code works perfectly in dev environment when I try npm run build I get the following error: ERROR in ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./node_modules/extract-text-webpack-plugin/dist/loader.js? ERROR in ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./node_modules/extract-text-webpack-plugin/dist/loader.js? Following is my code webpack.config.common.js var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { webpack.config.prod.js const ENV = process.env.NODE_ENV = process.env.ENV = 'production'; module.exports = webpackMerge(commonConfig, { |
- set webpack uglifyjs mangle option `keep_fnames: true` - workaround for angular/angular#10618 - resolves #81
I am getting this same issue in 7.0.2 |
Ok so I was experience same issue when using for example 'import { TooltipModule } from 'ngx-bootstrap/tooltip';' on my app.module. So my issue was that I wasnt including this module in the ts.spec file for the component the error was talking about. After adding it to the ts.spec file as an import, phantom started understanding what the tooltip module is. Hope this helps. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
Minified bundle breaks, but SOLVED temporarily by either:
mangle
off (change the option here)Error traces:
Expected/desired behavior
The minified bundle should work as in RC4
Reproduction of the problem
https://github.com/OasisDigital/rc5-declaration-order
What is the expected behavior?
Should work as in RC4
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: