@umijs/bundler-webpack 4.0.20 → 4.0.21

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.
@@ -1,3 +1,7 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+
1
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
6
 
3
7
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -37,9 +41,9 @@ var hadRuntimeError = false;
37
41
  var pingUrl = getPingUrl();
38
42
  var socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
39
43
  socket.addEventListener('message', /*#__PURE__*/function () {
40
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref) {
44
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
41
45
  var data;
42
- return regeneratorRuntime.wrap(function _callee$(_context) {
46
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
43
47
  while (1) {
44
48
  switch (_context.prev = _context.next) {
45
49
  case 0:
@@ -75,10 +79,10 @@ function waitForSuccessfulPing() {
75
79
  }
76
80
 
77
81
  function _waitForSuccessfulPing() {
78
- _waitForSuccessfulPing = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
82
+ _waitForSuccessfulPing = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
79
83
  var ms,
80
84
  _args3 = arguments;
81
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
85
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
82
86
  while (1) {
83
87
  switch (_context3.prev = _context3.next) {
84
88
  case 0:
@@ -119,8 +123,8 @@ function _waitForSuccessfulPing() {
119
123
  return _waitForSuccessfulPing.apply(this, arguments);
120
124
  }
121
125
 
122
- socket.addEventListener('close', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
123
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
126
+ socket.addEventListener('close', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
127
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
124
128
  while (1) {
125
129
  switch (_context2.prev = _context2.next) {
126
130
  case 0:
@@ -295,8 +299,8 @@ function handleMessage(_x2) {
295
299
  }
296
300
 
297
301
  function _handleMessage() {
298
- _handleMessage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(payload) {
299
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
302
+ _handleMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(payload) {
303
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
300
304
  while (1) {
301
305
  switch (_context4.prev = _context4.next) {
302
306
  case 0:
package/dist/build.js CHANGED
@@ -1,26 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
7
  var __export = (target, all) => {
25
8
  for (var name in all)
26
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -68,9 +51,10 @@ async function build(opts) {
68
51
  extraBabelIncludes: opts.config.extraBabelIncludes,
69
52
  chainWebpack: opts.chainWebpack,
70
53
  modifyWebpackConfig: opts.modifyWebpackConfig,
71
- cache: opts.cache ? __spreadProps(__spreadValues({}, opts.cache), {
54
+ cache: opts.cache ? {
55
+ ...opts.cache,
72
56
  cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "bundler-webpack")
73
- }) : void 0,
57
+ } : void 0,
74
58
  pkg: opts.pkg
75
59
  });
76
60
  let isFirstCompile = true;
@@ -2,22 +2,8 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
5
  var __getProtoOf = Object.getPrototypeOf;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
7
  var __export = (target, all) => {
22
8
  for (var name in all)
23
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -83,7 +69,10 @@ async function addCompressPlugin(opts) {
83
69
  } else if (jsMinifier !== import_types.JSMinifier.none) {
84
70
  throw new Error(`Unsupported jsMinifier ${userConfig.jsMinifier}.`);
85
71
  }
86
- terserOptions = __spreadValues(__spreadValues({}, terserOptions), userConfig.jsMinifierOptions);
72
+ terserOptions = {
73
+ ...terserOptions,
74
+ ...userConfig.jsMinifierOptions
75
+ };
87
76
  if (jsMinifier !== import_types.JSMinifier.none) {
88
77
  config.optimization.minimizer(`js-${jsMinifier}`).use(import_terser_webpack_plugin.default, [
89
78
  {
@@ -107,7 +96,10 @@ async function addCompressPlugin(opts) {
107
96
  } else if (cssMinifier !== import_types.CSSMinifier.none) {
108
97
  throw new Error(`Unsupported cssMinifier ${userConfig.cssMinifier}.`);
109
98
  }
110
- minimizerOptions = __spreadValues(__spreadValues({}, minimizerOptions), userConfig.cssMinifierOptions);
99
+ minimizerOptions = {
100
+ ...minimizerOptions,
101
+ ...userConfig.cssMinifierOptions
102
+ };
111
103
  config.optimization.minimizer(`css-${cssMinifier}`).use(import_css_minimizer_webpack_plugin.default, [
112
104
  {
113
105
  minify: cssMinify,
@@ -1,26 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
7
  var __export = (target, all) => {
25
8
  for (var name in all)
26
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -53,10 +36,11 @@ async function addCSSRules(opts) {
53
36
  loader: require.resolve("@umijs/bundler-webpack/compiled/less-loader"),
54
37
  loaderOptions: {
55
38
  implementation: require.resolve("@umijs/bundler-utils/compiled/less"),
56
- lessOptions: __spreadValues({
39
+ lessOptions: {
57
40
  modifyVars: userConfig.theme,
58
- javascriptEnabled: true
59
- }, userConfig.lessLoader)
41
+ javascriptEnabled: true,
42
+ ...userConfig.lessLoader
43
+ }
60
44
  }
61
45
  },
62
46
  {
@@ -80,7 +64,7 @@ async function addCSSRules(opts) {
80
64
  ].filter(Boolean);
81
65
  for (const { rule: rule2, isCSSModules } of nestRulesConfig) {
82
66
  if (userConfig.styleLoader) {
83
- rule2.use("style-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/style-loader")).options(__spreadValues({ base: 0, esModule: true }, userConfig.styleLoader));
67
+ rule2.use("style-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/style-loader")).options({ base: 0, esModule: true, ...userConfig.styleLoader });
84
68
  } else {
85
69
  rule2.use("mini-css-extract-plugin").loader(require.resolve("@umijs/bundler-webpack/compiled/mini-css-extract-plugin/loader")).options({
86
70
  publicPath: "./",
@@ -88,7 +72,7 @@ async function addCSSRules(opts) {
88
72
  esModule: true
89
73
  });
90
74
  }
91
- rule2.use("css-loader").loader(require.resolve("css-loader")).options(__spreadValues(__spreadValues({
75
+ rule2.use("css-loader").loader(require.resolve("css-loader")).options({
92
76
  importLoaders: 1,
93
77
  esModule: true,
94
78
  url: {
@@ -98,34 +82,38 @@ async function addCSSRules(opts) {
98
82
  return true;
99
83
  }
100
84
  },
101
- import: true
102
- }, isCSSModules ? {
103
- modules: __spreadProps(__spreadValues({
104
- localIdentName: "[local]___[hash:base64:5]"
105
- }, userConfig.cssLoaderModules), {
106
- getLocalIdent: userConfig.ssr && ((context, localIdentName, localName, opt) => {
107
- const classIdent = ((0, import_utils.winPath)(context.resourcePath).replace((0, import_utils.winPath)(ensureLastSlash(opt.context)), "") + "@" + localName).trim();
108
- let hash = Buffer.from(classIdent).toString("base64").replace(/=/g, "");
109
- hash = hash.substring(hash.length - 5);
110
- const result = localIdentName.replace(/\[local]/g, localName).replace(/\[hash[^\[]*?]/g, hash);
111
- return result;
112
- })
113
- })
114
- } : {}), userConfig.cssLoader));
85
+ import: true,
86
+ ...isCSSModules ? {
87
+ modules: {
88
+ localIdentName: "[local]___[hash:base64:5]",
89
+ ...userConfig.cssLoaderModules,
90
+ getLocalIdent: userConfig.ssr && ((context, localIdentName, localName, opt) => {
91
+ const classIdent = ((0, import_utils.winPath)(context.resourcePath).replace((0, import_utils.winPath)(ensureLastSlash(opt.context)), "") + "@" + localName).trim();
92
+ let hash = Buffer.from(classIdent).toString("base64").replace(/=/g, "");
93
+ hash = hash.substring(hash.length - 5);
94
+ const result = localIdentName.replace(/\[local]/g, localName).replace(/\[hash[^\[]*?]/g, hash);
95
+ return result;
96
+ })
97
+ }
98
+ } : {},
99
+ ...userConfig.cssLoader
100
+ });
115
101
  rule2.use("postcss-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/postcss-loader")).options({
116
- postcssOptions: __spreadValues({
102
+ postcssOptions: {
117
103
  ident: "postcss",
118
104
  plugins: [
119
105
  require("@umijs/bundler-webpack/compiled/postcss-flexbugs-fixes"),
120
106
  require("postcss-preset-env")({
121
107
  browsers: opts.browsers,
122
- autoprefixer: __spreadValues({
123
- flexbox: "no-2009"
124
- }, userConfig.autoprefixer),
108
+ autoprefixer: {
109
+ flexbox: "no-2009",
110
+ ...userConfig.autoprefixer
111
+ },
125
112
  stage: 3
126
113
  })
127
- ].concat(userConfig.extraPostCSSPlugins || [])
128
- }, userConfig.postcssLoader)
114
+ ].concat(userConfig.extraPostCSSPlugins || []),
115
+ ...userConfig.postcssLoader
116
+ }
129
117
  });
130
118
  if (loader) {
131
119
  rule2.use(loader).loader(typeof loader === "string" ? require.resolve(loader) : loader).options(loaderOptions || {});
@@ -1,21 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
5
  var __export = (target, all) => {
20
6
  for (var name in all)
21
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -57,9 +43,10 @@ function resolveDefine(opts) {
57
43
  define[key] = JSON.stringify(opts.define[key]);
58
44
  }
59
45
  }
60
- return __spreadValues({
61
- "process.env": env
62
- }, define);
46
+ return {
47
+ "process.env": env,
48
+ ...define
49
+ };
63
50
  }
64
51
  async function addDefinePlugin(opts) {
65
52
  const { config, userConfig } = opts;
@@ -56,7 +56,10 @@ async function addJavaScriptRules(opts) {
56
56
  if (p.startsWith("./")) {
57
57
  return require.resolve(p, { paths: [cwd] });
58
58
  }
59
- return (0, import_path.dirname)(import_utils.resolve.sync(`${p}/package.json`, { basedir: cwd }));
59
+ return (0, import_path.dirname)(import_utils.resolve.sync(`${p}/package.json`, {
60
+ basedir: cwd,
61
+ preserveSymlinks: false
62
+ }));
60
63
  } catch (e) {
61
64
  if (e.code === "MODULE_NOT_FOUND") {
62
65
  throw new Error("Cannot resolve extraBabelIncludes: " + p);
@@ -1,21 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
5
  var __export = (target, all) => {
20
6
  for (var name in all)
21
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -41,9 +27,10 @@ async function addManifestPlugin(opts) {
41
27
  const { config, userConfig } = opts;
42
28
  if (userConfig.manifest) {
43
29
  config.plugin("manifest-plugin").use(import_webpack_manifest_plugin.WebpackManifestPlugin, [
44
- __spreadValues({
45
- fileName: "asset-manifest.json"
46
- }, userConfig.manifest)
30
+ {
31
+ fileName: "asset-manifest.json",
32
+ ...userConfig.manifest
33
+ }
47
34
  ]);
48
35
  }
49
36
  }
@@ -1,24 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
5
  var __export = (target, all) => {
23
6
  for (var name in all)
24
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -49,17 +32,18 @@ async function addNodePolyfill(opts) {
49
32
  process: nodeLibs["process"]
50
33
  }
51
34
  ]);
52
- config.resolve.fallback.merge(__spreadProps(__spreadValues({}, Object.keys(nodeLibs).reduce((memo, key) => {
53
- if (nodeLibs[key]) {
54
- memo[key] = nodeLibs[key];
55
- } else {
56
- memo[key] = false;
57
- }
58
- return memo;
59
- }, {})), {
35
+ config.resolve.fallback.merge({
36
+ ...Object.keys(nodeLibs).reduce((memo, key) => {
37
+ if (nodeLibs[key]) {
38
+ memo[key] = nodeLibs[key];
39
+ } else {
40
+ memo[key] = false;
41
+ }
42
+ return memo;
43
+ }, {}),
60
44
  http: false,
61
45
  https: false
62
- }));
46
+ });
63
47
  }
64
48
  // Annotate the CommonJS export names for ESM import in node:
65
49
  0 && (module.exports = {
@@ -1,26 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
7
  var __export = (target, all) => {
25
8
  for (var name in all)
26
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -47,8 +30,8 @@ async function addSVGRules(opts) {
47
30
  const { svgr, svgo = {} } = userConfig;
48
31
  if (svgr) {
49
32
  const svgrRule = config.module.rule("svgr");
50
- svgrRule.test(/\.svg$/).issuer(/\.[jt]sx?$/).type("javascript/auto").use("svgr-loader").loader(require.resolve("../loader/svgr")).options(__spreadProps(__spreadValues({
51
- svgoConfig: __spreadValues({
33
+ svgrRule.test(/\.svg$/).issuer(/\.[jt]sx?$/).type("javascript/auto").use("svgr-loader").loader(require.resolve("../loader/svgr")).options({
34
+ svgoConfig: {
52
35
  plugins: [
53
36
  {
54
37
  name: "preset-default",
@@ -59,15 +42,16 @@ async function addSVGRules(opts) {
59
42
  }
60
43
  },
61
44
  "prefixIds"
62
- ]
63
- }, svgo)
64
- }, svgr), {
45
+ ],
46
+ ...svgo
47
+ },
48
+ ...svgr,
65
49
  svgo: !!svgo
66
- })).end().use("url-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/url-loader")).end();
50
+ }).end().use("url-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/url-loader")).end();
67
51
  }
68
52
  if (svgo !== false) {
69
53
  const svgRule = config.module.rule("svg");
70
- svgRule.test(/\.svg$/).use("svgo-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/svgo-loader")).options(__spreadValues({ configFile: false }, svgo)).end();
54
+ svgRule.test(/\.svg$/).use("svgo-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/svgo-loader")).options({ configFile: false, ...svgo }).end();
71
55
  }
72
56
  }
73
57
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,36 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
- var __objRest = (source, exclude) => {
23
- var target = {};
24
- for (var prop in source)
25
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
- target[prop] = source[prop];
27
- if (source != null && __getOwnPropSymbols)
28
- for (var prop of __getOwnPropSymbols(source)) {
29
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
- target[prop] = source[prop];
31
- }
32
- return target;
33
- };
34
5
  var __export = (target, all) => {
35
6
  for (var name in all)
36
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -86,15 +57,17 @@ function getBaseOpts({ filename }) {
86
57
  function swcLoader(contents) {
87
58
  const callback = this.async();
88
59
  const loaderOpts = this.getOptions();
89
- const _a = loaderOpts, { sync = false, parseMap = false } = _a, otherOpts = __objRest(_a, ["sync", "parseMap"]);
60
+ const { sync = false, parseMap = false, ...otherOpts } = loaderOpts;
90
61
  const filename = this.resourcePath;
91
- const swcOpts = __spreadValues(__spreadProps(__spreadValues({}, getBaseOpts({
92
- filename
93
- })), {
62
+ const swcOpts = {
63
+ ...getBaseOpts({
64
+ filename
65
+ }),
94
66
  filename,
95
67
  sourceMaps: this.sourceMap,
96
- sourceFileName: filename
97
- }), otherOpts);
68
+ sourceFileName: filename,
69
+ ...otherOpts
70
+ };
98
71
  try {
99
72
  if (sync) {
100
73
  const output = (0, import_core.transformSync)(contents, swcOpts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.0.20",
3
+ "version": "4.0.21",
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",
@@ -34,11 +34,11 @@
34
34
  "@svgr/plugin-jsx": "^6.2.1",
35
35
  "@svgr/plugin-svgo": "^6.2.0",
36
36
  "@types/hapi__joi": "17.1.8",
37
- "@umijs/babel-preset-umi": "4.0.20",
38
- "@umijs/bundler-utils": "4.0.20",
37
+ "@umijs/babel-preset-umi": "4.0.21",
38
+ "@umijs/bundler-utils": "4.0.21",
39
39
  "@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
40
- "@umijs/mfsu": "4.0.20",
41
- "@umijs/utils": "4.0.20",
40
+ "@umijs/mfsu": "4.0.21",
41
+ "@umijs/utils": "4.0.21",
42
42
  "cors": "^2.8.5",
43
43
  "css-loader": "6.7.1",
44
44
  "es5-imcompatible-versions": "^0.1.73",