Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

build-optimizer hardcodes private "esm5" paths to enable optimizations #523

Closed
@IgorMinar

Description

@IgorMinar

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:

/[\\/]node_modules[\\/]@angular[\\/][^\\/]+[\\/]esm5[\\/]/,

this line then uses the path above to test if build-optimizer optimizations should be enabled:

&& es5AngularModules.some((re) => re.test(filePath))

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions