Skip to content

Commit

Permalink
Feature/multi build (#4659)
Browse files Browse the repository at this point in the history
* Remove outdated ad-insertion samples

* Add new Webpack config to create a modern and a legacy build

* Adjust path to dist files in samples and functional tests

* Network interceptor sample

- integrate dash.js bundle in sample app output bundle

* Remove call to prebuild for "npm run build" to not trigger "prebuild" twice

* Remove ESM bundle from legacy build

* Remove any core.js polyfills from modern build

* Adjust Github actions

* Fix Github action

* Add examples for the different builds and rename ESM build

* Change dash.js dependency for Typescript and Webpack sample

* Add an export for CommonJS using the "require" field

---------

Co-authored-by: Bertrand Berthelot <[email protected]>
  • Loading branch information
dsilhavy and bbert authored Jan 21, 2025
1 parent a8f3da5 commit 8c873c5
Show file tree
Hide file tree
Showing 109 changed files with 2,284 additions and 1,884 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults
5 changes: 1 addition & 4 deletions .github/workflows/verify_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,4 @@ jobs:
continue-on-error: true
run: npm list
- run: npm install
- run: tsc
- run: npm run lint
- run: npm run test
- run: npm run webpack-build
- run: npm run build
7 changes: 2 additions & 5 deletions .github/workflows/verify_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ jobs:
continue-on-error: true
run: npm list
- run: npm install
- run: tsc
- run: npm run lint
- run: npm run test
- run: npm run webpack-build
- run: npm run build

run_functional_test_single_stream_lambdatest:
if: github.event.pull_request.head.repo.fork == false
Expand Down Expand Up @@ -78,7 +75,7 @@ jobs:
continue-on-error: true
run: npm list
- run: npm install
- run: npm run webpack-build
- run: npm run webpack-build-modern
- name: Start Tunnel
uses: LambdaTest/LambdaTest-tunnel-action@v2
id: tunnel
Expand Down
76 changes: 0 additions & 76 deletions build/webpack.base.cjs

This file was deleted.

64 changes: 0 additions & 64 deletions build/webpack.prod.cjs

This file was deleted.

44 changes: 44 additions & 0 deletions build/webpack/common/webpack.common.base.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const pkg = require('../../../package.json');

const commonBaseConfig = {
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js)$/,
exclude: [/core-js/],
use: [
{
loader: 'string-replace-loader',
options: {
search: '__VERSION__',
replace: pkg.version,
},
}
],
},
],
},
resolve: {
fallback: {
stream: require.resolve('stream-browserify'),
},
},
}

const prodEntries = {
'dash.all': './index.js',
'dash.mss': './src/mss/index.js',
'dash.mediaplayer': './index_mediaplayerOnly.js',
'dash.protection': './src/streaming/protection/Protection.js',
'dash.reporting': './src/streaming/metrics/MetricsReporting.js',
'dash.offline': './src/offline/index.js'
}

const devEntries = {
'dash.all': './index.js',
'dash.mss': './src/mss/index.js',
'dash.offline': './src/offline/index.js'
}

module.exports = { commonBaseConfig, prodEntries, devEntries };
54 changes: 54 additions & 0 deletions build/webpack/common/webpack.common.prod.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const EsLintWebpackPlugin = require('eslint-webpack-plugin');
const { prodEntries } = require('../common/webpack.common.base.cjs');

const plugins = [
new EsLintWebpackPlugin({
configType: 'flat',
files: [
'src/**/*.js',
'test/unit/mocks/*.js',
'test/unit/test/**/*.js'
]
})
]

const configCommonDebugProdUmd = {
mode: 'development',
entry: prodEntries,
output: {
filename: '[name].debug.js'
}
};

const configCommonMinProdUmd = {
mode: 'production',
entry: prodEntries,
output: {
filename: '[name].min.js'
},
performance: { hints: false },
plugins
};

const configCommonDebugProdEsm = {
mode: 'development',
entry: prodEntries,
output: {
filename: '[name].debug.js'
}
};

const configCommonMinProdEsm = {
mode: 'production',
entry: prodEntries,
output: {
filename: '[name].min.js'
},
optimization: {
usedExports: false,
},
performance: { hints: false },
plugins
};

module.exports = { configCommonDebugProdEsm, configCommonMinProdEsm, configCommonDebugProdUmd, configCommonMinProdUmd };
42 changes: 42 additions & 0 deletions build/webpack/legacy/webpack.legacy.base.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const path = require('path');
const { merge } = require('webpack-merge');
const { commonBaseConfig } = require('../common/webpack.common.base.cjs');

const legacyConfig = merge(commonBaseConfig, {
target: ['web', 'es5']
});

legacyConfig.module.rules[0].use.push({
loader: 'babel-loader',
options: {
sourceType: 'unambiguous',
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
targets: {
ie: '11',
},
corejs: '3.39.0',
}
],
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-transform-parameters'
],
},
},)

const umdConfig = merge(legacyConfig, {
output: {
path: path.resolve(__dirname, '../../../dist/legacy/umd'),
publicPath: '/dist/legacy/umd/',
library: 'dashjs',
libraryTarget: 'umd',
libraryExport: 'default'
},
});

module.exports = { umdConfig };
12 changes: 12 additions & 0 deletions build/webpack/legacy/webpack.legacy.prod.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { merge } = require('webpack-merge');
const { umdConfig } = require('./webpack.legacy.base.cjs');
const {
configCommonDebugProdUmd,
configCommonMinProdUmd
} = require('../common/webpack.common.prod.cjs');

const configLegacyDebugUmd = merge(umdConfig, configCommonDebugProdUmd);

const configLegacyMinUmd = merge(umdConfig, configCommonMinProdUmd);

module.exports = [configLegacyDebugUmd, configLegacyMinUmd];
48 changes: 48 additions & 0 deletions build/webpack/modern/webpack.modern.base.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const path = require('path');
const { merge } = require('webpack-merge');
const { commonBaseConfig } = require('../common/webpack.common.base.cjs');

const modernConfig = merge(commonBaseConfig, {
target: ['browserslist']
});

modernConfig.module.rules[0].use.push({
loader: 'babel-loader',
options: {
sourceType: 'unambiguous',
presets: [
[
'@babel/preset-env'
],
],
plugins: [
'@babel/plugin-transform-runtime'
],
},
},)

const umdConfig = merge(modernConfig, {
output: {
path: path.resolve(__dirname, '../../../dist/modern/umd'),
publicPath: '/dist/modern/umd/',
library: 'dashjs',
libraryTarget: 'umd',
libraryExport: 'default'
},
});

const esmConfig = merge(modernConfig, {
experiments: {
outputModule: true
},
output: {
path: path.resolve(__dirname, '../../../dist/modern/esm'),
publicPath: '/dist/modern/esm/',
library: {
type: 'module',
},
libraryExport: 'default',
},
});

module.exports = { umdConfig, esmConfig };
Loading

0 comments on commit 8c873c5

Please sign in to comment.