diff --git a/package-lock.json b/package-lock.json index 60ceb60b..4d03897c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,6 @@ "@types/node": "22.7.4", "@types/react": "18.3.10", "@types/react-dom": "18.3.0", - "@types/webpack-node-externals": "3.0.4", "@typescript-eslint/eslint-plugin": "8.7.0", "@typescript-eslint/parser": "8.7.0", "cspell": "8.14.4", @@ -52,8 +51,7 @@ "typescript": "5.5.4", "webpack": "5.95.0", "webpack-cli": "5.1.4", - "webpack-dev-server": "5.1.0", - "webpack-node-externals": "3.0.0" + "webpack-dev-server": "5.1.0" }, "engines": { "node": ">=20.0.0" @@ -3843,16 +3841,6 @@ "@types/node": "*" } }, - "node_modules/@types/webpack-node-externals": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/webpack-node-externals/-/webpack-node-externals-3.0.4.tgz", - "integrity": "sha512-8Z3/edqxE3RRlOJwKSgOFxLZRt/i1qFlv/Bi308ZUKo9jh8oGngd9r8GR0ZNKW5AEJq8QNQE3b17CwghTjQ0Uw==", - "dev": true, - "dependencies": { - "@types/node": "*", - "webpack": "^5" - } - }, "node_modules/@types/ws": { "version": "8.5.12", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", @@ -13163,15 +13151,6 @@ "node": ">=10.0.0" } }, - "node_modules/webpack-node-externals": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/webpack-node-externals/-/webpack-node-externals-3.0.0.tgz", - "integrity": "sha512-LnL6Z3GGDPht/AigwRh2dvL9PQPFQ8skEpVrWZXLWBYmqcaojHNN0onvHzie6rq7EWKrrBfPYqNEzTJgiwEQDQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/webpack-sources": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", diff --git a/package.json b/package.json index 727e761b..9b40e6c9 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,6 @@ "@types/node": "22.7.4", "@types/react": "18.3.10", "@types/react-dom": "18.3.0", - "@types/webpack-node-externals": "3.0.4", "@typescript-eslint/eslint-plugin": "8.7.0", "@typescript-eslint/parser": "8.7.0", "cspell": "8.14.4", @@ -87,7 +86,6 @@ "typescript": "5.5.4", "webpack": "5.95.0", "webpack-cli": "5.1.4", - "webpack-dev-server": "5.1.0", - "webpack-node-externals": "3.0.0" + "webpack-dev-server": "5.1.0" } } diff --git a/webpack.config.ts b/webpack.config.ts index 15d71b34..a455df7e 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -4,7 +4,7 @@ import * as path from 'node:path'; import * as MiniCssExtractPlugin from 'mini-css-extract-plugin'; import * as webpack from 'webpack'; -import * as NodeExternals from 'webpack-node-externals'; +import { ExternalItemFunctionData } from 'webpack'; // eslint-disable-next-line @typescript-eslint/no-require-imports const packageJSON = require('./package.json'); @@ -84,7 +84,14 @@ const config: Array = [ { ...baseConfig, entry: './src/index.ts', - externals: NodeExternals(), + externalsType: 'commonjs', + externals: ({ request }: ExternalItemFunctionData) => + Promise.resolve( + [ + ...Object.keys(packageJSON.peerDependencies), + ...Object.keys(packageJSON.dependencies), + ].some((pkg) => request === pkg || request?.startsWith(pkg + '/')), + ), output: { ...baseConfig.output, filename: 'voyager.lib.js',