-
Notifications
You must be signed in to change notification settings - Fork 418
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
CommandInterceptor.js
has side-effects, but is not included in sideEffects
property in package.json
#353
Comments
This is due to angular applying very aggressive optimization. This caused issues in other parts of our toolbelt already, cf. angular example issue, this forum post. No other cli tool or bundler shows this behavior. We are open to pull requests that improve the command interceptor implementation so that it is side-effect free from the Angular CLI point of view. Another option is to pursue the angular guys to fix their tool to not optimizing that particular pattern. |
Thanks for the reply. I already found a lot of issues in the meantime, this one here will probably only be the first we would encounter. I'm currently trying the workaround to import the prod builds of the library and see if this fixes it. |
Using the prod builds is the known workaround for such optimization issues. You can even bundle your own version of the editor, if you perform heavy customization. |
Closing this, as we do not intend to fix such issues. We are open for pull requests that improve the situation for angular users though. |
Related angular-cli issue for breaking external libraries: angular/angular-cli#11439 |
Ok, that's understandable. The workaround fixed it for us.
|
@nikku the main problem is the |
Please understand that the main problem is the angular-cli. Please provide your feedback to the Angular developers so that they can fix their tool chain. |
We use dmn.js in an angular app. In development mode, it works fine, but in a prod build, we get the following error:
This is the compressed code around the error location:
The problem is that the
canExecute
method is missing in theCommandInterceptor
prototype. Enabling source maps shows that the hooks actually are not created - the whole part ofCommandInterceptor
starting from thehooks
array delcaration is optimized away, specifically, this:I don't know too much about tree shaking, but I think the problem is that diagram.js is declared side-effect free (only css files are listed in
sideEffects
inpackage.json
), but this file contains imperative code that is not clearly linked to one of the exports.I didn't find an explicit list of what is considered a side-effect. Maybe it would already help to use a standard
for-of
and not callforEach
ofmin-dash
. But I think the safest way would be to assign the hooks explicitly to the prototype (you could still use a helper function to generate the hook implementation).Steps to Reproduce
dmn-js
as a dependencyimport Modeler from 'dmn-js/lib/Modeler'
new Modeler(/* ... */)
ng build --prod
(which enables tree shaking and other optimizations)I don't think it's relevant how exactly we use dmn-js, but if needed I can try to create a sample app that reproduces the problem.
Environment
The text was updated successfully, but these errors were encountered: