Skip to content

feat(ivy): add ngcc ivy switch#25238

Closed
mhevery wants to merge 6 commits into
angular:masterfrom
mhevery:enableIvy
Closed

feat(ivy): add ngcc ivy switch#25238
mhevery wants to merge 6 commits into
angular:masterfrom
mhevery:enableIvy

Conversation

@mhevery
Copy link
Copy Markdown
Contributor

@mhevery mhevery commented Aug 1, 2018

feat(ivy): add ngcc ivy switch

Provides a runtime and compile time switch for ivy including
ApplicationRef.bootstrapModule.

This is done by naming the symbols such that ngcc (angular
Compatibility compiler) can rename symbols in such a way that running
ngcc command will switch the @angular/core module from legacy to
ivy mode.

This is done as follows:

const someToken__PRE_NGCC__ = ‘legacy mode’;
const someToken__POST_NGCC__ = ‘ivy mode’;

export someSymbol = someToken__PRE_NGCC__;

The ngcc will search for any token which ends with __PRE_NGCC__
and replace it with __POST_NGCC__. This allows the @angular/core
package to be rewritten to ivy mode post ngcc execution.

Copy link
Copy Markdown
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

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

This seems to be heading in the right direction, but it appears incomplete and as I commented I think we can do this without ngcc rewriting stuff.

I left a bunch of notes. Please respond inline. thanks!

Comment thread packages/core/src/ivy_switch_legacy.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this flag also get modified when you turn on the mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread packages/core/src/ivy_switch_legacy.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

who calls this? the developer before the bootstrap?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment thread packages/core/src/ivy_switch_legacy.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see these arrays being filled anywhere. is that left as todo? I assume the decorators would do this. right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment thread packages/core/src/ivy_switch_legacy.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do you need ngcc to rename anything? if the decorators add stuff to the queue and the code just below this line does the compilation then nothing alive in the system refers to the ivy compiler unless you call enableIvyJitCompiler.

Unless I'm looking at this wrong, if you call the method from your app, you get ivy, otherwise ivy is dead code eliminated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

discussed offline

Comment thread packages/core/src/ivy_switch_legacy.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how will the queues get drained for lazy loaded code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

reverted

Comment thread packages/core/src/application_ref.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's the relationship between enableIvyBootstrap and enableIvyJitCompiler? when would I use which?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

reverted

@mhevery mhevery changed the title feat(ivy): add enableIvyBootstrap() and enableIvyJitCompiler() switch feat(ivy): add ngcc ivy switch Aug 9, 2018
Copy link
Copy Markdown
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

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

LGTM but please note that CI is currently very unhappy.

@mhevery mhevery added target: major This PR is targeted for the next major release and removed state: WIP labels Aug 15, 2018
@mary-poppins
Copy link
Copy Markdown

You can preview a206f5a at https://pr25238-a206f5a.ngbuilds.io/.

@IgorMinar IgorMinar added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Aug 15, 2018
@IgorMinar
Copy link
Copy Markdown
Contributor

@mhevery can you please update the commit message? it still mentions the api that we decided not to expose.

Provides a runtime and compile time switch for ivy including 
`ApplicationRef.bootstrapModule`.

This is done by naming the symbols such that `ngcc` (angular 
Compatibility compiler) can rename symbols in such a way that running
`ngcc` command will switch the `@angular/core` module from `legacy` to
`ivy` mode.

This is done as follows:

```
const someToken__PRE_NGCC__ = ‘legacy mode’;
const someToken__POST_NGCC__ = ‘ivy mode’;

export someSymbol = someToken__PRE_NGCC__;
```

The `ngcc` will search for any token which ends with `__PRE_NGCC__` 
and replace it with `__POST_NGCC__`. This allows the `@angular/core`
package to be rewritten to ivy mode post `ngcc` execution.
@mhevery
Copy link
Copy Markdown
Contributor Author

mhevery commented Aug 15, 2018

@mhevery mhevery removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Aug 15, 2018
@mary-poppins
Copy link
Copy Markdown

You can preview c8e9145 at https://pr25238-c8e9145.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview ada15d0 at https://pr25238-ada15d0.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 8204725 at https://pr25238-8204725.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 265573a at https://pr25238-265573a.ngbuilds.io/.

@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Aug 16, 2018
@mhevery mhevery removed the request for review from alxhub August 16, 2018 20:39
@jasonaden jasonaden closed this in 503905c Aug 16, 2018
petebacondarwin added a commit to petebacondarwin/angular that referenced this pull request Aug 28, 2018
This method will be used to find all the places where the "ivy switch"
will occur. See angular#25238
petebacondarwin added a commit to petebacondarwin/angular that referenced this pull request Aug 28, 2018
This supports the "ngcc ivy switch" specified in angular#25238.
mhevery pushed a commit that referenced this pull request Aug 31, 2018
…#25534)

This method will be used to find all the places where the "ivy switch"
will occur. See #25238

PR Close #25534
mhevery pushed a commit that referenced this pull request Aug 31, 2018
This supports the "ngcc ivy switch" specified in #25238.

PR Close #25534
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants