From e530ae2d500d01626c05aaf3cb148aa645c68f94 Mon Sep 17 00:00:00 2001 From: Sam Verschueren Date: Wed, 1 Nov 2017 20:42:25 +0100 Subject: [PATCH] Generate single distribution bundle - fixes #16 (#18) --- package.json | 22 +++++++++++++++------- tsconfig.json | 1 + webpack.config.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 webpack.config.js diff --git a/package.json b/package.json index 77784ec..a209fb0 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,12 @@ }, "scripts": { "prerelease": "npm run build", - "pretest": "npm run build -- --sourceMap", + "pretest": "npm run compile -- --sourceMap", "test": "npm run lint && nyc ava dist/test", "lint": "tslint --project .", - "build": "del dist && tsc --declaration" + "build": "npm run clean && webpack", + "compile": "npm run clean && tsc", + "clean": "del dist" }, "files": [ "dist" @@ -44,18 +46,24 @@ "instanceof", "object" ], - "dependencies": { - "@sindresorhus/is": "^0.4.0", - "vali-date": "^1.0.0" - }, "devDependencies": { + "@sindresorhus/is": "^0.4.0", "@types/node": "^8.0.31", "ava": "*", + "awesome-typescript-loader": "^3.2.3", "codecov": "^2.3.0", "del-cli": "^1.1.0", + "license-webpack-plugin": "^1.1.1", "nyc": "^11.2.1", "tslint": "^5.8.0", "tslint-xo": "^0.2.0", - "typescript": "^2.6.1" + "typescript": "^2.6.1", + "vali-date": "^1.0.0", + "webpack": "^3.8.1" + }, + "nyc": { + "exclude": [ + "dist/test" + ] } } diff --git a/tsconfig.json b/tsconfig.json index 5de6809..4b32b1a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ ], "module": "commonjs", "moduleResolution": "node", + "declaration": true, "pretty": true, "newLine": "lf", "stripInternal": true, diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..f366e85 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,31 @@ +'use strict'; +const webpack = require('webpack'); +const license = require('license-webpack-plugin'); + +module.exports = { + entry: './source/index.ts', + target: 'node', + devtool: 'source-map', + output: { + filename: 'dist/index.js', + libraryTarget: 'commonjs2' + }, + resolve: { + extensions: ['.ts', '.js'] + }, + plugins: [ + new webpack.optimize.ModuleConcatenationPlugin(), + new license.LicenseWebpackPlugin({ + pattern: /.*/, + outputFilename: 'dist/licenses.txt' + }) + ], + module: { + rules: [ + { + test: /\.ts$/, + loader: 'awesome-typescript-loader' + } + ] + } +};