Skip to content

Ngcc es5 resolving#25060

Closed
petebacondarwin wants to merge 2 commits into
angular:masterfrom
petebacondarwin:ngcc-es5-resolving
Closed

Ngcc es5 resolving#25060
petebacondarwin wants to merge 2 commits into
angular:masterfrom
petebacondarwin:ngcc-es5-resolving

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin commented Jul 24, 2018

This will replace #25048 when #24897 has landed in master.
Ignoring the fixup commits at the end: the penultimate commit is from #25048 - and the final commit is the meat of this PR.

@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release comp: ivy labels Jul 24, 2018
@petebacondarwin petebacondarwin added this to the Ivy milestone Jul 24, 2018
@googlebot
Copy link
Copy Markdown

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 the commit author(s) and merge this pull request when appropriate.

@mary-poppins
Copy link
Copy Markdown

You can preview 09d3f7c at https://pr25060-09d3f7c.ngbuilds.io/.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and to --> and

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.

or and to --> to

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it is also worth having tests like these (to test some aspects of looking for param initializers):

function baz() {
  var x;
  if (x === void 0) { x = 42; }
  return x;
}

var x;
function qux() {
  if (x === void 0) { x = 42; }
  return x;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great tests you added there 👍
I still think the tests in my previous comment are worth adding too 😁

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.

I thought I was in keeping with the sentiment of your tests!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The sentiment is great. It's just that your tests and my tests test different code paths.
(We need both.)

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.

So many code paths!

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.

Done

@mary-poppins
Copy link
Copy Markdown

You can preview aa77e55 at https://pr25060-aa77e55.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview b6c8c85 at https://pr25060-b6c8c85.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 9bb494b at https://pr25060-9bb494b.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview ce7a140 at https://pr25060-ce7a140.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 5c46d8f at https://pr25060-5c46d8f.ngbuilds.io/.

@gkalpak
Copy link
Copy Markdown
Member

gkalpak commented Jul 28, 2018

Rebased on master (now that #24897 has been merged) and force-pushed.

@trotyl
Copy link
Copy Markdown
Contributor

trotyl commented Jul 28, 2018

Sorry for an off-topic question, I wonder if current ngcc architecture will break use case of #24580 which doesn't use esm at all?

Previously compiler-cli needs only .metadata.json and .d.ts, rather than .js, making arbitrary JavaScript processing possible.

@petebacondarwin
Copy link
Copy Markdown
Contributor Author

@trotyl thanks for linking this. I am pretty sure that Ngcc will not be able to consume the modified UMD file which is all that appears to be left after "securing" a project.

That being said, I believe that going forward, one would be able to republish the original secured files after they have been compiled with ngtsc

let lookingForParamInitializers = true;

const statements = node.body && node.body.statements.filter(s => {
lookingForParamInitializers =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm. I'm not a fan of the non-pure filter lambda. Can you implement this as a loop instead?

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.

OK

@alxhub
Copy link
Copy Markdown
Member

alxhub commented Aug 7, 2018

@trotyl good point, and the answer as @petebacondarwin says is indeed no, it won't work with such packages. ngcc only operates on Angular Package Format packages.

@trotyl
Copy link
Copy Markdown
Contributor

trotyl commented Aug 8, 2018

@alxhub @petebacondarwin Thanks for reply, I'm fine with that, if finally everything will be on ngtsc, it's reasonable for not wasting effort.

alxhub and others added 2 commits August 8, 2018 08:02
ngtsc's static resolver can evaluate function calls where parameters
have default values. In TypeScript code these default values live on the
function definition, but in ES5 code the default values are represented
by statements in the function body.

A new ReflectionHost method getDefinitionOfFunction() abstracts over
this difference, and allows the static reflector to more accurately
evaluate ES5 code.
@mary-poppins
Copy link
Copy Markdown

You can preview e0e09ad at https://pr25060-e0e09ad.ngbuilds.io/.

@petebacondarwin petebacondarwin added merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 8, 2018
@petebacondarwin
Copy link
Copy Markdown
Contributor Author

Superceded by #25090

@petebacondarwin petebacondarwin deleted the ngcc-es5-resolving branch August 23, 2018 06:14
@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

cla: no merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note 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