@umijs/bundler-webpack 4.5.3 → 4.6.0

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/dist/build.js CHANGED
@@ -95,9 +95,8 @@ async function build(opts) {
95
95
  } else {
96
96
  resolve2(stats);
97
97
  }
98
- if (!opts.watch)
99
- compiler.close(() => {
100
- });
98
+ if (!opts.watch) compiler.close(() => {
99
+ });
101
100
  };
102
101
  if (opts.watch) {
103
102
  const watching = compiler.watch(
@@ -111,8 +110,7 @@ async function build(opts) {
111
110
  });
112
111
  }
113
112
  function esbuildCompressErrorHelper(errorMsg) {
114
- if (typeof errorMsg !== "string")
115
- return;
113
+ if (typeof errorMsg !== "string") return;
116
114
  if (
117
115
  // https://github.com/evanw/esbuild/blob/a5f781ecd5edeb3fb6ae8d1045507ab850462614/internal/js_parser/js_parser_lower.go#L18
118
116
  errorMsg.includes("configured target environment") && errorMsg.includes("es2015")
@@ -112,8 +112,7 @@ async function addCSSRules(opts) {
112
112
  esModule: true,
113
113
  url: {
114
114
  filter: (url) => {
115
- if (url.startsWith("/"))
116
- return false;
115
+ if (url.startsWith("/")) return false;
117
116
  return true;
118
117
  }
119
118
  },
@@ -26,8 +26,7 @@ var import_utils = require("@umijs/utils");
26
26
  var import_path = require("path");
27
27
  async function addDependenceCssModulesDetector(opts) {
28
28
  const { config, cwd, userConfig } = opts;
29
- if (!userConfig.checkDepCssModules)
30
- return;
29
+ if (!userConfig.checkDepCssModules) return;
31
30
  const matchers = opts.extraBabelIncludes.map(function(p) {
32
31
  if (import_utils.lodash.isRegExp(p)) {
33
32
  return p;
@@ -60,10 +59,12 @@ async function addDependenceCssModulesDetector(opts) {
60
59
  });
61
60
  config.plugin("dep-css-modules-detector").use(DetectCSsModulePlugin, [matchers]);
62
61
  }
63
- var _DetectCSsModulePlugin = class {
62
+ var DetectCSsModulePlugin = class _DetectCSsModulePlugin {
64
63
  constructor(skipMatcher = []) {
65
64
  this.skipMatcher = skipMatcher;
66
65
  }
66
+ static PLUGIN_NAME = "depCssModulesDetector";
67
+ static ERROR_NAME = "USE CSS-MODULES IN NODE_MODULES";
67
68
  isCallRequireStyle(statement) {
68
69
  if (
69
70
  // var x= require(...) ?
@@ -136,9 +137,6 @@ var _DetectCSsModulePlugin = class {
136
137
  throw Error(_DetectCSsModulePlugin.ERROR_NAME);
137
138
  }
138
139
  };
139
- var DetectCSsModulePlugin = _DetectCSsModulePlugin;
140
- DetectCSsModulePlugin.PLUGIN_NAME = "depCssModulesDetector";
141
- DetectCSsModulePlugin.ERROR_NAME = "USE CSS-MODULES IN NODE_MODULES";
142
140
  var toRegExp = (test) => {
143
141
  if (typeof test === "string") {
144
142
  return new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
@@ -90,8 +90,7 @@ var outputUnusedExportMap = (compilation, chunk, module2, includedFileMap, unuse
90
90
  return;
91
91
  }
92
92
  const path2 = (0, import_utils.winPath)(module2.resource);
93
- if (!/^((?!(node_modules)).)*$/.test(path2))
94
- return;
93
+ if (!/^((?!(node_modules)).)*$/.test(path2)) return;
95
94
  const providedExports = compilation.chunkGraph.moduleGraph.getProvidedExports(module2);
96
95
  const usedExports = compilation.chunkGraph.moduleGraph.getUsedExports(
97
96
  module2,
@@ -42,12 +42,8 @@ var defaultOptions = {
42
42
  detectUnusedExport: true
43
43
  };
44
44
  var DetectDeadCodePlugin = class {
45
+ options = defaultOptions;
45
46
  constructor(options) {
46
- this.options = defaultOptions;
47
- this.handleAfterEmit = (compilation, callback) => {
48
- (0, import_detectDeadCode.default)(compilation, this.options);
49
- callback();
50
- };
51
47
  if (!options) {
52
48
  return;
53
49
  }
@@ -68,6 +64,10 @@ var DetectDeadCodePlugin = class {
68
64
  this.handleAfterEmit
69
65
  );
70
66
  }
67
+ handleAfterEmit = (compilation, callback) => {
68
+ (0, import_detectDeadCode.default)(compilation, this.options);
69
+ callback();
70
+ };
71
71
  };
72
72
  async function addDetectDeadCodePlugin(opts) {
73
73
  const { config, userConfig } = opts;
@@ -86,8 +86,7 @@ async function addJavaScriptRules(opts) {
86
86
  // support es5ImcompatibleVersions
87
87
  (path) => {
88
88
  try {
89
- if (path.includes("client/client/client"))
90
- return true;
89
+ if (path.includes("client/client/client")) return true;
91
90
  return (0, import_depMatch.isMatch)({ path, pkgs: depPkgs });
92
91
  } catch (e) {
93
92
  console.error(import_utils.chalk.red(e));
@@ -29,6 +29,8 @@ var import_path = require("path");
29
29
  var import_constants = require("../constants");
30
30
  var PLUGIN_NAME = "SSR_PLUGIN";
31
31
  var SSRPlugin = class {
32
+ opts;
33
+ manifest;
32
34
  constructor(opts) {
33
35
  this.opts = opts;
34
36
  this.manifest = /* @__PURE__ */ new Map();
@@ -56,8 +56,7 @@ function svgrLoader(contents) {
56
56
  const callback = this.async();
57
57
  const options = this.getOptions();
58
58
  const previousExport = (() => {
59
- if (contents.startsWith("export "))
60
- return contents;
59
+ if (contents.startsWith("export ")) return contents;
61
60
  const exportMatches = contents.match(/^module.exports\s*=\s*(.*)/);
62
61
  return exportMatches ? `export default ${exportMatches[1]}` : null;
63
62
  })();
@@ -26,6 +26,7 @@ var import_utils = require("@umijs/utils");
26
26
  var import_webpack = require("../../compiled/webpack");
27
27
  var JS_FILE_REG = /\.(js|mjs|cjs)$/;
28
28
  var EsbuildMinifyFix = class {
29
+ name;
29
30
  constructor() {
30
31
  this.name = `EsbuildMinifyFix`;
31
32
  }
@@ -26,6 +26,7 @@ var import_webpack = require("@umijs/bundler-webpack/compiled/webpack");
26
26
  var import_utils = require("@umijs/utils");
27
27
  var PLUGIN_NAME = "ProgressPlugin";
28
28
  var UmiProgressPlugin = class extends import_webpack.ProgressPlugin {
29
+ options;
29
30
  constructor(options = {}) {
30
31
  super({ activeModules: true });
31
32
  this.options = options;
@@ -24,6 +24,7 @@ __export(SamplePlugin_exports, {
24
24
  module.exports = __toCommonJS(SamplePlugin_exports);
25
25
  var PLUGIN_NAME = "SamplePlugin";
26
26
  var _SamplePlugin = class {
27
+ options;
27
28
  constructor(options = {}) {
28
29
  this.options = options;
29
30
  }
@@ -43,7 +43,6 @@ var mod = require("module");
43
43
  var resolveFilename = mod._resolveFilename;
44
44
  mod._resolveFilename = function(request, parent, isMain, options) {
45
45
  const hookResolved = hookPropertyMap.get(request);
46
- if (hookResolved)
47
- request = hookResolved;
46
+ if (hookResolved) request = hookResolved;
48
47
  return resolveFilename.call(mod, request, parent, isMain, options);
49
48
  };
@@ -36,8 +36,7 @@ var import_utils = require("@umijs/utils");
36
36
  var import_path = __toESM(require("path"));
37
37
  function pkgUpContainsName(file) {
38
38
  let pkgPath = import_utils.pkgUp.pkgUpSync({ cwd: file });
39
- if (!pkgPath)
40
- return null;
39
+ if (!pkgPath) return null;
41
40
  const { name } = require(pkgPath);
42
41
  if (!name) {
43
42
  return pkgUpContainsName(import_path.default.resolve(pkgPath, "../.."));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.5.3",
3
+ "version": "4.6.0",
4
4
  "description": "@umijs/bundler-webpack",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-webpack#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -38,10 +38,10 @@
38
38
  "postcss-preset-env": "7.5.0",
39
39
  "react-error-overlay": "6.0.9",
40
40
  "react-refresh": "0.14.0",
41
- "@umijs/babel-preset-umi": "4.5.3",
42
- "@umijs/bundler-utils": "4.5.3",
43
- "@umijs/mfsu": "4.5.3",
44
- "@umijs/utils": "4.5.3"
41
+ "@umijs/babel-preset-umi": "4.6.0",
42
+ "@umijs/utils": "4.6.0",
43
+ "@umijs/bundler-utils": "4.6.0",
44
+ "@umijs/mfsu": "4.6.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@swc/core": "1.3.67",