@umijs/bundler-webpack 4.0.0-beta.1 → 4.0.0-beta.13

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.
Files changed (82) hide show
  1. package/compiled/autoprefixer/browserslist/index.d.ts +7 -7
  2. package/compiled/autoprefixer/index.js +3 -3
  3. package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
  4. package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
  5. package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
  6. package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
  7. package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
  8. package/compiled/autoprefixer/postcss/lib/node.d.ts +36 -2
  9. package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
  10. package/compiled/autoprefixer/postcss/lib/processor.d.ts +5 -4
  11. package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
  12. package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
  13. package/compiled/babel-loader/index.js +2 -2
  14. package/compiled/mini-css-extract-plugin/index.js +6769 -6731
  15. package/compiled/mini-css-extract-plugin/loader.js +1 -1
  16. package/compiled/mini-css-extract-plugin/utils.js +11 -6
  17. package/compiled/postcss-loader/index.js +1 -1
  18. package/compiled/react-refresh/index.js +3 -3
  19. package/compiled/sass-loader/index.js +1 -1
  20. package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
  21. package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
  22. package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
  23. package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
  24. package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
  25. package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
  26. package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
  27. package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
  28. package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
  29. package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
  30. package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
  31. package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
  32. package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
  33. package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
  34. package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
  35. package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
  36. package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
  37. package/compiled/schema-utils/declarations/validate.d.ts +4 -4
  38. package/compiled/schema-utils/index.js +8 -2
  39. package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
  40. package/compiled/style-loader/index.js +1 -1
  41. package/compiled/terser/index.js +1 -1
  42. package/compiled/terser-webpack-plugin/index.js +328 -451
  43. package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
  44. package/compiled/terser-webpack-plugin/minify.js +6 -1
  45. package/compiled/terser-webpack-plugin/types/index.d.ts +3 -3
  46. package/compiled/terser-webpack-plugin/types/utils.d.ts +9 -12
  47. package/compiled/terser-webpack-plugin/utils.js +113 -17
  48. package/compiled/webpack/index.js +5088 -4524
  49. package/compiled/webpack/lazy-compilation-node.js +3 -1
  50. package/compiled/webpack/package.json +5 -1
  51. package/compiled/webpack/types.d.ts +40 -9
  52. package/compiled/webpack-dev-middleware/index.js +11 -5
  53. package/compiled/webpack-sources/index.js +1 -1
  54. package/dist/build.d.ts +7 -0
  55. package/dist/build.js +11 -0
  56. package/dist/cli.js +0 -20
  57. package/dist/config/assetRules.js +2 -1
  58. package/dist/config/config.d.ts +4 -0
  59. package/dist/config/config.js +16 -1
  60. package/dist/config/cssRules.js +3 -3
  61. package/dist/config/javaScriptRules.d.ts +2 -0
  62. package/dist/config/javaScriptRules.js +8 -3
  63. package/dist/config/svgRules.d.ts +1 -0
  64. package/dist/config/svgRules.js +12 -11
  65. package/dist/dev.d.ts +6 -0
  66. package/dist/dev.js +23 -7
  67. package/dist/loader/svgr.d.ts +4 -0
  68. package/dist/loader/svgr.js +67 -0
  69. package/dist/schema.js +5 -1
  70. package/dist/server/server.js +11 -10
  71. package/dist/server/ws.d.ts +1 -1
  72. package/dist/server/ws.js +1 -1
  73. package/dist/swcPlugins/autoCSSModules.d.ts +8 -0
  74. package/dist/swcPlugins/autoCSSModules.js +35 -0
  75. package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
  76. package/dist/swcPlugins/lockCoreJS.js +23 -0
  77. package/dist/types.d.ts +3 -0
  78. package/package.json +43 -43
  79. package/compiled/@svgr/webpack/.svgo.yml +0 -75
  80. package/compiled/@svgr/webpack/LICENSE +0 -7
  81. package/compiled/@svgr/webpack/index.js +0 -343
  82. package/compiled/@svgr/webpack/package.json +0 -1
@@ -32,6 +32,16 @@ function createServer(opts) {
32
32
  // TODO: headers
33
33
  // before middlewares
34
34
  (opts.beforeMiddlewares || []).forEach((m) => app.use(m));
35
+ // TODO: add to before middleware
36
+ app.use((req, res, next) => {
37
+ if (req.path === '/umi.js' && (0, fs_1.existsSync)((0, path_1.join)(opts.cwd, 'umi.js'))) {
38
+ res.setHeader('Content-Type', 'application/javascript');
39
+ res.send((0, fs_1.readFileSync)((0, path_1.join)(opts.cwd, 'umi.js'), 'utf-8'));
40
+ }
41
+ else {
42
+ next();
43
+ }
44
+ });
35
45
  // webpack dev middleware
36
46
  const compiler = (0, webpack_1.default)(Array.isArray(webpackConfig) ? webpackConfig : [webpackConfig]);
37
47
  const webpackDevMiddleware = require('@umijs/bundler-webpack/compiled/webpack-dev-middleware');
@@ -117,15 +127,6 @@ function createServer(opts) {
117
127
  app.use('/__umi_ping', (_, res) => {
118
128
  res.end('pong');
119
129
  });
120
- // TODO: remove me
121
- app.use((req, res, next) => {
122
- if (req.path === '/umi.js' && (0, fs_1.existsSync)((0, path_1.join)(opts.cwd, 'umi.js'))) {
123
- res.send((0, fs_1.readFileSync)((0, path_1.join)(opts.cwd, 'umi.js'), 'utf-8'));
124
- }
125
- else {
126
- next();
127
- }
128
- });
129
130
  // index.html
130
131
  // TODO: remove me
131
132
  app.get('/', (_req, res, next) => {
@@ -149,7 +150,7 @@ function createServer(opts) {
149
150
  const port = opts.port || 8000;
150
151
  server.listen(port, () => {
151
152
  const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
152
- utils_1.logger.ready(`App listening at http://${host}:${port}`);
153
+ utils_1.logger.ready(`App listening at ${utils_1.chalk.green.bold(`http://${host}:${port}`)}`);
153
154
  });
154
155
  return server;
155
156
  });
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Server } from 'http';
3
- import WebSocket from 'ws';
3
+ import WebSocket from '../../compiled/ws';
4
4
  export declare function createWebSocketServer(server: Server): {
5
5
  send(message: string): void;
6
6
  wss: WebSocket.Server;
package/dist/server/ws.js CHANGED
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createWebSocketServer = void 0;
7
7
  const utils_1 = require("@umijs/utils");
8
- const ws_1 = __importDefault(require("ws"));
8
+ const ws_1 = __importDefault(require("../../compiled/ws"));
9
9
  function createWebSocketServer(server) {
10
10
  const wss = new ws_1.default.Server({
11
11
  noServer: true,
@@ -0,0 +1,8 @@
1
+ import { ImportDeclaration, TsType, VariableDeclaration } from '@swc/core';
2
+ import Visitor from '@swc/core/Visitor';
3
+ declare class AutoCSSModule extends Visitor {
4
+ visitTsType(expression: TsType): TsType;
5
+ visitImportDeclaration(expression: ImportDeclaration): ImportDeclaration;
6
+ visitVariableDeclaration(expression: VariableDeclaration): VariableDeclaration;
7
+ }
8
+ export default AutoCSSModule;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Visitor_1 = __importDefault(require("@swc/core/Visitor"));
7
+ const path_1 = require("path");
8
+ const CSS_EXT_NAMES = ['.css', '.less', '.sass', '.scss', '.stylus', '.styl'];
9
+ class AutoCSSModule extends Visitor_1.default {
10
+ visitTsType(expression) {
11
+ return expression;
12
+ }
13
+ visitImportDeclaration(expression) {
14
+ const { specifiers, source } = expression;
15
+ const { value } = source;
16
+ if (specifiers.length && CSS_EXT_NAMES.includes((0, path_1.extname)(value))) {
17
+ return Object.assign(Object.assign({}, expression), { source: Object.assign(Object.assign({}, source), { value: `${value}?modules` }) });
18
+ }
19
+ return expression;
20
+ }
21
+ visitVariableDeclaration(expression) {
22
+ const { declarations } = expression;
23
+ if (declarations.length &&
24
+ declarations[0].init &&
25
+ declarations[0].init.type === 'AwaitExpression' &&
26
+ declarations[0].init.argument.type === 'CallExpression' &&
27
+ declarations[0].init.argument.arguments[0].expression.type ===
28
+ 'StringLiteral' &&
29
+ CSS_EXT_NAMES.includes((0, path_1.extname)(declarations[0].init.argument.arguments[0].expression.value))) {
30
+ declarations[0].init.argument.arguments[0].expression.value = `${declarations[0].init.argument.arguments[0].expression.value}?modules`;
31
+ }
32
+ return expression;
33
+ }
34
+ }
35
+ exports.default = AutoCSSModule;
@@ -0,0 +1,6 @@
1
+ import { ImportDeclaration } from '@swc/core';
2
+ import Visitor from '@swc/core/Visitor';
3
+ declare class LockCoreJS extends Visitor {
4
+ visitImportDeclaration(expression: ImportDeclaration): ImportDeclaration;
5
+ }
6
+ export default LockCoreJS;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Visitor_1 = __importDefault(require("@swc/core/Visitor"));
7
+ const utils_1 = require("@umijs/utils");
8
+ const path_1 = require("path");
9
+ function addLastSlash(path) {
10
+ return path.endsWith('/') ? path : `${path}/`;
11
+ }
12
+ class LockCoreJS extends Visitor_1.default {
13
+ visitImportDeclaration(expression) {
14
+ const { source } = expression;
15
+ let { value, type } = source;
16
+ if (type === 'StringLiteral' && value.startsWith('core-js/')) {
17
+ value = value.replace(/^core-js\//, addLastSlash((0, utils_1.winPath)((0, path_1.dirname)(require.resolve('core-js/package.json')))));
18
+ return Object.assign(Object.assign({}, expression), { source: Object.assign(Object.assign({}, source), { value }) });
19
+ }
20
+ return expression;
21
+ }
22
+ }
23
+ exports.default = LockCoreJS;
package/dist/types.d.ts CHANGED
@@ -52,6 +52,9 @@ export interface IConfig {
52
52
  depTranspiler?: Transpiler;
53
53
  devtool?: Config.DevTool;
54
54
  externals?: WebpackConfig['externals'];
55
+ esm?: {
56
+ [key: string]: any;
57
+ };
55
58
  extraBabelPlugins?: IBabelPlugin[];
56
59
  extraBabelPresets?: IBabelPlugin[];
57
60
  extraPostCSSPlugins?: any[];
package/package.json CHANGED
@@ -1,9 +1,19 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.13",
4
4
  "description": "@umijs/bundler-webpack",
5
+ "homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-webpack#readme",
6
+ "bugs": "https://github.com/umijs/umi-next/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/umijs/umi-next"
10
+ },
11
+ "license": "MIT",
5
12
  "main": "dist/index.js",
6
13
  "types": "dist/index.d.ts",
14
+ "bin": {
15
+ "bundler-webpack": "bin/bundler-webpack.js"
16
+ },
7
17
  "files": [
8
18
  "bin",
9
19
  "client",
@@ -17,44 +27,30 @@
17
27
  "dev": "pnpm build -- --watch",
18
28
  "generate:webpackPackages": "zx ./scripts/generateWebpackPackages.mjs"
19
29
  },
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/umijs/umi-next"
23
- },
24
- "authors": [
25
- "chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
26
- ],
27
- "license": "MIT",
28
- "bugs": "https://github.com/umijs/umi-next/issues",
29
- "homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-webpack#readme",
30
- "publishConfig": {
31
- "access": "public"
32
- },
33
- "bin": {
34
- "bundler-webpack": "bin/bundler-webpack.js"
35
- },
36
30
  "dependencies": {
37
- "@pmmmwh/react-refresh-webpack-plugin": "0.5.1",
38
- "@swc/core": "1.2.105",
31
+ "@pmmmwh/react-refresh-webpack-plugin": "0.5.3",
32
+ "@svgr/core": "6.0.0",
33
+ "@svgr/plugin-jsx": "^6.1.0",
34
+ "@svgr/plugin-svgo": "^6.1.0",
35
+ "@swc/core": "1.2.117",
39
36
  "@types/hapi__joi": "17.1.7",
40
- "@umijs/babel-preset-umi": "4.0.0-beta.1",
41
- "@umijs/mfsu": "4.0.0-beta.1",
42
- "@umijs/utils": "4.0.0-beta.1",
43
- "css-loader": "6.4.0",
37
+ "@umijs/babel-preset-umi": "4.0.0-beta.13",
38
+ "@umijs/mfsu": "4.0.0-beta.13",
39
+ "@umijs/utils": "4.0.0-beta.13",
40
+ "css-loader": "6.5.1",
44
41
  "es5-imcompatible-versions": "^0.1.73",
45
- "jest-worker": "27.3.1",
42
+ "jest-worker": "27.4.2",
46
43
  "node-libs-browser": "2.2.1",
47
- "postcss": "^8.3.11",
48
- "postcss-preset-env": "6.7.0",
44
+ "postcss": "^8.4.4",
45
+ "postcss-preset-env": "7.0.1",
49
46
  "react-error-overlay": "6.0.9"
50
47
  },
51
48
  "devDependencies": {
52
- "@svgr/webpack": "5.5.0",
53
49
  "@types/express": "4.17.13",
54
50
  "@types/webpack-sources": "3.2.0",
55
- "@types/ws": "8.2.0",
56
- "autoprefixer": "10.3.7",
57
- "babel-loader": "8.2.2",
51
+ "@types/ws": "8.2.1",
52
+ "autoprefixer": "10.4.0",
53
+ "babel-loader": "8.2.3",
58
54
  "compression": "1.7.4",
59
55
  "connect-history-api-fallback": "1.6.0",
60
56
  "copy-webpack-plugin": "9.0.1",
@@ -64,31 +60,36 @@
64
60
  "http-proxy-middleware": "2.0.1",
65
61
  "less": "4.1.2",
66
62
  "less-loader": "10.2.0",
67
- "mini-css-extract-plugin": "2.4.2",
63
+ "mini-css-extract-plugin": "2.4.5",
68
64
  "postcss-flexbugs-fixes": "5.0.2",
69
- "postcss-loader": "6.2.0",
65
+ "postcss-loader": "6.2.1",
70
66
  "purgecss-webpack-plugin": "4.0.3",
71
- "react-refresh": "0.10.0",
72
- "sass-loader": "12.2.0",
73
- "schema-utils": "3.1.1",
67
+ "react-refresh": "0.11.0",
68
+ "sass-loader": "12.3.0",
69
+ "schema-utils": "4.0.0",
74
70
  "speed-measure-webpack-plugin": "1.5.0",
75
- "style-loader": "3.3.0",
71
+ "style-loader": "3.3.1",
76
72
  "svgo-loader": "3.0.0",
77
73
  "swc-loader": "0.1.15",
78
74
  "tapable": "2.2.1",
79
- "terser": "5.9.0",
80
- "terser-webpack-plugin": "5.2.4",
75
+ "terser": "5.10.0",
76
+ "terser-webpack-plugin": "5.2.5",
81
77
  "url-loader": "4.1.1",
82
- "webpack": "5.59.0",
78
+ "webpack": "5.64.4",
83
79
  "webpack-5-chain": "8.0.0",
84
80
  "webpack-bundle-analyzer": "4.5.0",
85
- "webpack-dev-middleware": "5.2.1",
86
- "webpack-sources": "3.2.1",
81
+ "webpack-dev-middleware": "5.2.2",
82
+ "webpack-sources": "3.2.2",
87
83
  "ws": "8.2.3"
88
84
  },
85
+ "publishConfig": {
86
+ "access": "public"
87
+ },
88
+ "authors": [
89
+ "chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
90
+ ],
89
91
  "compiledConfig": {
90
92
  "deps": [
91
- "@svgr/webpack",
92
93
  "autoprefixer",
93
94
  "babel-loader",
94
95
  "copy-webpack-plugin",
@@ -159,7 +160,6 @@
159
160
  "webpack"
160
161
  ],
161
162
  "excludeDtsDeps": [
162
- "@svgr/webpack",
163
163
  "babel-loader",
164
164
  "copy-webpack-plugin",
165
165
  "css-loader",
@@ -1,75 +0,0 @@
1
- # replace default config
2
-
3
- # multipass: true
4
- # full: true
5
-
6
- plugins:
7
-
8
- # - name
9
- #
10
- # or:
11
- # - name: false
12
- # - name: true
13
- #
14
- # or:
15
- # - name:
16
- # param1: 1
17
- # param2: 2
18
-
19
- - removeDoctype
20
- - removeXMLProcInst
21
- - removeComments
22
- - removeMetadata
23
- - removeXMLNS
24
- - removeEditorsNSData
25
- - cleanupAttrs
26
- - inlineStyles
27
- - minifyStyles
28
- - convertStyleToAttrs
29
- - cleanupIDs
30
- - prefixIds
31
- - removeRasterImages
32
- - removeUselessDefs
33
- - cleanupNumericValues
34
- - cleanupListOfValues
35
- - convertColors
36
- - removeUnknownsAndDefaults
37
- - removeNonInheritableGroupAttrs
38
- - removeUselessStrokeAndFill
39
- - removeViewBox
40
- - cleanupEnableBackground
41
- - removeHiddenElems
42
- - removeEmptyText
43
- - convertShapeToPath
44
- - convertEllipseToCircle
45
- - moveElemsAttrsToGroup
46
- - moveGroupAttrsToElems
47
- - collapseGroups
48
- - convertPathData
49
- - convertTransform
50
- - removeEmptyAttrs
51
- - removeEmptyContainers
52
- - mergePaths
53
- - removeUnusedNS
54
- - sortAttrs
55
- - sortDefsChildren
56
- - removeTitle
57
- - removeDesc
58
- - removeDimensions
59
- - removeAttrs
60
- - removeAttributesBySelector
61
- - removeElementsByAttr
62
- - addClassesToSVGElement
63
- - removeStyleElement
64
- - removeScriptElement
65
- - addAttributesToSVGElement
66
- - removeOffCanvasPaths
67
- - reusePaths
68
-
69
- # configure the indent (default 4 spaces) used by `--pretty` here:
70
- #
71
- # @see https://github.com/svg/svgo/blob/master/lib/svgo/js2svg.js#L6 for more config options
72
- #
73
- # js2svg:
74
- # pretty: true
75
- # indent: ' '
@@ -1,7 +0,0 @@
1
- Copyright 2017 Smooth Code
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.