@umijs/bundler-webpack 4.0.0-canary.20220428.1 → 4.0.0-canary.20220429.2

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 (99) hide show
  1. package/package.json +6 -8
  2. package/dist/build.d.ts +0 -20
  3. package/dist/build.js +0 -75
  4. package/dist/cli.d.ts +0 -1
  5. package/dist/cli.js +0 -90
  6. package/dist/client/client.d.ts +0 -1
  7. package/dist/client/client.js +0 -258
  8. package/dist/config/_sampleFeature.d.ts +0 -10
  9. package/dist/config/_sampleFeature.js +0 -22
  10. package/dist/config/assetRules.d.ts +0 -11
  11. package/dist/config/assetRules.js +0 -61
  12. package/dist/config/bundleAnalyzerPlugin.d.ts +0 -10
  13. package/dist/config/bundleAnalyzerPlugin.js +0 -30
  14. package/dist/config/compressPlugin.d.ts +0 -10
  15. package/dist/config/compressPlugin.js +0 -91
  16. package/dist/config/config.d.ts +0 -27
  17. package/dist/config/config.js +0 -226
  18. package/dist/config/copyPlugin.d.ts +0 -10
  19. package/dist/config/copyPlugin.js +0 -49
  20. package/dist/config/cssRules.d.ts +0 -11
  21. package/dist/config/cssRules.js +0 -98
  22. package/dist/config/definePlugin.d.ts +0 -15
  23. package/dist/config/definePlugin.js +0 -45
  24. package/dist/config/detectDeadCode.d.ts +0 -12
  25. package/dist/config/detectDeadCode.js +0 -120
  26. package/dist/config/detectDeadCodePlugin.d.ts +0 -9
  27. package/dist/config/detectDeadCodePlugin.js +0 -75
  28. package/dist/config/fastRefreshPlugin.d.ts +0 -12
  29. package/dist/config/fastRefreshPlugin.js +0 -34
  30. package/dist/config/forkTSCheckerPlugin.d.ts +0 -11
  31. package/dist/config/forkTSCheckerPlugin.js +0 -34
  32. package/dist/config/harmonyLinkingErrorPlugin.d.ts +0 -6
  33. package/dist/config/harmonyLinkingErrorPlugin.js +0 -42
  34. package/dist/config/ignorePlugin.d.ts +0 -10
  35. package/dist/config/ignorePlugin.js +0 -27
  36. package/dist/config/javaScriptRules.d.ts +0 -16
  37. package/dist/config/javaScriptRules.js +0 -188
  38. package/dist/config/manifestPlugin.d.ts +0 -11
  39. package/dist/config/manifestPlugin.js +0 -25
  40. package/dist/config/miniCSSExtractPlugin.d.ts +0 -11
  41. package/dist/config/miniCSSExtractPlugin.js +0 -33
  42. package/dist/config/nodePolyfill.d.ts +0 -10
  43. package/dist/config/nodePolyfill.js +0 -35
  44. package/dist/config/nodePrefixPlugin.d.ts +0 -11
  45. package/dist/config/nodePrefixPlugin.js +0 -25
  46. package/dist/config/progressPlugin.d.ts +0 -11
  47. package/dist/config/progressPlugin.js +0 -27
  48. package/dist/config/purgecssWebpackPlugin.d.ts +0 -10
  49. package/dist/config/purgecssWebpackPlugin.js +0 -32
  50. package/dist/config/speedMeasureWebpackPlugin.d.ts +0 -6
  51. package/dist/config/speedMeasureWebpackPlugin.js +0 -34
  52. package/dist/config/svgRules.d.ts +0 -12
  53. package/dist/config/svgRules.js +0 -57
  54. package/dist/constants.d.ts +0 -15
  55. package/dist/constants.js +0 -24
  56. package/dist/dev.d.ts +0 -25
  57. package/dist/dev.js +0 -145
  58. package/dist/index.d.ts +0 -8
  59. package/dist/index.js +0 -20
  60. package/dist/loader/svgr.d.ts +0 -4
  61. package/dist/loader/svgr.js +0 -67
  62. package/dist/loader/swc.d.ts +0 -4
  63. package/dist/loader/swc.js +0 -79
  64. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
  65. package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -63
  66. package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +0 -10
  67. package/dist/plugins/ParcelCSSMinifyPlugin.js +0 -75
  68. package/dist/plugins/ProgressPlugin.d.ts +0 -15
  69. package/dist/plugins/ProgressPlugin.js +0 -44
  70. package/dist/plugins/RuntimePublicPathPlugin.d.ts +0 -4
  71. package/dist/plugins/RuntimePublicPathPlugin.js +0 -20
  72. package/dist/plugins/_SamplePlugin.d.ts +0 -9
  73. package/dist/plugins/_SamplePlugin.js +0 -14
  74. package/dist/requireHook.d.ts +0 -1
  75. package/dist/requireHook.js +0 -31
  76. package/dist/schema.d.ts +0 -3
  77. package/dist/schema.js +0 -84
  78. package/dist/server/https.d.ts +0 -4
  79. package/dist/server/https.js +0 -74
  80. package/dist/server/server.d.ts +0 -17
  81. package/dist/server/server.js +0 -202
  82. package/dist/server/ws.d.ts +0 -11
  83. package/dist/server/ws.js +0 -42
  84. package/dist/swcPlugins/autoCSSModules.d.ts +0 -13
  85. package/dist/swcPlugins/autoCSSModules.js +0 -34
  86. package/dist/swcPlugins/changeImportFromString.d.ts +0 -2
  87. package/dist/swcPlugins/changeImportFromString.js +0 -10
  88. package/dist/swcPlugins/lockCoreJS.d.ts +0 -6
  89. package/dist/swcPlugins/lockCoreJS.js +0 -24
  90. package/dist/types.d.ts +0 -123
  91. package/dist/types.js +0 -30
  92. package/dist/utils/browsersList.d.ts +0 -5
  93. package/dist/utils/browsersList.js +0 -10
  94. package/dist/utils/depMatch.d.ts +0 -6
  95. package/dist/utils/depMatch.js +0 -46
  96. package/dist/utils/formatWebpackMessages.d.ts +0 -12
  97. package/dist/utils/formatWebpackMessages.js +0 -100
  98. package/dist/utils/getEsBuildTarget.d.ts +0 -5
  99. package/dist/utils/getEsBuildTarget.js +0 -12
