Skip to content
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

Breaks on Angular applications #7

Closed
filipesilva opened this issue Sep 3, 2018 · 5 comments
Closed

Breaks on Angular applications #7

filipesilva opened this issue Sep 3, 2018 · 5 comments
Labels
bug Something isn't working

Comments

@filipesilva
Copy link

Hi there,

I was trying out this plugin in an Angular app and it seems it breaks some of the imports there.

I'm not sure what's going wrong but tried to prepare the simplest repro possible:

git clone https://github.com/filipesilva/angular-deep-scope
cd angular-deep-scope
npm install
npm run ngc
npm serve

Note: the npm run ngc compiles the typescript files in AOT mode for Angular. You only need to run this once really.

After serving you can go to http://localhost:8080/ and you should see an error. If you remove the new WebpackDeepScopeAnalysisPlugin(), line from webpack.config.js (and restart the server) the error goes away and you should see a Hello World message.

The error is:

app.component.ngfactory.js:10 Uncaught TypeError: undefined is not a function
    at Module.<anonymous> (app.component.ngfactory.js:10)
    at __webpack_require__ (bootstrap:724)
    at fn (bootstrap:101)
    at Object.window.__webpackHotClient__ (main.js:21153)
    at __webpack_require__ (bootstrap:724)
    at bootstrap:791
    at bootstrap:791

It seems to be in this line:

// src/app.component.ngfactory.js
var RenderType_AppComponent = i0.ɵcrt({ encapsulation: 2, styles: styles_AppComponent, data: {} });

When WebpackDeepScopeAnalysisPlugin is present, this line is transformed into:

var RenderType_AppComponent = /* unused reexport */undefined({ encapsulation: 2, styles: styles_AppComponent, data: {} });

Since i0.ɵcrt() is transformed into undefined() the app fails at runtime.

I'm not sure why that transformation happens but if I can help further let me know.

@vincentdchan
Copy link
Owner

vincentdchan commented Sep 4, 2018

I suppose it's a very serious problem. But I cannot run your project:

ERROR in ./src/main.js
Module not found: Error: Can't resolve './app.module.ngfactory' in '/Users/duzhongchen/Workspace/webpack-contrib/angular-deep-scope/src'
 @ ./src/main.js 4:0-60 6:41-59
 @ multi ./src/main.js

Can you provide the content of src/app.component.ngfactory.js to a gist, so that I can locate the problem?

@vincentdchan vincentdchan added the bug Something isn't working label Sep 4, 2018
@filipesilva
Copy link
Author

@vincentdchan did do npm run ngc before npm serve? The src/app.module.ngfactory.js file is created by npm run ngc.

@vincentdchan
Copy link
Owner

vincentdchan commented Sep 4, 2018

Please upgrade to v1.5.4 and I have solved it just now.

@filipesilva
Copy link
Author

I have tested 1.5.4 locally and can verify it works, thanks for such a quick fix!

@vincentdchan
Copy link
Owner

Great! Thanks for reporting the bug because the bus of these plugin can break code when they are on production environment, which may cause very serious problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants