build-optimizer hardcodes private "esm5" paths to enable optimizations #523
Description
Bug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
Area
- [x] devkit
Versions
Angular CLI: 1.6.6
Node: 8.9.4
OS: darwin x64
Angular: 6.0.0-beta.7-ac402a5a85
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.6 (but the problematic code is still present in master)
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.7.2
Repro steps
the following line hardcodes "esm5" path - which is an implementation detail and not part of the public api:
this line then uses the path above to test if build-optimizer optimizations should be enabled:
Desired functionality
it's not clear to me why we hardcode these paths. ideally we should follow the "module" property to see where the code is in the package, or even better we should check the new "sideEffects" property introduced by webpack v4.
It seems that we are intentionally excluding the es2015 distribution from these optimizations. I'm not sure why, but regardless of the reason, relying on paths is not the right way to go about this - we should be consulting the package.json and using the same resolution algorithm (or the reversed version of it) to understand what kind of file we are dealing with.