weboptimizer 4.0.94 → 4.0.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "4.0.94",
3
+ "version": "4.0.95",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -170,7 +170,7 @@
170
170
  "terser-webpack-plugin": "^5.6.1",
171
171
  "typescript-eslint": "^8.72.1",
172
172
  "typescript-plugin-css-modules": "^5.3.0",
173
- "web-documentation": "^1.0.65",
173
+ "web-documentation": "^1.0.68",
174
174
  "workbox-webpack-plugin": "^7.4.1"
175
175
  },
176
176
  "peerDependencies": {
@@ -813,11 +813,17 @@ if (configuration.path.configuration.json) try {
813
813
  exports are never imported) would have its bundled modules tree-shaken away
814
814
  completely - resulting for example in a test bundle without any registered
815
815
  test.
816
+
817
+ NOTE: This applies to every command which runs the test bundle through
818
+ jest (with or without coverage instrumentation) - otherwise for example
819
+ "test:coverage" fails with "Cannot add a test after tests have started
820
+ running".
816
821
  */
822
+ const isJestTestRun = ['test', 'test:coverage', 'test:coverage:report'].includes(configuration.givenCommandLineArguments[2]);
817
823
  const generatedBarrelModuleFilePaths = [];
818
824
  const barrelledModuleFilePaths = [];
819
825
  const normalizedEntryInjection = {};
820
- for (const [chunkName, moduleIDs] of Object.entries(configuration.injection.entry.normalized)) if (configuration.givenCommandLineArguments[2] === 'test' && Array.isArray(moduleIDs) && moduleIDs.length > 1) {
826
+ for (const [chunkName, moduleIDs] of Object.entries(configuration.injection.entry.normalized)) if (isJestTestRun && Array.isArray(moduleIDs) && moduleIDs.length > 1) {
821
827
  const barrelModuleFilePath = resolve(configuration.path.context, `.__${convertToValidVariableName(chunkName)}__.barrel.mjs`);
822
828
  await writeFile(barrelModuleFilePath, moduleIDs.map(moduleID => {
823
829
  const specifier = stripLoader(moduleID);
@@ -972,7 +978,7 @@ export let webpackConfiguration = extend(true, {
972
978
  */
973
979
  concatenateModules: configuration.givenCommandLineArguments[2] === 'serve' || undefined,
974
980
  // region common chunks
975
- splitChunks: extend(true, !configuration.injection.chunks || configuration.targetTechnology.payload === 'node' || configuration.givenCommandLineArguments[2] === 'test' ? {
981
+ splitChunks: extend(true, !configuration.injection.chunks || configuration.targetTechnology.payload === 'node' || isJestTestRun ? {
976
982
  cacheGroups: {
977
983
  default: false,
978
984
  defaultVendors: false