@@ -1,202 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.createServer = void 0;
16
- const express_1 = __importDefault(require("@umijs/bundler-utils/compiled/express"));
17
- const http_proxy_middleware_1 = require("@umijs/bundler-webpack/compiled/http-proxy-middleware");
18
- const webpack_1 = __importDefault(require("@umijs/bundler-webpack/compiled/webpack"));
19
- const utils_1 = require("@umijs/utils");
20
- const fs_1 = require("fs");
21
- const http_1 = __importDefault(require("http"));
22
- const path_1 = require("path");
23
- const constants_1 = require("../constants");
24
- const https_1 = require("./https");
25
- const ws_1 = require("./ws");
26
- function createServer(opts) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const { webpackConfig, userConfig } = opts;
29
- const { proxy } = userConfig;
30
- const app = (0, express_1.default)();
31
- // cros
32
- app.use((_req, res, next) => {
33
- res.header('Access-Control-Allow-Origin', '*');
34
- res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With');
35
- res.header('Access-Control-Allow-Methods', 'GET, HEAD, PUT, POST, PATCH, DELETE, OPTIONS');
36
- next();
37
- });
38
- // compression
39
- app.use(require('@umijs/bundler-webpack/compiled/compression')());
40
- // TODO: headers
41
- // before middlewares
42
- (opts.beforeMiddlewares || []).forEach((m) => app.use(m));
43
- // TODO: add to before middleware
44
- app.use((req, res, next) => {
45
- if (req.path === '/umi.js' && (0, fs_1.existsSync)((0, path_1.join)(opts.cwd, 'umi.js'))) {
46
- res.setHeader('Content-Type', 'application/javascript');
47
- (0, fs_1.createReadStream)((0, path_1.join)(opts.cwd, 'umi.js')).on('error', next).pipe(res);
48
- }
49
- else {
50
- next();
51
- }
52
- });
53
- // webpack dev middleware
54
- const configs = Array.isArray(webpackConfig)
55
- ? webpackConfig
56
- : [webpackConfig];
57
- const progresses = [];
58
- if (opts.onProgress) {
59
- configs.forEach((config) => {
60
- const progress = {
61
- percent: 0,
62
- status: 'waiting',
63
- };
64
- progresses.push(progress);
65
- config.plugins.push(new webpack_1.default.ProgressPlugin((percent, msg) => {
66
- progress.percent = percent;
67
- progress.status = msg;
68
- opts.onProgress({ progresses });
69
- }));
70
- });
71
- }
72
- const compiler = (0, webpack_1.default)(configs);
73
- const webpackDevMiddleware = require('@umijs/bundler-webpack/compiled/webpack-dev-middleware');
74
- const compilerMiddleware = webpackDevMiddleware(compiler, {
75
- publicPath: userConfig.publicPath || '/',
76
- writeToDisk: userConfig.writeToDisk,
77
- stats: 'none',
78
- // watchOptions: { ignored }
79
- });
80
- app.use(compilerMiddleware);
81
- // hmr hooks
82
- let stats;
83
- let isFirstCompile = true;
84
- compiler.compilers.forEach(addHooks);
85
- function addHooks(compiler) {
86
- compiler.hooks.invalid.tap('server', () => {
87
- sendMessage(constants_1.MESSAGE_TYPE.invalid);
88
- });
89
- compiler.hooks.done.tap('server', (_stats) => {
90
- var _a;
91
- stats = _stats;
92
- sendStats(getStats(stats));
93
- (_a = opts.onDevCompileDone) === null || _a === void 0 ? void 0 : _a.call(opts, {
94
- stats,
95
- isFirstCompile,
96
- time: stats.endTime - stats.startTime,
97
- });
98
- isFirstCompile = false;
99
- });
100
- }
101
- function sendStats(stats, force, sender) {
102
- const shouldEmit = !force &&
103
- stats &&
104
- (!stats.errors || stats.errors.length === 0) &&
105
- (!stats.warnings || stats.warnings.length === 0) &&
106
- stats.assets &&
107
- stats.assets.every((asset) => !asset.emitted);
108
- if (shouldEmit) {
109
- sendMessage(constants_1.MESSAGE_TYPE.stillOk, null, sender);
110
- return;
111
- }
112
- sendMessage(constants_1.MESSAGE_TYPE.hash, stats.hash, sender);
113
- if ((stats.errors && stats.errors.length > 0) ||
114
- (stats.warnings && stats.warnings.length > 0)) {
115
- if (stats.warnings && stats.warnings.length > 0) {
116
- sendMessage(constants_1.MESSAGE_TYPE.warnings, stats.warnings, sender);
117
- }
118
- if (stats.errors && stats.errors.length > 0) {
119
- sendMessage(constants_1.MESSAGE_TYPE.errors, stats.errors, sender);
120
- }
121
- }
122
- else {
123
- sendMessage(constants_1.MESSAGE_TYPE.ok, null, sender);
124
- }
125
- }
126
- function getStats(stats) {
127
- return stats.toJson({
128
- all: false,
129
- hash: true,
130
- assets: true,
131
- warnings: true,
132
- errors: true,
133
- errorDetails: false,
134
- });
135
- }
136
- function sendMessage(type, data, sender) {
137
- (sender || ws).send(JSON.stringify({ type, data }));
138
- }
139
- // mock
140
- // proxy
141
- if (proxy) {
142
- Object.keys(proxy).forEach((key) => {
143
- const proxyConfig = proxy[key];
144
- const target = proxyConfig.target;
145
- if (target) {
146
- app.use(key, (0, http_proxy_middleware_1.createProxyMiddleware)(key, Object.assign(Object.assign({}, proxy[key]), {
147
- // Add x-real-url in response header
148
- onProxyRes(proxyRes, req) {
149
- var _a;
150
- proxyRes.headers['x-real-url'] =
151
- ((_a = new URL(req.url || '', target)) === null || _a === void 0 ? void 0 : _a.href) || '';
152
- } })));
153
- }
154
- });
155
- }
156
- // after middlewares
157
- (opts.afterMiddlewares || []).forEach((m) => {
158
- // TODO: FIXME
159
- app.use(m.toString().includes(`{ compiler }`) ? m({ compiler }) : m);
160
- });
161
- // history fallback
162
- app.use(require('@umijs/bundler-webpack/compiled/connect-history-api-fallback')({
163
- index: '/',
164
- }));
165
- // hmr reconnect ping
166
- app.use('/__umi_ping', (_, res) => {
167
- res.end('pong');
168
- });
169
- // index.html
170
- // TODO: remove me
171
- app.get('/', (_req, res, next) => {
172
- res.set('Content-Type', 'text/html');
173
- const htmlPath = (0, path_1.join)(opts.cwd, 'index.html');
174
- if ((0, fs_1.existsSync)(htmlPath)) {
175
- (0, fs_1.createReadStream)(htmlPath).on('error', next).pipe(res);
176
- }
177
- else {
178
- next();
179
- }
180
- });
181
- const server = userConfig.https
182
- ? yield (0, https_1.createHttpsServer)(app, userConfig.https)
183
- : http_1.default.createServer(app);
184
- if (!server) {
185
- return null;
186
- }
187
- const ws = (0, ws_1.createWebSocketServer)(server);
188
- ws.wss.on('connection', (socket) => {
189
- if (stats) {
190
- sendStats(getStats(stats), false, socket);
191
- }
192
- });
193
- const protocol = userConfig.https ? 'https:' : 'http:';
194
- const port = opts.port || 8000;
195
- server.listen(port, () => {
196
- const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
197
- utils_1.logger.ready(`App listening at ${utils_1.chalk.green(`${protocol}//${host}:${port}`)}`);
198
- });
199
- return server;
200
- });
201
- }
202
- exports.createServer = createServer;
@@ -1,11 +0,0 @@
1
- /// <reference types="node" />
2
- import { Server as HttpServer } from 'http';
3
- import { Http2Server } from 'http2';
4
- import { Server as HttpsServer } from 'https';
5
- import { Server } from 'spdy';
6
- import WebSocket from '../../compiled/ws';
7
- export declare function createWebSocketServer(server: HttpServer | HttpsServer | Http2Server | Server): {
8
- send(message: string): void;
9
- wss: WebSocket.Server;
10
- close(): void;
11
- };
package/dist/server/ws.js DELETED
@@ -1,42 +0,0 @@
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
- exports.createWebSocketServer = void 0;
7
- const utils_1 = require("@umijs/utils");
8
- const ws_1 = __importDefault(require("../../compiled/ws"));
9
- function createWebSocketServer(server) {
10
- const wss = new ws_1.default.Server({
11
- noServer: true,
12
- });
13
- server.on('upgrade', (req, socket, head) => {
14
- if (req.headers['sec-websocket-protocol'] === 'webpack-hmr') {
15
- wss.handleUpgrade(req, socket, head, (ws) => {
16
- wss.emit('connection', ws, req);
17
- });
18
- }
19
- });
20
- wss.on('connection', (socket) => {
21
- socket.send(JSON.stringify({ type: 'connected' }));
22
- });
23
- wss.on('error', (e) => {
24
- if (e.code !== 'EADDRINUSE') {
25
- console.error(utils_1.chalk.red(`WebSocket server error:\n${e.stack || e.message}`));
26
- }
27
- });
28
- return {
29
- send(message) {
30
- wss.clients.forEach((client) => {
31
- if (client.readyState === ws_1.default.OPEN) {
32
- client.send(message);
33
- }
34
- });
35
- },
36
- wss,
37
- close() {
38
- wss.close();
39
- },
40
- };
41
- }
42
- exports.createWebSocketServer = createWebSocketServer;
@@ -1,13 +0,0 @@
1
- import type { ImportDeclaration, ModuleItem, TsType } from '@swc/core';
2
- import Visitor from '@swc/core/Visitor';
3
- declare class AutoCSSModule extends Visitor {
4
- visitTsType(expression: TsType): TsType;
5
- /**
6
- * call path:
7
- * visitProgram -> visitModule -> visitModuleItems -> visitModuleItem -> visitImportDeclaration
8
- * @see https://github.com/swc-project/swc/blob/main/node-swc/src/Visitor.ts#L189
9
- */
10
- visitModuleItem(n: ModuleItem): ImportDeclaration | import("@swc/core").ExportDeclaration | import("@swc/core").ExportNamedDeclaration | import("@swc/core").ExportDefaultDeclaration | import("@swc/core").ExportDefaultExpression | import("@swc/core").ExportAllDeclaration | import("@swc/core").TsImportEqualsDeclaration | import("@swc/core").TsExportAssignment | import("@swc/core").TsNamespaceExportDeclaration | import("@swc/core").ExpressionStatement | import("@swc/core").BlockStatement | import("@swc/core").EmptyStatement | import("@swc/core").DebuggerStatement | import("@swc/core").WithStatement | import("@swc/core").ReturnStatement | import("@swc/core").LabeledStatement | import("@swc/core").BreakStatement | import("@swc/core").ContinueStatement | import("@swc/core").IfStatement | import("@swc/core").SwitchStatement | import("@swc/core").ThrowStatement | import("@swc/core").TryStatement | import("@swc/core").WhileStatement | import("@swc/core").DoWhileStatement | import("@swc/core").ForStatement | import("@swc/core").ForInStatement | import("@swc/core").ForOfStatement | import("@swc/core").ClassDeclaration | import("@swc/core").FunctionDeclaration | import("@swc/core").VariableDeclaration | import("@swc/core").TsInterfaceDeclaration | import("@swc/core").TsTypeAliasDeclaration | import("@swc/core").TsEnumDeclaration | import("@swc/core").TsModuleDeclaration;
11
- visitImportDeclaration(expression: ImportDeclaration): ImportDeclaration;
12
- }
13
- export default AutoCSSModule;
@@ -1,34 +0,0 @@
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 changeImportFromString_1 = require("./changeImportFromString");
9
- class AutoCSSModule extends Visitor_1.default {
10
- visitTsType(expression) {
11
- return expression;
12
- }
13
- /**
14
- * call path:
15
- * visitProgram -> visitModule -> visitModuleItems -> visitModuleItem -> visitImportDeclaration
16
- * @see https://github.com/swc-project/swc/blob/main/node-swc/src/Visitor.ts#L189
17
- */
18
- visitModuleItem(n) {
19
- if (n.type === 'ImportDeclaration') {
20
- return this.visitImportDeclaration(n);
21
- }
22
- return n;
23
- }
24
- visitImportDeclaration(expression) {
25
- const { specifiers, source } = expression;
26
- const { value } = source;
27
- if (specifiers.length && (0, utils_1.isStyleFile)({ filename: value })) {
28
- const newImportFrom = `${value}?modules`;
29
- (0, changeImportFromString_1.changeImportFromString)(expression, newImportFrom);
30
- }
31
- return expression;
32
- }
33
- }
34
- exports.default = AutoCSSModule;
@@ -1,2 +0,0 @@
1
- import type { ImportDeclaration } from '@swc/core';
2
- export declare const changeImportFromString: (e: ImportDeclaration, v: string) => void;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.changeImportFromString = void 0;
4
- const changeImportFromString = (e, v) => {
5
- e.source.value = v;
6
- // sync change to `raw`
7
- // https://github.com/swc-project/swc/issues/4128
8
- e.source.raw = `'${v}'`;
9
- };
10
- exports.changeImportFromString = changeImportFromString;
@@ -1,6 +0,0 @@
1
- import type { 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;
@@ -1,24 +0,0 @@
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
- const changeImportFromString_1 = require("./changeImportFromString");
10
- function addLastSlash(path) {
11
- return path.endsWith('/') ? path : `${path}/`;
12
- }
13
- class LockCoreJS extends Visitor_1.default {
14
- visitImportDeclaration(expression) {
15
- const { source } = expression;
16
- let { value, type } = source;
17
- if (type === 'StringLiteral' && value.startsWith('core-js/')) {
18
- const newValue = value.replace(/^core-js\//, addLastSlash((0, utils_1.winPath)((0, path_1.dirname)(require.resolve('core-js/package.json')))));
19
- (0, changeImportFromString_1.changeImportFromString)(expression, newValue);
20
- }
21
- return expression;
22
- }
23
- }
24
- exports.default = LockCoreJS;
package/dist/types.d.ts DELETED
@@ -1,123 +0,0 @@
1
- import type { Config as SwcConfig } from '@swc/core';
2
- import type { Options as ProxyOptions } from '../compiled/http-proxy-middleware';
3
- import { Configuration } from '../compiled/webpack';
4
- import Config from '../compiled/webpack-5-chain';
5
- export declare enum Env {
6
- development = "development",
7
- production = "production"
8
- }
9
- export declare enum Transpiler {
10
- babel = "babel",
11
- swc = "swc",
12
- esbuild = "esbuild",
13
- none = "none"
14
- }
15
- export declare enum JSMinifier {
16
- terser = "terser",
17
- swc = "swc",
18
- esbuild = "esbuild",
19
- uglifyJs = "uglifyJs",
20
- none = "none"
21
- }
22
- export declare enum CSSMinifier {
23
- esbuild = "esbuild",
24
- cssnano = "cssnano",
25
- parcelCSS = "parcelCSS",
26
- none = "none"
27
- }
28
- export interface ICopy {
29
- from: string;
30
- to: string;
31
- }
32
- declare type WebpackConfig = Required<Configuration>;
33
- declare type IBabelPlugin = Function | string | [string, {
34
- [key: string]: any;
35
- }];
36
- export interface DeadCodeParams {
37
- patterns?: string[];
38
- exclude?: string[];
39
- failOnHint?: boolean;
40
- detectUnusedFiles?: boolean;
41
- detectUnusedExport?: boolean;
42
- context?: string;
43
- }
44
- export interface HttpsParams {
45
- key?: string;
46
- cert?: string;
47
- hosts?: string[];
48
- }
49
- export interface IConfig {
50
- alias?: Record<string, string>;
51
- autoCSSModules?: boolean;
52
- base?: string;
53
- chainWebpack?: Function;
54
- copy?: ICopy[] | string[];
55
- cssLoader?: {
56
- [key: string]: any;
57
- };
58
- cssLoaderModules?: {
59
- [key: string]: any;
60
- };
61
- cssMinifier?: CSSMinifier;
62
- cssMinifierOptions?: {
63
- [key: string]: any;
64
- };
65
- define?: {
66
- [key: string]: any;
67
- };
68
- depTranspiler?: Transpiler;
69
- devtool?: Config.DevTool;
70
- deadCode?: DeadCodeParams;
71
- https?: HttpsParams;
72
- externals?: WebpackConfig['externals'];
73
- esm?: {
74
- [key: string]: any;
75
- };
76
- extraBabelPlugins?: IBabelPlugin[];
77
- extraBabelPresets?: IBabelPlugin[];
78
- extraBabelIncludes?: string[];
79
- extraPostCSSPlugins?: any[];
80
- hash?: boolean;
81
- ignoreMomentLocale?: boolean;
82
- jsMinifier?: JSMinifier;
83
- jsMinifierOptions?: {
84
- [key: string]: any;
85
- };
86
- lessLoader?: {
87
- [key: string]: any;
88
- };
89
- outputPath?: string;
90
- postcssLoader?: {
91
- [key: string]: any;
92
- };
93
- proxy?: {
94
- [key: string]: ProxyOptions;
95
- };
96
- publicPath?: string;
97
- purgeCSS?: {
98
- [key: string]: any;
99
- };
100
- sassLoader?: {
101
- [key: string]: any;
102
- };
103
- srcTranspiler?: Transpiler;
104
- styleLoader?: {
105
- [key: string]: any;
106
- };
107
- svgr?: {
108
- [key: string]: any;
109
- };
110
- svgo?: {
111
- [key: string]: any;
112
- } | false;
113
- targets?: {
114
- [key: string]: any;
115
- };
116
- writeToDisk?: boolean;
117
- [key: string]: any;
118
- }
119
- export interface SwcOptions extends SwcConfig {
120
- sync?: boolean;
121
- parseMap?: boolean;
122
- }
123
- export {};
package/dist/types.js DELETED
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CSSMinifier = exports.JSMinifier = exports.Transpiler = exports.Env = void 0;
4
- var Env;
5
- (function (Env) {
6
- Env["development"] = "development";
7
- Env["production"] = "production";
8
- })(Env = exports.Env || (exports.Env = {}));
9
- var Transpiler;
10
- (function (Transpiler) {
11
- Transpiler["babel"] = "babel";
12
- Transpiler["swc"] = "swc";
13
- Transpiler["esbuild"] = "esbuild";
14
- Transpiler["none"] = "none";
15
- })(Transpiler = exports.Transpiler || (exports.Transpiler = {}));
16
- var JSMinifier;
17
- (function (JSMinifier) {
18
- JSMinifier["terser"] = "terser";
19
- JSMinifier["swc"] = "swc";
20
- JSMinifier["esbuild"] = "esbuild";
21
- JSMinifier["uglifyJs"] = "uglifyJs";
22
- JSMinifier["none"] = "none";
23
- })(JSMinifier = exports.JSMinifier || (exports.JSMinifier = {}));
24
- var CSSMinifier;
25
- (function (CSSMinifier) {
26
- CSSMinifier["esbuild"] = "esbuild";
27
- CSSMinifier["cssnano"] = "cssnano";
28
- CSSMinifier["parcelCSS"] = "parcelCSS";
29
- CSSMinifier["none"] = "none";
30
- })(CSSMinifier = exports.CSSMinifier || (exports.CSSMinifier = {}));
@@ -1,5 +0,0 @@
1
- interface IOpts {
2
- targets: Record<string, any>;
3
- }
4
- export declare function getBrowsersList({ targets }: IOpts): any;
5
- export {};
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBrowsersList = void 0;
4
- function getBrowsersList({ targets }) {
5
- return (targets.browsers ||
6
- Object.keys(targets).map((key) => {
7
- return `${key} >= ${targets[key] === true ? '0' : targets[key]}`;
8
- }));
9
- }
10
- exports.getBrowsersList = getBrowsersList;
@@ -1,6 +0,0 @@
1
- export declare function cleanCache(): void;
2
- export declare function isMatch(opts: {
3
- path: string;
4
- pkgs: Record</*name*/ string, /*version*/ string[]>;
5
- }): boolean;
6
- export declare function es5ImcompatibleVersionsToPkg(): Record<string, string[]>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.es5ImcompatibleVersionsToPkg = exports.isMatch = exports.cleanCache = void 0;
4
- const utils_1 = require("@umijs/utils");
5
- const path_1 = require("path");
6
- const cache = new Map();
7
- function cleanCache() {
8
- cache.clear();
9
- }
10
- exports.cleanCache = cleanCache;
11
- function isMatch(opts) {
12
- // cache by dir, 命中率会更高
13
- const dir = (0, utils_1.winPath)((0, path_1.dirname)(opts.path));
14
- if (cache.has(dir)) {
15
- return !!cache.get(dir);
16
- }
17
- else {
18
- const pkgPath = utils_1.pkgUp.pkgUpSync({ cwd: opts.path });
19
- let ret;
20
- if (!pkgPath) {
21
- ret = false;
22
- }
23
- else {
24
- const { name, version } = require(pkgPath);
25
- if (opts.pkgs[name]) {
26
- ret = opts.pkgs[name].some((v) => {
27
- return utils_1.semver.satisfies(version, v);
28
- });
29
- }
30
- else {
31
- ret = false;
32
- }
33
- }
34
- cache.set(dir, ret);
35
- return ret;
36
- }
37
- }
38
- exports.isMatch = isMatch;
39
- function es5ImcompatibleVersionsToPkg() {
40
- const { config: { 'es5-imcompatible-versions': config }, } = require('es5-imcompatible-versions/package.json');
41
- return Object.keys(config).reduce((memo, key) => {
42
- memo[key] = /* versions */ Object.keys(config[key]);
43
- return memo;
44
- }, {});
45
- }
46
- exports.es5ImcompatibleVersionsToPkg = es5ImcompatibleVersionsToPkg;
@@ -1,12 +0,0 @@
1
- export declare function formatMessage(message: string | {
2
- message: string;
3
- } | {
4
- message: string;
5
- }[]): string;
6
- export declare function formatWebpackMessages(json: {
7
- errors: string[];
8
- warnings: string[];
9
- }): {
10
- errors: string[];
11
- warnings: string[];
12
- };