Skip to content

build: switch to release output from bazel #17046

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 14 commits into from
Sep 18, 2019

Conversation

devversion
Copy link
Member

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 11, 2019
@devversion devversion force-pushed the build/npm-packages-bazel branch 5 times, most recently from faf5d9d to 75180f5 Compare September 11, 2019 13:55
@devversion devversion marked this pull request as ready for review September 11, 2019 14:53
@devversion devversion requested review from jelbourn, mmalerba and a team as code owners September 11, 2019 14:53
@devversion
Copy link
Member Author

I can squash all other commits together, or we just preserve all. Either way, we should preserve the commit that removes the re-exports for the Material primary entry-point 🤷‍♂

@jelbourn @josephperrott This should be ready for review. Note that it looks like we don't have real integration tests that ensure that the package output works properly in CLI applications.

I'd strongly advocate that this is something we should do next. Should be fairly simple to get an initial integration test.

@devversion devversion added target: major This PR is targeted for the next major release pr: needs rebase labels Sep 11, 2019
@devversion
Copy link
Member Author

Needs rebase now and I need to apply the workaround for angular/angular#32610 to the cdk/testing/* tertiary entry-points.

Also two things missing (which I just noticed):

  1. Rewire primary entry-point package.json files. ng_package is never auto-generating these.
  2. Wire up theming bundle for material-experimental (as discussed in #components)

echo "> Copying package output to \"${targetDir}\".."
rm -rf ${targetDir}
cp -R ${pkgDir} ${targetDir}
chmod -R u+w ${targetDir}
Copy link
Member

Choose a reason for hiding this comment

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

Can you also npm pack the copied packages? That makes them easier to work with for some scenarios

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. We can do that, but let's do this as a follow-up.

we need to move the npm pack-ed output to a different folder to not accidentally publish them within the release packages.

@devversion devversion force-pushed the build/npm-packages-bazel branch from 75180f5 to e406972 Compare September 12, 2019 21:19
@devversion devversion added in progress This issue is currently in progress and removed pr: needs rebase labels Sep 12, 2019
@mmalerba mmalerba added this to the 9.0.0 milestone Sep 12, 2019
@devversion devversion force-pushed the build/npm-packages-bazel branch 7 times, most recently from fcb08e9 to c8632ba Compare September 17, 2019 13:58
@devversion devversion force-pushed the build/npm-packages-bazel branch 2 times, most recently from cbc9ed6 to 624c6ca Compare September 17, 2019 21:34
@devversion devversion removed the in progress This issue is currently in progress label Sep 17, 2019
@devversion
Copy link
Member Author

devversion commented Sep 17, 2019

Addressed initial comments. Also I was able to work around the last big blocker in a reasonable way. I'll document the details of the workaround in the hackmd for the blockers (just so that we can use the insights if we/someone spends time fixing the root cause issues).

This should be ready for another review. I also manually tested the release output in the docs app and everything worked as expected.

Removes the re-exports to all secondary entry-points from the Angular
Material primary entry-point.

BREAKING CHANGE: Components can no longer be imported through "@angular/material". Use the individual secondary entry-points.
The CDK contains stylesheet files which are re-rooted at the NPM
package root. This needs to be done for the bazel package as
well as it would otherwise break a lot of consumers.
We can't use "ts_library" for entry-points which should be part
of a "ng_package". This is because "ng_package" currently only
partially includes "ts_library" targets in the package (i.e. missing
`package.json` file for secondary entry-points).

Until we figure out what best practice is, or if angular/angular#32610
is merged, we just use "ng_module" to work around this issue.
…output

The primary entry-point `package.json` files are not generated by the
`ng_package` bazel rule. This is by intention because it does not
try to overwrite existing `package.json` files in the release output
(i.e. to preserve placeholders; dependencies etc.)

We need to update the `package.json` fields to match the new
release output that is generated by Bazel. Also adds a new
release output validation that ensures that those fields in the
`package.json` files are resolving to existing files.
Currently with Gulp we have a **hacky** script that fixes up
relative imports in sass files. This is something we cannot
easily do with Bazel when we assemble the release package.

Primarily because of that limitation/complexity with Bazel and
the general preference to avoid such hacky rewrites, we now
ship all individual "scss_lib" files to the release output.

This way all relative style references remain *correct* when
the release packages are assembled. This means that we no
longer need a hacky script to rewrite the imports.

For backwards compatibility, the `_theming.scss` entry-point
at the root of the Material package is still created. It just isn't
a sass bundle anymore, but the functionality remains the same
(making it a bundle means we repeat a *lot* of code; also there
no real big benefit as we don't have too deep dependencies)

Same has been done for the CDK sass files (overlay, a11y, text-field),
where we still expose the prebuilt css and sass files at the top-level
of the release output.

In the future, we can consider removing these backwards-compatibility
changes in favor of a less convoluted bazel setup.
Fixes the missing metadata for example modules. This happens because
we built the individual example modules without a flat module bundle. Not
building with a flat module bundle means that metadata will not be generated
in the `ng_module` bazel rule.
Applies a workaround for the invalid imports generation issue
in the Bazel `ng_module` rule. Read more about this here:

https://hackmd.io/@devversion/ryCOwIKIS.
Apparently the `google-maps` package has the same problem
as the `material-examples` package where the metadata for
the Bazel sub-packages is not incldued in the entry-point of
the `@angular/google-maps` entry-point. There are two solutions
to make it work with Angular package format:

* Making the packages generate flat module bundles and including them as secondary entry-points
* Only having one Bazel package so that metadata will be included in the flat module bundle.

I chose the latter as the `google-maps` package is still very small and doesn't have a lot
of dependencies, so in terms of speed it is even faster to have on package. Also it seems
like there were never plans to have secondary entry-points for that package.
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Sep 18, 2019
@jelbourn jelbourn merged commit 9d6f4c2 into angular:master Sep 18, 2019
CaerusKaru added a commit to CaerusKaru/components that referenced this pull request Sep 25, 2019
mmalerba pushed a commit that referenced this pull request Oct 1, 2019
@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 Oct 19, 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 PR author has agreed to Google's Contributor License Agreement target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants