Add IIFE bundles for NPM packages
PiperOrigin-RevId: 488504360
This commit is contained in:
committed by
Copybara-Service
parent
794f64db55
commit
a12bc3fd0e
@@ -28,8 +28,8 @@ mediapipe_ts_library(
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "audio_bundle",
|
||||
config_file = "rollup.config.mjs",
|
||||
name = "audio_cjs_bundle",
|
||||
config_file = "rollup.config.cjs.mjs",
|
||||
entry_point = "audio.ts",
|
||||
format = "cjs",
|
||||
output_dir = False,
|
||||
@@ -37,6 +37,22 @@ rollup_bundle(
|
||||
":audio_lib",
|
||||
"@npm//@rollup/plugin-commonjs",
|
||||
"@npm//@rollup/plugin-node-resolve",
|
||||
"@npm//@rollup/plugin-replace",
|
||||
],
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "audio_iife_bundle",
|
||||
config_file = "rollup.config.iife.mjs",
|
||||
entry_point = "audio.ts",
|
||||
format = "iife",
|
||||
output_dir = False,
|
||||
deps = [
|
||||
":audio_lib",
|
||||
"@npm//@rollup/plugin-commonjs",
|
||||
"@npm//@rollup/plugin-node-resolve",
|
||||
"@npm//@rollup/plugin-replace",
|
||||
"@npm//@rollup/plugin-terser",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -52,7 +68,8 @@ pkg_npm(
|
||||
deps = [
|
||||
"wasm/audio_wasm_internal.js",
|
||||
"wasm/audio_wasm_internal.wasm",
|
||||
":audio_bundle",
|
||||
":audio_cjs_bundle",
|
||||
":audio_iife_bundle",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -65,8 +82,8 @@ mediapipe_ts_library(
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "text_bundle",
|
||||
config_file = "rollup.config.mjs",
|
||||
name = "text_cjs_bundle",
|
||||
config_file = "rollup.config.cjs.mjs",
|
||||
entry_point = "text.ts",
|
||||
format = "cjs",
|
||||
output_dir = False,
|
||||
@@ -74,6 +91,22 @@ rollup_bundle(
|
||||
":text_lib",
|
||||
"@npm//@rollup/plugin-commonjs",
|
||||
"@npm//@rollup/plugin-node-resolve",
|
||||
"@npm//@rollup/plugin-replace",
|
||||
],
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "text_iife_bundle",
|
||||
config_file = "rollup.config.iife.mjs",
|
||||
entry_point = "text.ts",
|
||||
format = "iife",
|
||||
output_dir = False,
|
||||
deps = [
|
||||
":text_lib",
|
||||
"@npm//@rollup/plugin-commonjs",
|
||||
"@npm//@rollup/plugin-node-resolve",
|
||||
"@npm//@rollup/plugin-replace",
|
||||
"@npm//@rollup/plugin-terser",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -89,7 +122,8 @@ pkg_npm(
|
||||
deps = [
|
||||
"wasm/text_wasm_internal.js",
|
||||
"wasm/text_wasm_internal.wasm",
|
||||
":text_bundle",
|
||||
":text_cjs_bundle",
|
||||
":text_iife_bundle",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -102,8 +136,8 @@ mediapipe_ts_library(
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "vision_bundle",
|
||||
config_file = "rollup.config.mjs",
|
||||
name = "vision_cjs_bundle",
|
||||
config_file = "rollup.config.cjs.mjs",
|
||||
entry_point = "vision.ts",
|
||||
format = "cjs",
|
||||
output_dir = False,
|
||||
@@ -111,6 +145,22 @@ rollup_bundle(
|
||||
":vision_lib",
|
||||
"@npm//@rollup/plugin-commonjs",
|
||||
"@npm//@rollup/plugin-node-resolve",
|
||||
"@npm//@rollup/plugin-replace",
|
||||
],
|
||||
)
|
||||
|
||||
rollup_bundle(
|
||||
name = "vision_iife_bundle",
|
||||
config_file = "rollup.config.iife.mjs",
|
||||
entry_point = "vision.ts",
|
||||
format = "iife",
|
||||
output_dir = False,
|
||||
deps = [
|
||||
":vision_lib",
|
||||
"@npm//@rollup/plugin-commonjs",
|
||||
"@npm//@rollup/plugin-node-resolve",
|
||||
"@npm//@rollup/plugin-replace",
|
||||
"@npm//@rollup/plugin-terser",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -126,6 +176,7 @@ pkg_npm(
|
||||
deps = [
|
||||
"wasm/vision_wasm_internal.js",
|
||||
"wasm/vision_wasm_internal.wasm",
|
||||
":vision_bundle",
|
||||
":vision_cjs_bundle",
|
||||
":vision_iife_bundle",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
"name": "@mediapipe/tasks-__NAME__",
|
||||
"version": "__VERSION__",
|
||||
"description": "__DESCRIPTION__",
|
||||
"main": "__NAME___bundle.js",
|
||||
"module": "__NAME___bundle.js",
|
||||
"main": "__NAME___cjs_bundle.js",
|
||||
"module": "__NAME___cjs_bundle.js",
|
||||
"jsdeliver": "__NAME___iife_bundle.js",
|
||||
"exports": {
|
||||
".": "./__NAME___bundle.js",
|
||||
".": "./__NAME___cjs_bundle.js",
|
||||
"./loader": "./wasm/__NAME___wasm_internal.js",
|
||||
"./wasm": "./wasm/__NAME___wasm_internal.wasm"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
// Workaround for https://github.com/protocolbuffers/protobuf-javascript/issues/151
|
||||
replace({
|
||||
'var calculator_options_pb = {};': 'var calculator_options_pb = {}; var mediapipe_framework_calculator_options_pb = calculator_options_pb;',
|
||||
delimiters: ['', '']
|
||||
}),
|
||||
resolve(),
|
||||
commonjs()
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import terser from '@rollup/plugin-terser';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
|
||||
export default {
|
||||
output: {
|
||||
name: 'bundle',
|
||||
sourcemap: false
|
||||
},
|
||||
plugins: [
|
||||
// Workaround for https://github.com/protocolbuffers/protobuf-javascript/issues/151
|
||||
replace({
|
||||
'var calculator_options_pb = {};': 'var calculator_options_pb = {}; var mediapipe_framework_calculator_options_pb = calculator_options_pb;',
|
||||
delimiters: ['', '']
|
||||
}),
|
||||
resolve({browser: true}),
|
||||
commonjs(),
|
||||
terser()
|
||||
]
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
resolve(),
|
||||
commonjs()
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user