-
Notifications
You must be signed in to change notification settings - Fork 155
build-optimizer hardcodes private "esm5" paths to enable optimizations #523
Comments
@IgorMinar the reason those paths are hardcoded is because Build Optimizer itself does not know about entry points as described in When used with Webpack, that information could be passed along. But Build Optimizer can be used outside of Webpack as well. Doing resolution for each file passed can be costly so that determination is left to the tooling. I think the right approach to move out of the hardcoded paths is to make use of the This is what we used for the Bazel integration via Rollup. The webpack loader hasn't yet been revisited to use this as well. The |
aha! great insights. thanks! I agree that we should just switch over to detection based on the |
PR #531 allows the build optimizer to leverage the webpack side effect detection. |
Also of note: The CLI v6 webpack 4 configuration marks previous versions of Angular as side effect free in addition to any packages with the |
Bug Report or Feature Request (mark with an
x
)Area
Versions
Repro steps
the following line hardcodes "esm5" path - which is an implementation detail and not part of the public api:
devkit/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer.ts
Line 44 in 40c5eeb
this line then uses the path above to test if build-optimizer optimizations should be enabled:
devkit/packages/angular_devkit/build_optimizer/src/build-optimizer/build-optimizer.ts
Line 59 in 40c5eeb
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.
Mention any other details that might be useful
The text was updated successfully, but these errors were encountered: