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

Split native bundles into separate target #255

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bazel_dep(name = "rules_player")

git_override(
remote = "https://github.com/player-ui/rules_player.git",
commit = "10d56d526846171b2e05dce00c03b8a4f7310cf0",
commit = "d9c8d7c1802916dc6e4619b5da2ac0cab590944a",
module_name = "rules_player",
)
# local_path_override(module_name = "rules_player", path = "../rules_player")
Expand Down
1 change: 1 addition & 0 deletions core/make-flow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/make-flow",
native_bundle = "MakeFlow",
build_deps = [
"//:tsup_config",
"//:typings",
Expand Down
1 change: 0 additions & 1 deletion core/make-flow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/make-flow",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/MakeFlow.native.js",
"dependencies": {
"@player-ui/types": "workspace:*"
}
Expand Down
1 change: 1 addition & 0 deletions core/partial-match-registry/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/partial-match-registry",
native_bundle = "Registry",
deps = [
"//:node_modules/@types/dlv",
"//:node_modules/dlv",
Expand Down
3 changes: 1 addition & 2 deletions core/partial-match-registry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "@player-ui/partial-match-registry",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/Registry.native.js"
"main": "src/index.ts"
}
1 change: 1 addition & 0 deletions core/player/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/player",
native_bundle = "Player",
test_deps = [
":node_modules/@player-ui/make-flow",
"//:vitest_config",
Expand Down
1 change: 0 additions & 1 deletion core/player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/player",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/Player.native.js",
"dependencies": {
"@player-ui/partial-match-registry": "workspace:*",
"@player-ui/make-flow": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions plugins/beacon/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/beacon-plugin",
native_bundle = "BeaconPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/beacon/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/beacon-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/BeaconPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*",
"@player-ui/types": "workspace:*"
Expand Down
1 change: 1 addition & 0 deletions plugins/check-path/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/check-path-plugin",
native_bundle = "PubSubPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/check-path/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/check-path-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/PubSubPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*"
},
Expand Down
1 change: 1 addition & 0 deletions plugins/common-expressions/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/common-expressions-plugin",
native_bundle = "CommonExpressionsPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/common-expressions/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/common-expressions-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/CommonExpressionsPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*"
},
Expand Down
1 change: 1 addition & 0 deletions plugins/common-types/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/common-types-plugin",
native_bundle = "CommonTypesPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/common-types/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/common-types-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/CommonTypesPlugin.native.js",
"dependencies": {
"@player-ui/types-provider-plugin": "workspace:*"
},
Expand Down
1 change: 1 addition & 0 deletions plugins/computed-properties/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/computed-properties-plugin",
native_bundle = "ComputedPropertiesPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/computed-properties/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/computed-properties-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/ComputedPropertiesPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*"
},
Expand Down
1 change: 1 addition & 0 deletions plugins/expression/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/expression-plugin",
native_bundle = "ExpressionPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/expression/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/expression-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/ExpressionPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*"
}
Expand Down
1 change: 1 addition & 0 deletions plugins/external-action/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/external-action-plugin",
native_bundle = "ExternalActionPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/external-action/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/external-action-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/ExternalActionPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*"
}
Expand Down
1 change: 1 addition & 0 deletions plugins/markdown/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/markdown-plugin",
native_bundle = "MarkdownPlugin",
peer_deps = [
":node_modules/@player-ui/player",
":node_modules/@player-ui/types",
Expand Down
1 change: 0 additions & 1 deletion plugins/markdown/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/markdown-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/MarkdownPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*",
"@player-ui/types": "workspace:*"
Expand Down
1 change: 1 addition & 0 deletions plugins/metrics/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/metrics-plugin",
native_bundle = "MetricsPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/metrics/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/metrics-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/MetricsPlugin.native.js",
"dependencies": {
"@player-ui/beacon-plugin": "workspace:*"
},
Expand Down
1 change: 1 addition & 0 deletions plugins/partial-match-fingerprint/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/partial-match-fingerprint-plugin",
native_bundle = "PartialMatchFingerprintPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/partial-match-fingerprint/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/partial-match-fingerprint-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/PartialMatchFingerprintPlugin.native.js",
"dependencies": {
"@player-ui/partial-match-registry": "workspace:*"
},
Expand Down
1 change: 1 addition & 0 deletions plugins/pubsub/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/pubsub-plugin",
native_bundle = "PubSubPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/pubsub/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/pubsub",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/PubSubPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*"
}
Expand Down
1 change: 1 addition & 0 deletions plugins/reference-assets/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/reference-assets-plugin",
native_bundle = "ReferenceAssetsPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/reference-assets/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/reference-assets-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/ReferenceAssetsPlugin.native.js",
"dependencies": {
"@player-ui/asset-transform-plugin": "workspace:*",
"@player-ui/beacon-plugin": "workspace:*"
Expand Down
1 change: 1 addition & 0 deletions plugins/stage-revert-data/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/stage-revert-data-plugin",
native_bundle = "StageRevertDataPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/stage-revert-data/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/stage-revert-data-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/StageRevertDataPlugin.native.js",
"devDependencies": {
"@player-ui/make-flow": "workspace:*",
"@player-ui/types": "workspace:*"
Expand Down
1 change: 1 addition & 0 deletions plugins/types-provider/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vitest_config(name = "vitest_config")

js_pipeline(
package_name = "@player-ui/types-provider-plugin",
native_bundle = "TypesProviderPlugin",
peer_deps = [
":node_modules/@player-ui/player",
],
Expand Down
1 change: 0 additions & 1 deletion plugins/types-provider/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@player-ui/types-provider-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"bundle": "dist/TypesProviderPlugin.native.js",
"peerDependencies": {
"@player-ui/player": "workspace:*"
},
Expand Down
46 changes: 25 additions & 21 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,33 @@ export function createConfig() {
...options,
};

const bundleConfig: Options[] = [];
if (process.env.PLAYER_NATIVE_BUNDLE) {
const bundleEntryName = process.env.PLAYER_NATIVE_BUNDLE;
const bundleFileTarget = path.join(
"dist",
bundleEntryName + ".native.js",
);
return [
{
...defaultOptions,
globalName: bundleEntryName,
external: [],
format: ["iife"],
async onSuccess() {
await fs.promises.copyFile(
"dist/index.global.js",
bundleFileTarget,
);
await fs.promises.copyFile(
"dist/index.global.js.map",
bundleFileTarget + ".map",
);

if (pkgJson.bundle) {
const bundleFileTarget = pkgJson.bundle;
const bundleEntryName = path.basename(bundleFileTarget, ".native.js");

bundleConfig.push({
...defaultOptions,
globalName: bundleEntryName,
format: ["iife"],
async onSuccess() {
await fs.promises.copyFile("dist/index.global.js", bundleFileTarget);
await fs.promises.copyFile(
"dist/index.global.js.map",
bundleFileTarget + ".map",
);

await fs.promises.rm("dist/index.global.js");
await fs.promises.rm("dist/index.global.js.map");
await fs.promises.rm("dist/index.global.js");
await fs.promises.rm("dist/index.global.js.map");
},
},
});
];
}

return [
Expand All @@ -58,15 +64,13 @@ export function createConfig() {
},
format: ["esm"],
outExtension: () => ({ js: ".mjs" }),
minify: true,
},
{
...defaultOptions,
format: "cjs",
outDir: "./dist/cjs/",
outExtension: () => ({ js: ".cjs" }),
},
...bundleConfig,
];
});
}