Skip to content

Commit

Permalink
feat: export name and version on module (#33)
Browse files Browse the repository at this point in the history
add export of name and version of library
  • Loading branch information
OrenMe committed Nov 8, 2017
1 parent f03d304 commit 8ca7829
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
},
"globals": {
"should": true,
"sinon": true
"sinon": true,
"__VERSION__": true,
"__NAME__": true
},
"rules": {
"mocha-no-only/mocha-no-only": "off",
Expand Down
9 changes: 9 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const webpack = require("webpack");
const packageData = require("./package.json");

const isWindows = /^win/.test(process.platform);
const isMacOS = /^darwin/.test(process.platform);
// Create custom launcher in case running with Travis
Expand Down Expand Up @@ -39,6 +42,12 @@ module.exports = function (config) {
'coverage'
],
webpack: {
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(packageData.version),
__NAME__: JSON.stringify(packageData.name)
})
],
devtool: 'inline-source-map',
module: {
rules: [{
Expand Down
6 changes: 6 additions & 0 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,12 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
}
}

declare var __VERSION__: string;
declare var __NAME__: string;

export {__VERSION__ as VERSION, __NAME__ as NAME};


// Register DashAdapter to the media source adapter manager
if (DashAdapter.isSupported()) {
registerMediaSourceAdapter(DashAdapter);
Expand Down
14 changes: 13 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
const webpack = require("webpack");
const path = require("path");
const PROD = (process.env.NODE_ENV === 'production');
const packageData = require("./package.json");

let plugins = [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(packageData.version),
__NAME__: JSON.stringify(packageData.name)
})
];

if (PROD) {
plugins.push(new webpack.optimize.UglifyJsPlugin({sourceMap: true}));
}

module.exports = {
context: __dirname + "/src",
Expand All @@ -15,7 +27,7 @@ module.exports = {
devtoolModuleFilenameTemplate: "./dash/[resource-path]",
},
devtool: 'source-map',
plugins: PROD ? [new webpack.optimize.UglifyJsPlugin({sourceMap: true})] : [],
plugins: plugins,
module: {
rules: [{
test: /\.js$/,
Expand Down

0 comments on commit 8ca7829

Please sign in to comment.