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

build: add missing @babel/generator bazel dep to fix //packages/localize/src/tools/test:test #34974

Closed

Conversation

IgorMinar
Copy link
Contributor

@IgorMinar IgorMinar commented Jan 26, 2020

It's not clear how this ever worked (npm hoisting is a suspect though), but this dep is required because
one of the tests imports @babel/generator in the ts sources.

The lack of this dep is breaking builds on the master branch.

More discussion about this issue on Slack: https://angular-team.slack.com/archives/C07DT5M6V/p1579934766007500

…ize/src/tools/test:test

It's not clear how this ever worked (npm hoisting is a suspect though), but this dep is required because
one of the tests imports @babel/generator in the ts sources.

The lack of this dep is breaking builds on the master branch.

More discussion about this issue on Slack: https://angular-team.slack.com/archives/C07DT5M6V/p1579934766007500
@IgorMinar IgorMinar requested review from a team as code owners January 26, 2020 15:48
@IgorMinar IgorMinar changed the title build: add missing @babel/generator bazel dep to fix //packages/loca… build: add missing @babel/generator bazel dep to fix //packages/localize/src/tools/test:test Jan 26, 2020
@IgorMinar IgorMinar added area: build & ci Related the build and CI infrastructure of the project target: patch This PR is targeted for the next patch release labels Jan 26, 2020
@ngbot ngbot bot modified the milestone: needsTriage Jan 26, 2020
@IgorMinar IgorMinar added the action: merge The PR is ready for merge by the caretaker label Jan 26, 2020
@mary-poppins
Copy link

You can preview af97ced at https://pr34974-af97ced.ngbuilds.io/.

