diff --git a/package.json b/package.json index fb51893..e36d70f 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "build": "run-s clear prettier build:*", "build:main": "tsc -p tsconfig.json", "build:module": "tsc -p tsconfig.esm.json", - "build:umd": "webpack --config webpack.config.js --mode=production && npm run generate:types", - "generate:types": "dts-bundle-generator --umd-module-name HybridFormsJS -o dist/umd/hybridforms.d.ts src/index.ts", + "build:umd": "webpack --config webpack.config.js --mode=production", "postbuild": "cd dist && zip -r ../dist.zip * && cd umd && zip -r ../../dist-umd.zip *", "clear": "rimraf dist/* && rimraf dist-umd.zip && rimraf dist.zip", "prettier": "prettier src --write", @@ -31,10 +30,10 @@ "@types/node": "^20.4.6", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", + "bundle-declarations-webpack-plugin": "^5.1.1", "chai": "^4.3.7", "chai-uuid": "^1.0.6", "dotenv": "^16.3.1", - "dts-bundle-generator": "^8.1.2", "eslint": "^8.54.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.1", diff --git a/webpack.config.js b/webpack.config.js index 4a3be5b..04f7c12 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,14 @@ -const webpack = require('webpack') -const path = require('path') -const TerserPlugin = require('terser-webpack-plugin') +const webpack = require('webpack'); +const path = require('path'); +const TerserPlugin = require('terser-webpack-plugin'); +const { + BundleDeclarationsWebpackPlugin +} = require('bundle-declarations-webpack-plugin'); + +const entry = './src/index.ts'; module.exports = { - entry: './src/index.ts', + entry, output: { path: path.resolve(__dirname, 'dist/umd'), filename: 'hybridforms.min.js', @@ -16,7 +21,7 @@ module.exports = { minimize: true, minimizer: [ new TerserPlugin({ - extractComments: false, + extractComments: false }) ] }, @@ -32,7 +37,7 @@ module.exports = { ] }, resolve: { - extensions: ['.ts', '.js', '.json'], + extensions: ['.ts', '.js', '.json'] }, externalsPresets: { node: true }, plugins: [ @@ -42,5 +47,15 @@ module.exports = { new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }), + new BundleDeclarationsWebpackPlugin({ + entry: { + filePath: entry, + output: { + umdModuleName: 'HybridFormsJS', + noBanner: true + } + }, + outFile: 'hybridforms.d.ts' + }) ] -} +};