Add CommonJS bundle for MediaPipe Tasks

Fixes https://github.com/google/mediapipe/issues/4398

PiperOrigin-RevId: 538539711
This commit is contained in:
Sebastian Schmidt 2023-06-07 11:09:27 -07:00 committed by Copybara-Service
parent 489e927410
commit a7cd7b9a32
4 changed files with 57 additions and 4 deletions

View File

@ -43,7 +43,23 @@ rollup_bundle(
entry_point = "index.ts",
format = "esm",
output_dir = False,
sourcemap = "false",
sourcemap = "true",
deps = [
":audio_lib",
"@npm//@rollup/plugin-commonjs",
"@npm//@rollup/plugin-node-resolve",
"@npm//@rollup/plugin-terser",
"@npm//google-protobuf",
],
)
rollup_bundle(
name = "audio_bundle_cjs",
config_file = "//mediapipe/tasks/web:rollup.config.mjs",
entry_point = "index.ts",
format = "cjs",
output_dir = False,
sourcemap = "true",
deps = [
":audio_lib",
"@npm//@rollup/plugin-commonjs",
@ -76,6 +92,7 @@ pkg_npm(
"wasm/audio_wasm_nosimd_internal.js",
"wasm/audio_wasm_nosimd_internal.wasm",
":audio_bundle",
":audio_bundle_cjs",
":package_json",
],
)

View File

@ -2,7 +2,9 @@
"name": "@mediapipe/tasks-__NAME__",
"version": "__VERSION__",
"description": "__DESCRIPTION__",
"main": "__NAME___bundle.js",
"main": "__NAME___bundle_cjs.js",
"browser": "__NAME___bundle.js",
"module": "__NAME___bundle.js",
"author": "mediapipe@google.com",
"license": "Apache-2.0",
"types": "__TYPES__",

View File

@ -44,7 +44,23 @@ rollup_bundle(
entry_point = "index.ts",
format = "esm",
output_dir = False,
sourcemap = "false",
sourcemap = "true",
deps = [
":text_lib",
"@npm//@rollup/plugin-commonjs",
"@npm//@rollup/plugin-node-resolve",
"@npm//@rollup/plugin-terser",
"@npm//google-protobuf",
],
)
rollup_bundle(
name = "text_bundle_cjs",
config_file = "//mediapipe/tasks/web:rollup.config.mjs",
entry_point = "index.ts",
format = "cjs",
output_dir = False,
sourcemap = "true",
deps = [
":text_lib",
"@npm//@rollup/plugin-commonjs",
@ -78,5 +94,6 @@ pkg_npm(
"wasm/text_wasm_nosimd_internal.wasm",
":package_json",
":text_bundle",
":text_bundle_cjs",
],
)

View File

@ -55,7 +55,23 @@ rollup_bundle(
entry_point = "index.ts",
format = "esm",
output_dir = False,
sourcemap = "false",
sourcemap = "true",
deps = [
":vision_lib",
"@npm//@rollup/plugin-commonjs",
"@npm//@rollup/plugin-node-resolve",
"@npm//@rollup/plugin-terser",
"@npm//google-protobuf",
],
)
rollup_bundle(
name = "vision_bundle_cjs",
config_file = "//mediapipe/tasks/web:rollup.config.mjs",
entry_point = "index.ts",
format = "cjs",
output_dir = False,
sourcemap = "true",
deps = [
":vision_lib",
"@npm//@rollup/plugin-commonjs",
@ -89,5 +105,6 @@ pkg_npm(
"wasm/vision_wasm_nosimd_internal.wasm",
":package_json",
":vision_bundle",
":vision_bundle_cjs",
],
)