@@ -11,6 +11,7 @@ ts_library(
"//packages/compiler",
"//packages/localize",
"//packages/localize/src/tools",
"@npm//@babel/generator",
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to have these packages in package.json or is BUILD.bazel enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right. I added it as well as the @types/babel__generator package in a separate commit.

@gkalpak gkalpak added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: merge The PR is ready for merge by the caretaker labels Jan 26, 2020
@gregmagolan
Copy link
Contributor

gregmagolan commented Jan 26, 2020

There are quite a few @babel/generators in node_modules on master.

./@angular-devkit/build-angular/node_modules/@babel/core/node_modules/@babel/generator/package.json
./@angular-devkit/build-angular/node_modules/@babel/generator/package.json
./@angular-devkit/build-angular/node_modules/@babel/traverse/node_modules/@babel/generator/package.json
./@angular-devkit/build-angular/node_modules/@babel/helpers/node_modules/@babel/generator/package.json
./@babel/generator/package.json
./@babel/traverse/node_modules/@babel/generator/package.json

The test that is causing trouble transitively depends on @babel/core which transitively depends on @babel/generator so its import from @babel/generator would only work if the @babel/core dep @bable/generator was being hoisted to the root.... which on master that looks to be the case:

cat node_modules/@babel/generator/package.json
{
  "name": "@babel/generator",
  "version": "7.6.4",

But if it wasn't hoisted due to package.json changes that could break the test.

I don't think this PR is sufficient to fix the problem in all cases as it is possible that there will be no @npm//@babel/generator layed out.

The file that uses @babel/generator is packages/localize/src/tools/test/translate/source_files/source_file_utils_spec.ts. So I think the correct shape for the fix is:

  1. to add @babel/generator and @npm//@babel/core to the test_lib target packages/localize/src/tools/test/BUILD.bazel. Its currently getting both transitively from //packages/localize/src/tools:tools but only working as @babel/generator from @bable/core is being hoisted to the top.

  2. explicitely add @babel/generator to the root package.json so we're not depending on the package manager hoisting it to the top

@gregmagolan
Copy link
Contributor

@IgorMinar Threw up a quick #34980 with my suggestion

Previously we just happened to be able to use it because of npm hoisting.
@IgorMinar IgorMinar requested a review from a team as a code owner January 26, 2020 20:04
…rc/tools/test:test_lib

Previously we relied on this package being hoisted and available, which is error prone and it would
be just a matter of time before the build would break due rehoisting of deps upon future npm package.json
changes.
@IgorMinar IgorMinar 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: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jan 26, 2020
@ngbot ngbot bot added the action: merge The PR is ready for merge by the caretaker label Jan 26, 2020
@IgorMinar
Copy link
Contributor Author

merge-assistance: global approval

@IgorMinar
Copy link
Contributor Author

@gregmagolan George noticed the same thing, and I addressed it in follow up commits.

@mary-poppins
Copy link

You can preview a8565a7 at https://pr34974-a8565a7.ngbuilds.io/.

the test failures most likely result from the babel updates in the previous commit.

it does look like we lost the file path from the error message, which is something that we

should follow up no in a separate change.
It seems that we missed adding it before and listed all the localize fixes under 'ivy'.
@mary-poppins
Copy link

You can preview 6020c70 at https://pr34974-6020c70.ngbuilds.io/.

@@ -140,9 +140,9 @@ describe('makeEs5Plugin', () => {
expect(diagnostics.hasErrors).toBe(true);
expect(diagnostics.messages[0]).toEqual({
type: 'error',
message: '/app/dist/test.js: `$localize` called without any arguments.\n' +
Copy link
Contributor Author

@IgorMinar IgorMinar Jan 26, 2020

Choose a reason for hiding this comment

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

@petebacondarwin this is unexpected and likely due to the @babel version update in 0a5a944 can you please look into why the path disappeared and fix it in a follow up PR if possible? I'd like to get this PR landed so that it doesn't block other PRs.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, yet, why the file path has disappeared. But the other changes to the error messages (i.e. the extra ^^^^ etc) are due to this commit in Babel: babel/babel@f1bc6c4

Copy link
Member

Choose a reason for hiding this comment

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

Ahah! The filename was removed in this commit: babel/babel@dcf7d89

IgorMinar added a commit that referenced this pull request Jan 26, 2020
…ize/src/tools/test:test (#34974)

It's not clear how this ever worked (npm hoisting is a suspect though), but this dep is required because
one of the tests imports @babel/generator in the ts sources.

The lack of this dep is breaking builds on the master branch.

More discussion about this issue on Slack: https://angular-team.slack.com/archives/C07DT5M6V/p1579934766007500

PR Close #34974
IgorMinar added a commit that referenced this pull request Jan 26, 2020
Previously we just happened to be able to use it because of npm hoisting.

PR Close #34974
IgorMinar added a commit that referenced this pull request Jan 26, 2020
…rc/tools/test:test_lib (#34974)

Previously we relied on this package being hoisted and available, which is error prone and it would
be just a matter of time before the build would break due rehoisting of deps upon future npm package.json
changes.

PR Close #34974
IgorMinar added a commit that referenced this pull request Jan 26, 2020
the test failures most likely result from the babel updates in the previous commit.

it does look like we lost the file path from the error message, which is something that we

should follow up no in a separate change.

PR Close #34974
IgorMinar added a commit that referenced this pull request Jan 26, 2020
It seems that we missed adding it before and listed all the localize fixes under 'ivy'.

PR Close #34974
@IgorMinar IgorMinar closed this in a58034b Jan 26, 2020
IgorMinar added a commit that referenced this pull request Jan 26, 2020
Previously we just happened to be able to use it because of npm hoisting.

PR Close #34974
IgorMinar added a commit that referenced this pull request Jan 26, 2020
…rc/tools/test:test_lib (#34974)

Previously we relied on this package being hoisted and available, which is error prone and it would
be just a matter of time before the build would break due rehoisting of deps upon future npm package.json
changes.

PR Close #34974
IgorMinar added a commit that referenced this pull request Jan 26, 2020
the test failures most likely result from the babel updates in the previous commit.

it does look like we lost the file path from the error message, which is something that we

should follow up no in a separate change.

PR Close #34974
IgorMinar added a commit that referenced this pull request Jan 26, 2020
It seems that we missed adding it before and listed all the localize fixes under 'ivy'.

PR Close #34974
petebacondarwin added a commit to petebacondarwin/angular that referenced this pull request Jan 28, 2020
In angular#34974 the top level dependency on `@babel/core` was bumped to
7.8.3. This commit ensures that the package.json that gets included
in the `@angular/localize` distributable is at the same version.
AndrewKushnir pushed a commit that referenced this pull request Jan 29, 2020
In #34974 the top level dependency on `@babel/core` was bumped to
7.8.3. This commit ensures that the package.json that gets included
in the `@angular/localize` distributable is at the same version.

PR Close #35008
AndrewKushnir pushed a commit that referenced this pull request Jan 29, 2020
In #34974 the top level dependency on `@babel/core` was bumped to
7.8.3. This commit ensures that the package.json that gets included
in the `@angular/localize` distributable is at the same version.

PR Close #35008
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Feb 13, 2020
…ize/src/tools/test:test (angular#34974)

It's not clear how this ever worked (npm hoisting is a suspect though), but this dep is required because
one of the tests imports @babel/generator in the ts sources.

The lack of this dep is breaking builds on the master branch.

More discussion about this issue on Slack: https://angular-team.slack.com/archives/C07DT5M6V/p1579934766007500

PR Close angular#34974
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Feb 13, 2020
…r#34974)

Previously we just happened to be able to use it because of npm hoisting.

PR Close angular#34974
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Feb 13, 2020
…rc/tools/test:test_lib (angular#34974)

Previously we relied on this package being hoisted and available, which is error prone and it would
be just a matter of time before the build would break due rehoisting of deps upon future npm package.json
changes.

PR Close angular#34974
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Feb 13, 2020
the test failures most likely result from the babel updates in the previous commit.

it does look like we lost the file path from the error message, which is something that we

should follow up no in a separate change.

PR Close angular#34974
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Feb 13, 2020
It seems that we missed adding it before and listed all the localize fixes under 'ivy'.

PR Close angular#34974
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Feb 13, 2020
In angular#34974 the top level dependency on `@babel/core` was bumped to
7.8.3. This commit ensures that the package.json that gets included
in the `@angular/localize` distributable is at the same version.

PR Close angular#35008
@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 Feb 27, 2020
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: build & ci Related the build and CI infrastructure of the project cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants