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

Fix bundle size of Conviva connector #15

Merged
merged 6 commits into from
Apr 5, 2024
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
5 changes: 5 additions & 0 deletions .changeset/thick-carpets-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@theoplayer/conviva-connector-web": patch
---

Fixed an issue where the THEOplayer library and the Yospace connector were accidentally bundled together with the Conviva connector.
2 changes: 1 addition & 1 deletion cmcd/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const banner = `
* THEOplayer CMCD Connector v${version}
*/`.trim();

export default getSharedBuildConfiguration(fileName, globalName, banner);
export default getSharedBuildConfiguration({ fileName, globalName, banner });
8 changes: 6 additions & 2 deletions conviva/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const banner = `
/**
* THEOplayer Conviva Connector v${version}
*/`.trim();
const external = ['@convivainc/conviva-js-coresdk', '@theoplayer/yospace-connector-web'];
const globals = {
'@convivainc/conviva-js-coresdk': 'Conviva',
'@theoplayer/yospace-connector-web': 'THEOplayerYospaceConnector'
};


export default getSharedBuildConfiguration(fileName, globalName, banner);
export default getSharedBuildConfiguration({ fileName, globalName, banner, external, globals });
2 changes: 1 addition & 1 deletion nielsen/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ const banner = `
* Nielsen Web Connector v${version}
*/`.trim();

export default getSharedBuildConfiguration(fileName, globalName, banner);
export default getSharedBuildConfiguration({ fileName, globalName, banner });
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

121 changes: 63 additions & 58 deletions tools/build.mjs
Original file line number Diff line number Diff line change
@@ -1,61 +1,66 @@
import {defineConfig} from "rollup";
import nodeResolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
import { defineConfig } from 'rollup';
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';

export function getSharedBuildConfiguration(fileName, globalName, banner) {
return defineConfig([{
input: {
[fileName]: "src/index.ts"
},
output: [
{
dir: "dist",
entryFileNames: "[name].umd.js",
name: globalName,
format: "umd",
indent: false,
banner,
globals: {theoplayer: "THEOplayer"}
export function getSharedBuildConfiguration({ fileName, globalName, banner, external, globals }) {
return defineConfig([
{
input: {
[fileName]: 'src/index.ts'
},
{
dir: "dist",
entryFileNames: "[name].esm.js",
format: "esm",
indent: false,
banner
}
],
plugins: [
nodeResolve({
extensions: [".ts", ".js"]
}),
commonjs({
include: ['node_modules/**', '../node_modules/**']
}),
typescript({
tsconfig: "tsconfig.json",
module: "es2015",
include: ["src/**/*"]
})
]
}, {
input: {
[fileName]: "src/index.ts"
output: [
{
dir: 'dist',
entryFileNames: '[name].umd.js',
name: globalName,
format: 'umd',
indent: false,
banner,
globals: { theoplayer: 'THEOplayer', ...(globals ?? {}) }
},
{
dir: 'dist',
entryFileNames: '[name].esm.js',
format: 'esm',
indent: false,
banner
}
],
external: ['theoplayer', ...(external ?? [])],
plugins: [
nodeResolve({
extensions: ['.ts', '.js']
}),
commonjs({
include: ['node_modules/**', '../node_modules/**']
}),
typescript({
tsconfig: 'tsconfig.json',
module: 'es2015',
include: ['src/**/*']
})
]
},
output: [
{
dir: "dist",
format: "esm",
banner,
footer: `export as namespace ${globalName};`
}
],
plugins: [
dts({
tsconfig: "tsconfig.json",
})
]
}]);
}
{
input: {
[fileName]: 'src/index.ts'
},
output: [
{
dir: 'dist',
format: 'esm',
banner,
footer: `export as namespace ${globalName};`
}
],
external: ['theoplayer', ...(external ?? [])],
plugins: [
dts({
tsconfig: 'tsconfig.json'
})
]
}
]);
}
2 changes: 1 addition & 1 deletion yospace/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const banner = `
* THEOplayer Yospace Connector v${version}
*/`.trim();

export default getSharedBuildConfiguration(fileName, globalName, banner);
export default getSharedBuildConfiguration({ fileName, globalName, banner });