Skip to content

feat(@angular-devkit/build-optimizer): don't use getImportTslibTransformer #15749

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

Merged
merged 2 commits into from
Oct 3, 2019

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Oct 3, 2019

This transformer can cause size regressions when it introduces tslib imports across independent chunks.

It should be deprecated because tslib adoption has become more ubiquitous.

Should also speed up Build Optimizer processing time because there's one less thing to do.

@filipesilva
Copy link
Contributor Author

I saw the mentioned size regression in angular/angular#32957, debugged it and found the following:

We have the importTsLib transformer in BO that converts inlined ts declarations into tslib imports. We have a regex test that's meant to bypass the transformer to speed things up. When you don't have sourcemaps turned on, we don't use the regex test. zone.js inlines the __assign tslib function, that is not caught by the regex test.

When you make a build with sourcemaps, the regex fails to find the zone.js inlined tslib, and does nothing. When you make a build without sourcemaps, the regex isn't used, and the more sophisticated AST based test is used instead, which converts the zone.js tslib function into an import.

Adding an import to zone.js introduces a cross-chunk dependency between polyfills and main, because both use tslib. This prevents tslib from being concatenated with the rest of polyfills and of main, which in turn prevents further optimizations.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, other than adding the deprecated msg in the transformer.

Also, you can probably remove the testImportTslib method.

@filipesilva filipesilva changed the title feat(@angular-devkit/build-optimizer): don't use the deprecated getIm… feat(@angular-devkit/build-optimizer): don't use getImportTslibTransformer Oct 3, 2019
…ormer

This transformer can cause size regressions when it introduces `tslib` imports across independent chunks.

It should be deprecated because tslib adoption has become more ubiquitous.

Should also speed up Build Optimizer processing time because there's one less thing to do.

Closes angular#15401 without adding the warning, because some libraries like zone.js should inline the helpers.
@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 Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants