@umijs/bundler-webpack 4.0.0-canary.20220729.2 → 4.0.0-canary.20220809.1

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.
@@ -53,7 +53,8 @@ async function addCompressPlugin(opts) {
53
53
  }
54
54
  config.optimization.minimize(true);
55
55
  const esbuildTarget = (0, import_getEsBuildTarget.getEsBuildTarget)({
56
- targets: userConfig.targets || {}
56
+ targets: userConfig.targets || {},
57
+ jsMinifier
57
58
  });
58
59
  let minify;
59
60
  let terserOptions;
package/dist/dev.js CHANGED
@@ -65,6 +65,10 @@ async function dev(opts) {
65
65
  const cacheDirectoryPath = (0, import_path.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
66
66
  const enableMFSU = opts.config.mfsu !== false;
67
67
  let mfsu = null;
68
+ let devHost = "localhost";
69
+ if (opts.host && opts.host !== "0.0.0.0") {
70
+ devHost = opts.host;
71
+ }
68
72
  if (enableMFSU) {
69
73
  if (opts.config.srcTranspiler === import_types.Transpiler.swc) {
70
74
  import_utils.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
@@ -97,7 +101,7 @@ async function dev(opts) {
97
101
  publicPath: opts.config.publicPath
98
102
  });
99
103
  },
100
- serverBase: `${opts.config.https ? "https" : "http"}://${opts.host}:${opts.port || 8e3}`
104
+ serverBase: `${opts.config.https ? "https" : "http"}://${devHost}:${opts.port || 8e3}`
101
105
  });
102
106
  }
103
107
  const webpackConfig = await (0, import_config.getConfig)({
@@ -137,6 +141,7 @@ async function dev(opts) {
137
141
  staticPathPrefix: import_mfsu.MF_DEP_PREFIX,
138
142
  name: import_constants.MFSU_NAME,
139
143
  chainWebpack: (_i = opts.config.mfsu) == null ? void 0 : _i.chainWebpack,
144
+ extraBabelIncludes: opts.config.extraBabelIncludes,
140
145
  cache: {
141
146
  buildDependencies: (_j = opts.cache) == null ? void 0 : _j.buildDependencies,
142
147
  cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "mfsu-deps")
@@ -169,7 +174,7 @@ async function dev(opts) {
169
174
  ...opts.beforeMiddlewares || []
170
175
  ],
171
176
  port: opts.port,
172
- host: opts.host,
177
+ host: devHost,
173
178
  afterMiddlewares: [...opts.afterMiddlewares || []],
174
179
  onDevCompileDone: opts.onDevCompileDone,
175
180
  onProgress: opts.onProgress
@@ -162,6 +162,13 @@ async function createServer(opts) {
162
162
  (0, import_assert.default)(typeof proxy2.target === "string", "proxy.target must be string");
163
163
  (0, import_assert.default)(proxy2.context, "proxy.context must be supplied");
164
164
  middleware = (0, import_http_proxy_middleware.createProxyMiddleware)(proxy2.context, __spreadProps(__spreadValues({}, proxy2), {
165
+ onProxyReq(proxyReq, req, res) {
166
+ var _a, _b;
167
+ if (proxyReq.getHeader("origin")) {
168
+ proxyReq.setHeader("origin", ((_a = new URL(proxy2.target)) == null ? void 0 : _a.href) || "");
169
+ }
170
+ (_b = proxy2.onProxyReq) == null ? void 0 : _b.call(proxy2, proxyReq, req, res);
171
+ },
165
172
  onProxyRes(proxyRes, req, res) {
166
173
  var _a, _b;
167
174
  proxyRes.headers["x-real-url"] = ((_a = new URL(req.url || "", proxy2.target)) == null ? void 0 : _a.href) || "";
@@ -215,8 +222,10 @@ async function createServer(opts) {
215
222
  const protocol = userConfig.https ? "https:" : "http:";
216
223
  const port = opts.port || 8e3;
217
224
  server.listen(port, () => {
218
- const host = opts.host && opts.host !== "0.0.0.0" ? opts.host : "localhost";
219
- import_utils.logger.ready(`App listening at ${import_utils.chalk.green(`${protocol}//${host}:${port}`)}`);
225
+ const banner = (0, import_utils.getDevBanner)(protocol, opts.host, port);
226
+ console.log(banner.before);
227
+ import_utils.logger.ready(banner.main);
228
+ console.log(banner.after);
220
229
  });
221
230
  return server;
222
231
  }
@@ -1,5 +1,7 @@
1
+ import { JSMinifier } from '../types';
1
2
  interface IOpts {
2
3
  targets: Record<string, any>;
4
+ jsMinifier: `${JSMinifier}`;
3
5
  }
4
- export declare function getEsBuildTarget({ targets }: IOpts): string[];
6
+ export declare function getEsBuildTarget({ targets, jsMinifier }: IOpts): string[];
5
7
  export {};
@@ -22,8 +22,14 @@ __export(getEsBuildTarget_exports, {
22
22
  getEsBuildTarget: () => getEsBuildTarget
23
23
  });
24
24
  module.exports = __toCommonJS(getEsBuildTarget_exports);
25
+ var import_utils = require("@umijs/utils");
25
26
  var import_constants = require("../constants");
26
- function getEsBuildTarget({ targets }) {
27
+ var import_types = require("../types");
28
+ function getEsBuildTarget({ targets, jsMinifier }) {
29
+ if (targets["ie"] && jsMinifier === import_types.JSMinifier.esbuild) {
30
+ import_utils.logger.error(`${import_utils.chalk.red(`jsMinifier: esbuild`)} is not supported when there is ie in the targets, you can use ${import_utils.chalk.green(`jsMinifier: 'terser'`)}`);
31
+ throw new Error("IE is not supported");
32
+ }
27
33
  return Object.keys(targets).filter((key) => import_constants.DEFAULT_ESBUILD_TARGET_KEYS.includes(key)).map((key) => {
28
34
  return `${key}${targets[key] === true ? "0" : targets[key]}`;
29
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.0.0-canary.20220729.2",
3
+ "version": "4.0.0-canary.20220809.1",
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.0-canary.20220729.2",
38
- "@umijs/bundler-utils": "4.0.0-canary.20220729.2",
37
+ "@umijs/babel-preset-umi": "4.0.0-canary.20220809.1",
38
+ "@umijs/bundler-utils": "4.0.0-canary.20220809.1",
39
39
  "@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
40
- "@umijs/mfsu": "4.0.0-canary.20220729.2",
41
- "@umijs/utils": "4.0.0-canary.20220729.2",
40
+ "@umijs/mfsu": "4.0.0-canary.20220809.1",
41
+ "@umijs/utils": "4.0.0-canary.20220809.1",
42
42
  "cors": "^2.8.5",
43
43
  "css-loader": "6.7.1",
44
44
  "es5-imcompatible-versions": "^0.1.73",