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

Make Bazel npm outputs match current packages #5451

Merged
merged 17 commits into from Aug 11, 2021

Conversation

mattsoulanille
Copy link
Member

@mattsoulanille mattsoulanille commented Aug 10, 2021

Make npm packages generated by Bazel match what we currently publish to npm.

tfjs-core/
    package.json
    dist/
        index.js # <-- ESModule format
        index.d.ts
        tf-core.node.js # <-- CommonJS node bundle
        ...

Also, add a webpack regression test to e2e that makes sure webpack can consume the npm packages we publish.

Additionally, it fixes a bug in version tests that was caused by setting package_name of a js_library and module_name of a ts_library to the same value. See this for more details.

Fixes #5382

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@google-cla google-cla bot added the cla: yes label Aug 10, 2021
@mattsoulanille mattsoulanille marked this pull request as ready for review August 10, 2021 17:46
@@ -1,6 +1,6 @@
/**
Copy link
Member Author

Choose a reason for hiding this comment

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

This file was not renamed. e2e/webpack_test/app.js is a new file, and version_test.ts was deleted since it's now generated by Bazel.

Copy link
Collaborator

@lina128 lina128 left a comment

Choose a reason for hiding this comment

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

Thank you for the fix, Matt! It looks much cleaner!

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @mattsoulanille)


tfjs-core/src/BUILD.bazel, line 87 at r1 (raw file):

:version_test

Is it possible to only run version_test in release flow? Similarly, we may also want to run bundle size tests in release or nightly flow. How can we support this use case? Just curious whether it's possible, the actual solution can be in a separate PR.


tools/make_version_test_file.ts, line 69 at r1 (raw file):

core

Consider parameterize this part too to accomodate other version tests, such as:
converter: https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/src/version_test.ts
wasm: https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/src/version_test.ts

Copy link
Member Author

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @lina128)


tfjs-core/src/BUILD.bazel, line 87 at r1 (raw file):

Previously, lina128 (Na Li) wrote…
:version_test

Is it possible to only run version_test in release flow? Similarly, we may also want to run bundle size tests in release or nightly flow. How can we support this use case? Just curious whether it's possible, the actual solution can be in a separate PR.

That's an interesting question. For the version test, it's more difficult to test only during release because it is added to the tests.ts file due to being a dependency of the rule that generates it, and there isn't a good way to change dependencies based on development vs release (as far as I know).

The bundle size rules are also tricky since they run in the current PR's branch and the master branch (by cloning a copy of it). The first part is easy with Bazel. We can just write a test rule that checks the output size of the bundles. The second part, comparing the size to the master branch, is more difficult since it requires running tests in a completely different Bazel workspace which has the exact same name as the current workspace. This is likely not easy to do with Bazel, and may actually be impossible. This script may need to remain as a shell script.


tools/make_version_test_file.ts, line 69 at r1 (raw file):

Previously, lina128 (Na Li) wrote…
core

Consider parameterize this part too to accomodate other version tests, such as:
converter: https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/src/version_test.ts
wasm: https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/src/version_test.ts

That's a good point. We may want to pass a template file to the make_version_test_file rule to allow different packages to use it with their own version test logic, although maybe the pattern is similar enough to implement with code generation. I think this is best addressed when we convert another package that has a version test.

@mattsoulanille mattsoulanille merged commit b206857 into tensorflow:master Aug 11, 2021
@mattsoulanille mattsoulanille deleted the webpack_test branch August 11, 2021 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webpack fails when using Bazel's .mjs output files
2 participants