@umijs/bundler-webpack 4.0.55 → 4.0.56

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.
@@ -3,5 +3,6 @@ export declare class EsbuildMinifyFix {
3
3
  private name;
4
4
  constructor();
5
5
  apply(compiler: Compiler): void;
6
+ private isIIFE;
6
7
  minifyFix(compilation: Compilation, assets: Record<string, sources.Source>): Promise<void>;
7
8
  }
@@ -41,6 +41,16 @@ var EsbuildMinifyFix = class {
41
41
  );
42
42
  });
43
43
  }
44
+ isIIFE(source) {
45
+ source = source.trim();
46
+ if (source.startsWith('(function(){"use strict";')) {
47
+ return true;
48
+ }
49
+ if (source.startsWith("(function(){") && (source.endsWith("})()") || source.endsWith("})();"))) {
50
+ return true;
51
+ }
52
+ return false;
53
+ }
44
54
  async minifyFix(compilation, assets) {
45
55
  const matchObject = import_webpack.ModuleFilenameHelpers.matchObject.bind(void 0, {
46
56
  include: [JS_FILE_REG]
@@ -57,6 +67,9 @@ var EsbuildMinifyFix = class {
57
67
  if (info == null ? void 0 : info.EsbuildMinifyFix) {
58
68
  return false;
59
69
  }
70
+ if (name.endsWith(".worker.js")) {
71
+ return false;
72
+ }
60
73
  return true;
61
74
  }).map(async (name) => {
62
75
  const { info, source } = compilation.getAsset(name);
@@ -72,9 +85,9 @@ var EsbuildMinifyFix = class {
72
85
  const { source, map } = inputSource.sourceAndMap();
73
86
  const originCode = source.toString();
74
87
  let newCode = originCode;
75
- if (!newCode.startsWith('"use strict";(self.') && !newCode.startsWith('(function(){"use strict";') && !newCode.startsWith("(self.webpack")) {
88
+ if (!newCode.startsWith('"use strict";(self.') && !newCode.startsWith("(self.webpack") && !this.isIIFE(newCode)) {
76
89
  const bundle = new import_utils.MagicString(newCode);
77
- bundle.indent().prepend("!(function () {\n").append("}());");
90
+ bundle.prepend("!(function(){").append("}());");
78
91
  newCode = bundle.toString();
79
92
  const output = {};
80
93
  if (map) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.0.55",
3
+ "version": "4.0.56",
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",
@@ -33,11 +33,11 @@
33
33
  "@svgr/plugin-jsx": "^6.5.1",
34
34
  "@svgr/plugin-svgo": "^6.5.1",
35
35
  "@types/hapi__joi": "17.1.9",
36
- "@umijs/babel-preset-umi": "4.0.55",
37
- "@umijs/bundler-utils": "4.0.55",
36
+ "@umijs/babel-preset-umi": "4.0.56",
37
+ "@umijs/bundler-utils": "4.0.56",
38
38
  "@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
39
- "@umijs/mfsu": "4.0.55",
40
- "@umijs/utils": "4.0.55",
39
+ "@umijs/mfsu": "4.0.56",
40
+ "@umijs/utils": "4.0.56",
41
41
  "cors": "^2.8.5",
42
42
  "css-loader": "6.7.1",
43
43
  "es5-imcompatible-versions": "^0.1.78",