Skip to content

Commit

Permalink
Remove MochaJUnitReporter bundle for Node.js in webpack
Browse files Browse the repository at this point in the history
After 4f887c6 there is no need anymore
to build a separate MochaJUnitReporter bundle for Node.js - we can use
`mocha-junit-reporter` package directly from Node.

As a result, we also don't need `webpack-node-externals` package
anymore, so run `npm uninstall webpack-node-externals`
  • Loading branch information
VeskeR committed Mar 2, 2024
1 parent 4f887c6 commit b345281
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
18 changes: 1 addition & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@
"vite": "^4.4.9",
"vitest": "^0.18.0",
"webpack": "^5.79.0",
"webpack-cli": "^5.0.1",
"webpack-node-externals": "^3.0.0"
"webpack-cli": "^5.0.1"
},
"engines": {
"node": ">=16"
Expand Down
2 changes: 1 addition & 1 deletion test/support/mocha_reporter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Mocha = require('mocha');
const MochaJUnitReporter = require('./mocha_junit_reporter/build/node');
const MochaJUnitReporter = require('mocha-junit-reporter');
const path = require('path');
const jUnitDirectoryPath = require('./junit_directory_path');

Expand Down
17 changes: 0 additions & 17 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { BannerPlugin, ProvidePlugin } = require('webpack');
const banner = require('./src/fragments/license');
// This is needed for baseUrl to resolve correctly from tsconfig
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const nodeExternals = require('webpack-node-externals');

const baseConfig = {
mode: 'production',
Expand Down Expand Up @@ -168,24 +167,8 @@ function createMochaJUnitReporterConfigs() {
},
};

const nodeConfig = {
...baseConfig,
target: 'node',
output: {
...baseConfig.output,
filename: 'node.js',
libraryTarget: 'umd',
},
// Don’t bundle any packages except mocha-junit-reporter. Using the
// webpack-node-externals library which I saw mentioned on
// https://webpack.js.org/configuration/externals/#function; there may
// be a simpler way of doing this but seems OK.
externals: [nodeExternals({ allowlist: 'mocha-junit-reporter' })],
};

return {
mochaJUnitReporterBrowser: browserConfig,
mochaJUnitReporterNode: nodeConfig,
};
}

Expand Down

0 comments on commit b345281

Please sign in to comment.