Skip to content

Move reflect metadata from the polyfills to the dev environment file. #12314

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
Sep 25, 2018

Conversation

hansl
Copy link
Contributor

@hansl hansl commented Sep 20, 2018

No description provided.

// Used for reflect-metadata in JIT. For size and performance reasons, this should not be imported
// in AOT unless absolutely needed. All Angular metadata is removed in AOT so this is only needed,
// by default, in development.
import 'core-js/es7/reflect';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the environment file is the right place to add polyfills.

Environments here are for runtime variables, and we encourage users to add API keys and such here. It's common to test your app over the production runtime environment on a development build.

We now have general purpose file replacements as well. Why not have polyfills.ts and polyfills.aot.ts and effect the replacement on AOT configurations instead? The default production configuration would replace both environment.ts and polyfills.ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's not a bad idea, but it will make the update step more complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually since the polyfill file is an option we should just override that.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we can automatically move the polyfill without breaking existing applications. Some may rely on the reflect APIs which will have mysteriously disappeared after updating.

Copy link
Contributor

@filipesilva filipesilva Sep 20, 2018

Choose a reason for hiding this comment

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

Yeah making a new polyfills file is much better. How about, for updating, we make a new polyfills.jit.ts, that's a copy of the existing user polyfills, but with reflect removed?

This still suffers from the problem @clydin highlighted. Maybe we should put a warning about that as well. It's probably worth some confused users to make sure most people don't ship reflect by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update would: copy the file, remove the reflect.

New project gets a dev polyfills that imports the AOT one.

Copy link
Member

Choose a reason for hiding this comment

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

doesn't have to be a copy. The JIT file would just contain reflect and then import the original polyfills file.

But that brings up another problem: ng build --prod --no-aot

Copy link
Member

@clydin clydin Sep 20, 2018

Choose a reason for hiding this comment

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

The ideal scenario here would be for the CLI to analyze the code and only include the polyfill if actually used. similar to babel-preset-env

@hansl hansl added the needs: discussion On the agenda for team meeting to determine next steps label Sep 20, 2018
@IgorMinar
Copy link
Contributor

after further discussion it's likely that we'll go with #12346 instead.

@hansl
Copy link
Contributor Author

hansl commented Sep 24, 2018

I'll reuse this PR for the migration

@hansl hansl force-pushed the feat-reflect-metadata branch from 1824394 to ce72815 Compare September 24, 2018 19:18
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@hansl hansl force-pushed the feat-reflect-metadata branch from ce72815 to 904dc00 Compare September 24, 2018 20:37
@googlebot
Copy link

CLAs look good, thanks!

clydin
clydin previously approved these changes Sep 24, 2018
See PR angular#12346 for more information. This
PR migrates current CLI projects to the new polyfills introduced in that PR.
@hansl hansl added target: major This PR is targeted for the next major release and removed needs: discussion On the agenda for team meeting to determine next steps labels Sep 25, 2018
@vikerman vikerman merged commit 2771529 into angular:master Sep 25, 2018
@hansl hansl deleted the feat-reflect-metadata branch November 29, 2018 01:17
@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 12, 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.

6 participants