Commit Graph

6 Commits

Author SHA1 Message Date
Matthew Soulanille 6a002b730c
Update rollup and its plugins to 3.20.2 (#7579)
Change the config file extension from .js to .mjs. This update only applies to
Bazel packages.
2023-04-12 20:14:42 -07:00
Matthew Soulanille 060f16b654
Add tslib, which es5 bundling depends on (#6536)
tslib was formerly included by chance since typescript depends on it. With this change, we explicitly depend on it and add it as a dependency to the tfjs_bundle Bazel rule. Rollup uses the es5 downleveling plugin, which uses tslib for bundle size optimization.
2022-06-16 10:45:07 -07:00
Matthew Soulanille 42db7c5f99
Modularize rollup templates so they can be more easily reused (#6503)
Create tools/make_rollup_config.ts, which exports a function to create a tfjs rollup configuration. The only thing tools/rollup_template.config.js does now is import and call that function.

Move the custom es5 downleveling plugin to its own file.

Co-authored-by: Na Li <linazhao@google.com>
2022-06-08 09:48:12 -07:00
Matthew Soulanille 1d0c63f3be
Add 'leave_as_require' option to tfjs_bundle (#6005)
BUG
* Allow bundles to keep 'require' calls as 'require' calls

@rollup/plugin-commonjs rewrites 'require' calls to 'import' statements, but this is not always desirable. This commit adds the 'leave_as_require' option to 'tfjs_bundle', which allows specifying a list of modules to leave as 'require' calls.

This commit also disables @rollup/plugin-commonjs when targeting commonjs, since require calls do not need to be transpiled for commonjs.

* Always use the commonjs plugin

It is required even for node cjs bundles because we still want to bundle the commonjs modules. Without the plugin, they're left as 'require()' calls, but with the plugin, their contents are included in the bundle.
2022-01-12 16:47:24 -08:00
Jing Jin 6cfa88edfc
tfjs_bundle related improvements (#5337)
* Hook up the "external" parameter of tfjs_bundle rule with rollup_bundle, and add "globals" parameter to tfjs_bundle

* fix lint error

* fix

* fix

* fix
2021-07-16 16:31:04 -07:00
Matthew Soulanille e745d42cae
Use Bazel and ts_library to build core and backend-cpu (#5133)
This PR builds tfjs-core and tfjs-backend-cpu using Bazel and makes the build outputs available to the other packages in the monorepo. It also sets up Bazel rules and macros that facilitate converting other packages in the monorepo to Bazel. For more details, see #5133.
2021-07-15 14:50:45 -07:00