Skip to content
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

feat(bazel): update bazel-schematics to use Ivy and new rollup_bundle #33435

Closed
wants to merge 1 commit into from

Conversation

gregmagolan
Copy link
Contributor

@gregmagolan gregmagolan commented Oct 27, 2019

Note: the @angular/bazel schematic now appends the package.json "script" field with 'ngcc --properties es2015 browser module main'. If there is an existing script field with ngcc then the schematic modifies it in place removing --first-only and --create-ivy-entry-points.

ViewEngine sources under node_modules need to be updated in-place for Bazel as it does not know how to use the __ivy__ entry points that are created by the non-bazel ngcc command that is added to "scripts" :ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

@angular/bazel schematics was depending on the legacy rollup_bundle rule which will be removed for the nodejs rules 1.0 release and it was building ViewEngine

What is the new behavior?

@angular/bazel schematics updated to Ivy & to the new rollup_bundle rule

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

if (scripts) {
const postInstall = findPropertyInAstObject(scripts, 'postinstall');
if (postInstall) {
const command = `${postInstall.value}; ${ngcCommand}`;
// Our `ngcc` command should go first so it is executed before before the CLI
// generated ngcc command as if it goes after it does not work as expected
Copy link
Contributor

Choose a reason for hiding this comment

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

that's strange that you could end up with two ngcc commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ng new with ivy adds "scripts": { "postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points" } which doesn't work with bazel because of --first-only and --create-ivy-entry-points

chatted with @filipesilva about this on slack and I think the better solution is to mutate the ngcc <options> to just ngcc in the bazel schematic instead of adding a second

Copy link
Contributor

Choose a reason for hiding this comment

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

Even with just ngcc, there are still two ngcc commands aren't there?
I think Alex's point was, why not just one ngcc command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaned up. If there is an existing ngcc command then the schematic modified the one in-place removing --first-only and --create-ivy-entry-points:

        if (/\bngcc\b/.test(value)) {
          // `ngcc` is already in the postinstall script
          value = value
              .replace(/\s*--first-only\b/, '')
              .replace(/\s*--create-ivy-entry-points\b/, '');
          replacePropertyInAstObject(recorder, scripts, 'postinstall', value);
        } else {
          const command = `${postInstall.value}; ${ngccCommand}`;
          replacePropertyInAstObject(recorder, scripts, 'postinstall', command);
        }

@alexeagle
Copy link
Contributor

/cc @kyliau

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

This also moves to bazel 1.1.0? We should definitely be noting that in the commits/PR message.

@gregmagolan
Copy link
Contributor Author

This also moves to bazel 1.1.0? We should definitely be noting that in the commits/PR message.

👍 will add that note and cleanup the ngcc postinstall

@gregmagolan gregmagolan 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 Oct 28, 2019
@gregmagolan
Copy link
Contributor Author

Actually, given bazelbuild/rules_nodejs#1307 I'll remove the Bazel update on this PR as it will break Windows users.

@gregmagolan gregmagolan force-pushed the bazel_schematics_ivy branch 3 times, most recently from c75a576 to 2261c57 Compare October 28, 2019 22:38
@gregmagolan gregmagolan 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 Oct 28, 2019
Copy link
Contributor

@kyliau kyliau left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@kyliau kyliau added the area: bazel Issues related to the published `@angular/bazel` build rules label Oct 28, 2019
@ngbot ngbot bot added this to the needsTriage milestone Oct 28, 2019
Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

@alexeagle alexeagle added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Oct 29, 2019
@alexeagle
Copy link
Contributor

Caretaker: assistance because there is a "cla/google" status that isn't turning green

@josephperrott josephperrott added cla: yes and removed cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Oct 29, 2019
@josephperrott
Copy link
Member

Removing merge-assistance as cla/google status is corrected

Note: the @angular/bazel schematic now appends the package.json "script" field with 'ngcc --properties es2015 browser module main'. If there is an existing script field with ngcc then the schematic modifies it in place removing `--first-only` and `--create-ivy-entry-points`.

ViewEngine sources under node_modules need to be updated in-place for Bazel as it does not know how to use the `__ivy__` entry points that are created by the non-bazel `ngcc` command that is added to "scripts" :`ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points`.
@gregmagolan
Copy link
Contributor Author

@caretaker Noticed the comment on the commit was outdated so updated it as it's a feat commit. No other changes. CI running again.

matsko pushed a commit to matsko/angular that referenced this pull request Oct 30, 2019
…angular#33435)

Note: the @angular/bazel schematic now appends the package.json "script" field with 'ngcc --properties es2015 browser module main'. If there is an existing script field with ngcc then the schematic modifies it in place removing `--first-only` and `--create-ivy-entry-points`.

ViewEngine sources under node_modules need to be updated in-place for Bazel as it does not know how to use the `__ivy__` entry points that are created by the non-bazel `ngcc` command that is added to "scripts" :`ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points`.

PR Close angular#33435
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…angular#33435)

Note: the @angular/bazel schematic now appends the package.json "script" field with 'ngcc --properties es2015 browser module main'. If there is an existing script field with ngcc then the schematic modifies it in place removing `--first-only` and `--create-ivy-entry-points`.

ViewEngine sources under node_modules need to be updated in-place for Bazel as it does not know how to use the `__ivy__` entry points that are created by the non-bazel `ngcc` command that is added to "scripts" :`ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points`.

PR Close angular#33435
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…angular#33435)

Note: the @angular/bazel schematic now appends the package.json "script" field with 'ngcc --properties es2015 browser module main'. If there is an existing script field with ngcc then the schematic modifies it in place removing `--first-only` and `--create-ivy-entry-points`.

ViewEngine sources under node_modules need to be updated in-place for Bazel as it does not know how to use the `__ivy__` entry points that are created by the non-bazel `ngcc` command that is added to "scripts" :`ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points`.

PR Close angular#33435
@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 29, 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 area: bazel Issues related to the published `@angular/bazel` build rules 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.

None yet

5 participants