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

[build-optimizer] docs about sideEffects: false and maybe bug #11399

Closed
ghetolay opened this issue Jun 28, 2018 · 3 comments · Fixed by #11430
Closed

[build-optimizer] docs about sideEffects: false and maybe bug #11399

ghetolay opened this issue Jun 28, 2018 · 3 comments · Fixed by #11430

Comments

@ghetolay
Copy link

ghetolay commented Jun 28, 2018

Bug Report or Feature Request

- [ ] bug report (maybe)
- [x] feature request (docs I guess)

Area

- [x] devkit
- [ ] schematics

Versions

@angular-devkit/build-optimizer@0.6.8

Issue

After adding sideEffects: false to a library doing webgl stuff, I found out some code was removed because the library contains unpure functions (any function doing webgl stuff).

Turns out build-optimizer is also using that flag in his process to prefix functions with /*@__PURE__*/ and that is the cause of code removal.
I have build up a repro with one of the function :
https://repl.it/@GhetGhetolay/buildoptimizerwebgl
I'm not sure if

  1. this is the expected behavior and we should set isSideEffectFree to false
  2. it's a bug and webgl functions shouldn't be prefixed with pure

If it's not a bug this means we're using same flag for different purposes, webpack sideEffects and build-optimizer isSideEffectFree options are not about the same kind of side effects (module vs functions).

Anyway I think we're missing a bit of docs, neither the Angular Package Format nor the build-optimizer docs mentionned the use of sideEffects flag by build-optimizer.

@ghetolay ghetolay changed the title [build-optimizer] docs about sideEffects: false and maybe bug [build-optimizer] docs about side_effects: false and maybe bug Jun 28, 2018
@ghetolay ghetolay changed the title [build-optimizer] docs about side_effects: false and maybe bug [build-optimizer] docs about sideEffects: false and maybe bug Jun 28, 2018
@clydin
Copy link
Member

clydin commented Jul 2, 2018

The underlying issue is that the build optimizer does not currently understand the usage of the object literal function definition syntax used in the example. Changing the function definition to the following results in proper behavior:

buildTexture: (gl, image) => {

@ghetolay
Copy link
Author

ghetolay commented Jul 3, 2018

Thanks !

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants