Skip to content

Commit

Permalink
fix: inline json version (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Oct 14, 2020
1 parent 329d50a commit 326ce1c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
41 changes: 41 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
},
"devDependencies": {
"@gkatsev/rollup-plugin-bundle-worker": "^1.0.2",
"@rollup/plugin-replace": "^2.3.3",
"@videojs/generator-helpers": "~1.2.0",
"d3": "^3.4.8",
"es5-shim": "^4.5.13",
Expand Down
18 changes: 18 additions & 0 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ const generate = require('videojs-generate-rollup-config');
const worker = require('@gkatsev/rollup-plugin-bundle-worker');
const {terser} = require('rollup-plugin-terser');
const createTestData = require('./create-test-data.js');
const vhs = require('../package.json');
const mux = require('mux.js/package.json');
const mpd = require('mpd-parser/package.json');
const m3u8 = require('m3u8-parser/package.json');
const aes = require('aes-decrypter/package.json');
const replace = require('@rollup/plugin-replace');

// see https://github.com/videojs/videojs-generate-rollup-config
// for options
Expand All @@ -28,6 +34,10 @@ const options = {
defaults.module.splice(2, 0, 'worker');
defaults.browser.splice(2, 0, 'worker');
defaults.test.splice(3, 0, 'worker');

defaults.module.unshift('replace');
defaults.browser.unshift('replace');
defaults.test.unshift('replace');
defaults.test.splice(0, 0, 'createTestData');

// istanbul is only in the list for regular builds and not watch
Expand All @@ -45,6 +55,14 @@ const options = {
compress: {passes: 2},
include: [/^.+\.min\.js$/]
}),
replace: replace({
"import {version as vhsVersion} from '../package.json';": `const vhsVersion = '${vhs.version}';`,
"import {version as muxVersion} from 'mux.js/package.json';": `const muxVersion = '${mux.version}';`,
"import {version as mpdVersion} from 'mpd-parser/package.json';": `const mpdVersion = '${mpd.version}';`,
"import {version as m3u8Version} from 'm3u8-parser/package.json';": `const m3u8Version = '${m3u8.version}';`,
"import {version as aesVersion} from 'aes-decrypter/package.json';": `const aesVersion = '${aes.version}';`,
'delimiters': ['', '']
}),
createTestData: createTestData()
});
},
Expand Down
7 changes: 6 additions & 1 deletion src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ import {
comparePlaylistBandwidth,
comparePlaylistResolution
} from './playlist-selectors.js';
import {isAudioCodec, isVideoCodec, browserSupportsCodec} from '@videojs/vhs-utils/dist/codecs.js';

// IMPORTANT:
// keep these at the bottom they are replaced at build time
// because webpack and rollup without plugins do not support json
// and we do not want to break our users
import {version as vhsVersion} from '../package.json';
import {version as muxVersion} from 'mux.js/package.json';
import {version as mpdVersion} from 'mpd-parser/package.json';
import {version as m3u8Version} from 'm3u8-parser/package.json';
import {version as aesVersion} from 'aes-decrypter/package.json';
import {isAudioCodec, isVideoCodec, browserSupportsCodec} from '@videojs/vhs-utils/dist/codecs.js';

const Vhs = {
PlaylistLoader,
Expand Down

0 comments on commit 326ce1c

Please sign in to comment.