Use .mjs for ESM Modules and use .cjs for CommonJS
PiperOrigin-RevId: 539664711
This commit is contained in:
parent
ac4f60a793
commit
8a2ec518de
|
@ -38,7 +38,7 @@ mediapipe_files(srcs = [
|
|||
])
|
||||
|
||||
rollup_bundle(
|
||||
name = "audio_bundle",
|
||||
name = "audio_bundle_mjs",
|
||||
config_file = "//mediapipe/tasks/web:rollup.config.mjs",
|
||||
entry_point = "index.ts",
|
||||
format = "esm",
|
||||
|
@ -69,6 +69,29 @@ rollup_bundle(
|
|||
],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "audio_sources",
|
||||
srcs = [
|
||||
":audio_bundle_cjs",
|
||||
":audio_bundle_mjs",
|
||||
],
|
||||
outs = [
|
||||
"audio_bundle.cjs",
|
||||
"audio_bundle.cjs.map",
|
||||
"audio_bundle.mjs",
|
||||
"audio_bundle.mjs.map",
|
||||
],
|
||||
cmd = (
|
||||
"for FILE in $(SRCS); do " +
|
||||
" OUT_FILE=$(GENDIR)/mediapipe/tasks/web/audio/$$(" +
|
||||
" basename $$FILE | sed -E 's/_([cm])js\\.js/.\\1js/'" +
|
||||
" ); " +
|
||||
" echo $$FILE ; echo $$OUT_FILE ; " +
|
||||
" cp $$FILE $$OUT_FILE ; " +
|
||||
"done;"
|
||||
),
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "package_json",
|
||||
srcs = ["//mediapipe/tasks/web:package.json"],
|
||||
|
@ -91,8 +114,7 @@ pkg_npm(
|
|||
"wasm/audio_wasm_internal.wasm",
|
||||
"wasm/audio_wasm_nosimd_internal.js",
|
||||
"wasm/audio_wasm_nosimd_internal.wasm",
|
||||
":audio_bundle",
|
||||
":audio_bundle_cjs",
|
||||
":audio_sources",
|
||||
":package_json",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
"name": "@mediapipe/tasks-__NAME__",
|
||||
"version": "__VERSION__",
|
||||
"description": "__DESCRIPTION__",
|
||||
"main": "__NAME___bundle_cjs.js",
|
||||
"browser": "__NAME___bundle.js",
|
||||
"module": "__NAME___bundle.js",
|
||||
"main": "__NAME___bundle.cjs",
|
||||
"browser": "__NAME___bundle.mjs",
|
||||
"module": "__NAME___bundle.mjs",
|
||||
"author": "mediapipe@google.com",
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"types": "__TYPES__",
|
||||
"homepage": "http://mediapipe.dev",
|
||||
"keywords": [ "AR", "ML", "Augmented", "MediaPipe", "MediaPipe Tasks" ]
|
||||
|
|
|
@ -39,7 +39,7 @@ mediapipe_ts_library(
|
|||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "text_bundle",
|
||||
name = "text_bundle_mjs",
|
||||
config_file = "//mediapipe/tasks/web:rollup.config.mjs",
|
||||
entry_point = "index.ts",
|
||||
format = "esm",
|
||||
|
@ -70,6 +70,29 @@ rollup_bundle(
|
|||
],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "text_sources",
|
||||
srcs = [
|
||||
":text_bundle_cjs",
|
||||
":text_bundle_mjs",
|
||||
],
|
||||
outs = [
|
||||
"text_bundle.cjs",
|
||||
"text_bundle.cjs.map",
|
||||
"text_bundle.mjs",
|
||||
"text_bundle.mjs.map",
|
||||
],
|
||||
cmd = (
|
||||
"for FILE in $(SRCS); do " +
|
||||
" OUT_FILE=$(GENDIR)/mediapipe/tasks/web/text/$$(" +
|
||||
" basename $$FILE | sed -E 's/_([cm])js\\.js/.\\1js/'" +
|
||||
" ); " +
|
||||
" echo $$FILE ; echo $$OUT_FILE ; " +
|
||||
" cp $$FILE $$OUT_FILE ; " +
|
||||
"done;"
|
||||
),
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "package_json",
|
||||
srcs = ["//mediapipe/tasks/web:package.json"],
|
||||
|
@ -93,7 +116,6 @@ pkg_npm(
|
|||
"wasm/text_wasm_nosimd_internal.js",
|
||||
"wasm/text_wasm_nosimd_internal.wasm",
|
||||
":package_json",
|
||||
":text_bundle",
|
||||
":text_bundle_cjs",
|
||||
":text_sources",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -50,7 +50,7 @@ mediapipe_ts_library(
|
|||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "vision_bundle",
|
||||
name = "vision_bundle_mjs",
|
||||
config_file = "//mediapipe/tasks/web:rollup.config.mjs",
|
||||
entry_point = "index.ts",
|
||||
format = "esm",
|
||||
|
@ -81,6 +81,29 @@ rollup_bundle(
|
|||
],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "vision_sources",
|
||||
srcs = [
|
||||
":vision_bundle_cjs",
|
||||
":vision_bundle_mjs",
|
||||
],
|
||||
outs = [
|
||||
"vision_bundle.cjs",
|
||||
"vision_bundle.cjs.map",
|
||||
"vision_bundle.mjs",
|
||||
"vision_bundle.mjs.map",
|
||||
],
|
||||
cmd = (
|
||||
"for FILE in $(SRCS); do " +
|
||||
" OUT_FILE=$(GENDIR)/mediapipe/tasks/web/vision/$$(" +
|
||||
" basename $$FILE | sed -E 's/_([cm])js\\.js/.\\1js/'" +
|
||||
" ); " +
|
||||
" echo $$FILE ; echo $$OUT_FILE ; " +
|
||||
" cp $$FILE $$OUT_FILE ; " +
|
||||
"done;"
|
||||
),
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "package_json",
|
||||
srcs = ["//mediapipe/tasks/web:package.json"],
|
||||
|
@ -104,7 +127,6 @@ pkg_npm(
|
|||
"wasm/vision_wasm_nosimd_internal.js",
|
||||
"wasm/vision_wasm_nosimd_internal.wasm",
|
||||
":package_json",
|
||||
":vision_bundle",
|
||||
":vision_bundle_cjs",
|
||||
":vision_sources",
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user