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

feat: export name and version on module #34

Merged
merged 4 commits into from
Nov 8, 2017
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
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
5 changes: 5 additions & 0 deletions src/k-provider/ovp/ovp-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type playerConfig = {
plugins: Object
};

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

/**
* Ovp provider
* @classdesc
Expand Down Expand Up @@ -184,3 +187,5 @@ export class OvpProvider {
}

export default OvpProvider;
const packageName = __NAME__ + "-ovp";
export {__VERSION__ as VERSION, packageName as NAME};
5 changes: 5 additions & 0 deletions src/k-provider/ovp/services/stats-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import RequestBuilder from '../../request-builder'
import Configuration from '../config'
import {param} from '../../../util/param'

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

const SERVICE_NAME: string = "stats";
/**
* Ovp stats service methods
Expand Down Expand Up @@ -37,3 +40,5 @@ export default class StatsService extends OvpService {
}

export {StatsService, Configuration, RequestBuilder};
const packageName = __NAME__ + "-stats-service";
export {__VERSION__ as VERSION, packageName as NAME};
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 @@ -23,7 +35,7 @@ module.exports = {
devtoolModuleFilenameTemplate: "./providers/[resource-path]",
},
devtool: 'source-map',
plugins: PROD ? [new webpack.optimize.UglifyJsPlugin({sourceMap: true})] : [],
plugins: plugins,
module: {
rules: [{
test: /\.js$/,
Expand Down