@umijs/bundler-webpack 4.0.0-canary.20220428.2 → 4.0.0-canary.20220429.3

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,79 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- const core_1 = require("@swc/core");
15
- const types_1 = require("../types");
16
- function getBaseOpts({ filename }) {
17
- const isTSFile = filename.endsWith('.ts');
18
- const isTypeScript = isTSFile || filename.endsWith('.tsx');
19
- const isDev = process.env.NODE_ENV === types_1.Env.development;
20
- /**
21
- * Not use swc auto polyfill , depend on `preset-umi/features/polyfill/polyfill` imported polyfill file
22
- *
23
- * @issue https://github.com/swc-project/swc/issues/2607
24
- * https://github.com/swc-project/swc/issues/1604
25
- */
26
- const swcOpts = {
27
- module: {
28
- // @ts-ignore
29
- type: 'es6',
30
- ignoreDynamic: true,
31
- },
32
- jsc: {
33
- parser: {
34
- syntax: isTypeScript ? 'typescript' : 'ecmascript',
35
- [isTypeScript ? 'tsx' : 'jsx']: !isTSFile,
36
- dynamicImport: isTypeScript,
37
- },
38
- target: 'es2015',
39
- transform: {
40
- react: {
41
- runtime: 'automatic',
42
- pragma: 'React.createElement',
43
- pragmaFrag: 'React.Fragment',
44
- throwIfNamespace: true,
45
- development: isDev,
46
- useBuiltins: true,
47
- },
48
- },
49
- },
50
- };
51
- return swcOpts;
52
- }
53
- function swcLoader(contents) {
54
- // 启用异步模式
55
- const callback = this.async();
56
- const loaderOpts = this.getOptions();
57
- const { sync = false, parseMap = false } = loaderOpts, otherOpts = __rest(loaderOpts, ["sync", "parseMap"]);
58
- const filename = this.resourcePath;
59
- const swcOpts = Object.assign(Object.assign(Object.assign({}, getBaseOpts({
60
- filename,
61
- })), { filename, sourceMaps: this.sourceMap, sourceFileName: filename }), otherOpts);
62
- try {
63
- if (sync) {
64
- const output = (0, core_1.transformSync)(contents, swcOpts);
65
- callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
66
- }
67
- else {
68
- (0, core_1.transform)(contents, swcOpts).then((output) => {
69
- callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
70
- }, (err) => {
71
- callback(err);
72
- });
73
- }
74
- }
75
- catch (e) {
76
- callback(e);
77
- }
78
- }
79
- exports.default = swcLoader;
@@ -1,11 +0,0 @@
1
- import { Compilation, Compiler } from '@umijs/bundler-webpack/compiled/webpack';
2
- interface IOpts {
3
- sourcemap?: any;
4
- }
5
- declare class ESBuildCSSMinifyPlugin {
6
- options: IOpts;
7
- constructor(options?: IOpts);
8
- apply(compiler: Compiler): void;
9
- transformAssets(compilation: Compilation): Promise<void>;
10
- }
11
- export default ESBuildCSSMinifyPlugin;
@@ -1,63 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
13
- const webpack_sources_1 = require("@umijs/bundler-webpack/compiled/webpack-sources");
14
- const version = require('../../package.json');
15
- const PLUGIN_NAME = 'ESBuildCSSMinifyPlugin';
16
- const RE_CSS_FILE = /\.css(\?.*)?$/i;
17
- class ESBuildCSSMinifyPlugin {
18
- constructor(options = {}) {
19
- this.options = options;
20
- }
21
- apply(compiler) {
22
- compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
23
- compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash) => {
24
- hash.update(JSON.stringify({
25
- version,
26
- options: this.options,
27
- }));
28
- });
29
- compilation.hooks.processAssets.tapPromise({
30
- name: PLUGIN_NAME,
31
- stage: 400,
32
- additionalAssets: true,
33
- }, () => __awaiter(this, void 0, void 0, function* () {
34
- yield this.transformAssets(compilation);
35
- }));
36
- });
37
- }
38
- transformAssets(compilation) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const { options: { devtool }, } = compilation.compiler;
41
- const sourcemap = this.options.sourcemap === undefined ? !!devtool : this.options.sourcemap;
42
- const assets = compilation.getAssets().filter((asset) => {
43
- return !asset.info.minimized && RE_CSS_FILE.test(asset.name);
44
- });
45
- yield Promise.all(assets.map((asset) => __awaiter(this, void 0, void 0, function* () {
46
- const { source, map } = asset.source.sourceAndMap();
47
- const sourceAsString = source.toString();
48
- const result = yield (0, esbuild_1.transform)(sourceAsString, {
49
- loader: 'css',
50
- sourcemap,
51
- sourcefile: asset.name,
52
- minify: true,
53
- });
54
- compilation.updateAsset(asset.name,
55
- // @ts-ignore
56
- sourcemap
57
- ? new webpack_sources_1.SourceMapSource(result.code, asset.name, result.map, sourceAsString, map, true)
58
- : new webpack_sources_1.RawSource(result.code), Object.assign(Object.assign({}, asset.info), { minimized: true }));
59
- })));
60
- });
61
- }
62
- }
63
- exports.default = ESBuildCSSMinifyPlugin;
@@ -1,10 +0,0 @@
1
- import type { TransformOptions } from '@parcel/css';
2
- import type { Compiler } from '../../compiled/webpack/types';
3
- declare type MinifyPluginOpts = Omit<TransformOptions, 'filename' | 'code' | 'minify'>;
4
- export declare class ParcelCSSMinifyPlugin {
5
- private readonly options;
6
- constructor(opts?: MinifyPluginOpts);
7
- apply(compiler: Compiler): void;
8
- private transformAssets;
9
- }
10
- export {};
@@ -1,75 +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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ParcelCSSMinifyPlugin = void 0;
13
- const utils_1 = require("@umijs/utils");
14
- const buffer_1 = require("buffer");
15
- const path_1 = require("path");
16
- const webpack_sources_1 = require("../../compiled/webpack-sources");
17
- const pkgPath = (0, path_1.join)(__dirname, '../../package.json');
18
- const pkg = require(pkgPath);
19
- const PLUGIN_NAME = 'parcel-css-minify-plugin';
20
- const CSS_FILE_REG = /\.css(?:\?.*)?$/i;
21
- class ParcelCSSMinifyPlugin {
22
- constructor(opts = {}) {
23
- this.options = opts;
24
- }
25
- apply(compiler) {
26
- const meta = JSON.stringify({
27
- name: pkg.name,
28
- version: pkg.version,
29
- options: this.options,
30
- });
31
- compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
32
- compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash) => hash.update(meta));
33
- compilation.hooks.processAssets.tapPromise({
34
- name: PLUGIN_NAME,
35
- // @ts-ignore
36
- stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
37
- additionalAssets: true,
38
- }, () => __awaiter(this, void 0, void 0, function* () { return yield this.transformAssets(compilation); }));
39
- compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter) => {
40
- statsPrinter.hooks.print
41
- .for('asset.info.minimized')
42
- // @ts-ignore
43
- .tap(PLUGIN_NAME, (minimized, { green, formatFlag }) => {
44
- // @ts-ignore
45
- return minimized ? green(formatFlag('minimized')) : undefined;
46
- });
47
- });
48
- });
49
- }
50
- transformAssets(compilation) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const { options: { devtool }, } = compilation.compiler;
53
- const sourcemap = this.options.sourceMap === undefined
54
- ? (devtool && devtool.includes('source-map'))
55
- : this.options.sourceMap;
56
- const assets = compilation.getAssets().filter((asset) => {
57
- return !asset.info.minimized && CSS_FILE_REG.test(asset.name);
58
- });
59
- yield Promise.all(assets.map((asset) => __awaiter(this, void 0, void 0, function* () {
60
- const { source, map } = asset.source.sourceAndMap();
61
- const sourceAsString = source.toString();
62
- const code = typeof source === 'string' ? buffer_1.Buffer.from(source) : source;
63
- const { transform } = (0, utils_1.importLazy)('@parcel/css');
64
- const result = yield transform(Object.assign({ filename: asset.name, code, minify: true, sourceMap: sourcemap }, this.options));
65
- const codeString = result.code.toString();
66
- compilation.updateAsset(asset.name,
67
- // @ts-ignore
68
- sourcemap
69
- ? new webpack_sources_1.SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, true)
70
- : new webpack_sources_1.RawSource(codeString), Object.assign(Object.assign({}, asset.info), { minimized: true }));
71
- })));
72
- });
73
- }
74
- }
75
- exports.ParcelCSSMinifyPlugin = ParcelCSSMinifyPlugin;
@@ -1,15 +0,0 @@
1
- import { Compiler, ProgressPlugin } from '@umijs/bundler-webpack/compiled/webpack';
2
- interface IOpts {
3
- name?: string;
4
- }
5
- declare class UmiProgressPlugin extends ProgressPlugin {
6
- options: IOpts;
7
- constructor(options?: IOpts);
8
- apply(compiler: Compiler): void;
9
- updateProgress(opts: {
10
- percent: number;
11
- message: string;
12
- details: any[];
13
- }): void;
14
- }
15
- export default UmiProgressPlugin;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
4
- const utils_1 = require("@umijs/utils");
5
- const PLUGIN_NAME = 'ProgressPlugin';
6
- class UmiProgressPlugin extends webpack_1.ProgressPlugin {
7
- constructor(options = {}) {
8
- super({ activeModules: true });
9
- this.options = options;
10
- this.handler = (percent, message, ...details) => {
11
- this.updateProgress({ percent, message, details });
12
- };
13
- }
14
- apply(compiler) {
15
- compiler.hooks.invalid.tap(PLUGIN_NAME, () => {
16
- utils_1.logger.wait('Compiling...');
17
- });
18
- compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
19
- const { errors, warnings } = stats.toJson({
20
- all: false,
21
- warnings: true,
22
- errors: true,
23
- colors: true,
24
- });
25
- const hasErrors = !!(errors === null || errors === void 0 ? void 0 : errors.length);
26
- const hasWarnings = !!(warnings === null || warnings === void 0 ? void 0 : warnings.length);
27
- hasWarnings;
28
- if (hasErrors) {
29
- errors.forEach((error) => {
30
- utils_1.logger.error(`${error.moduleName}${error.loc ? `:${error.loc}` : ''}`);
31
- console.log(error.message);
32
- });
33
- }
34
- else {
35
- const prefix = this.options.name ? `${this.options.name} ` : '';
36
- utils_1.logger.event(`${prefix}Compiled successfully in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
37
- }
38
- });
39
- }
40
- updateProgress(opts) {
41
- opts;
42
- }
43
- }
44
- exports.default = UmiProgressPlugin;
@@ -1,4 +0,0 @@
1
- import type { Compiler } from '@umijs/bundler-webpack/compiled/webpack';
2
- export declare class RuntimePublicPathPlugin {
3
- apply(compiler: Compiler): void;
4
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RuntimePublicPathPlugin = void 0;
4
- const PLUGIN_NAME = 'RuntimePublicPath';
5
- // ref: https://gist.github.com/ScriptedAlchemy/60d0c49ce049184f6ce3e86ca351fdca
6
- class RuntimePublicPathPlugin {
7
- apply(compiler) {
8
- compiler.hooks.make.tap(PLUGIN_NAME, (compilation) => {
9
- compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (module) => {
10
- // The hook to get the public path ('__webpack_require__.p')
11
- // https://github.com/webpack/webpack/blob/master/lib/runtime/PublicPathRuntimeModule.js
12
- if (module.constructor.name === 'PublicPathRuntimeModule') {
13
- // @ts-ignore
14
- module._cachedGeneratedCode = `__webpack_require__.p = (globalThis || window).publicPath;`;
15
- }
16
- });
17
- });
18
- }
19
- }
20
- exports.RuntimePublicPathPlugin = RuntimePublicPathPlugin;
@@ -1,9 +0,0 @@
1
- import { Compiler } from '@umijs/bundler-webpack/compiled/webpack';
2
- interface IOpts {
3
- }
4
- declare class _SamplePlugin {
5
- options: IOpts;
6
- constructor(options?: IOpts);
7
- apply(compiler: Compiler): void;
8
- }
9
- export default _SamplePlugin;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const PLUGIN_NAME = 'SamplePlugin';
4
- class _SamplePlugin {
5
- constructor(options = {}) {
6
- this.options = options;
7
- }
8
- apply(compiler) {
9
- compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
10
- compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_) => { });
11
- });
12
- }
13
- }
14
- exports.default = _SamplePlugin;
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
1
- "use strict";
2
- // MIT: copy from https://github.com/vercel/next.js/blob/canary/packages/next/build/webpack/require-hook.ts
3
- // sync injects a hook for webpack and webpack/... requires to use the internal ncc webpack version
4
- // this is in order for userland plugins to attach to the same webpack instance as umi
5
- // the individual compiled modules are as defined for the compilation in bundles/webpack/packages/*
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- // @ts-ignore
11
- const deepImports_json_1 = __importDefault(require("@umijs/bundler-webpack/compiled/webpack/deepImports.json"));
12
- const hookPropertyMap = new Map([
13
- ['webpack', '@umijs/bundler-webpack/compiled/webpack'],
14
- ['webpack/package', '@umijs/bundler-webpack/compiled/webpack/package'],
15
- ['webpack/package.json', '@umijs/bundler-webpack/compiled/webpack/package'],
16
- ['webpack/lib/webpack', '@umijs/bundler-webpack/compiled/webpack'],
17
- ['webpack/lib/webpack.js', '@umijs/bundler-webpack/compiled/webpack'],
18
- ]);
19
- deepImports_json_1.default.forEach((item) => {
20
- const name = item.split('/').pop();
21
- hookPropertyMap.set(item, `@umijs/bundler-webpack/compiled/webpack/${name}`);
22
- hookPropertyMap.set(`${item}.js`, `@umijs/bundler-webpack/compiled/webpack/${name}`);
23
- });
24
- const mod = require('module');
25
- const resolveFilename = mod._resolveFilename;
26
- mod._resolveFilename = function (request, parent, isMain, options) {
27
- const hookResolved = hookPropertyMap.get(request);
28
- if (hookResolved)
29
- request = hookResolved;
30
- return resolveFilename.call(mod, request, parent, isMain, options);
31
- };
package/dist/schema.d.ts DELETED
@@ -1,3 +0,0 @@
1
- /// <reference types="hapi__joi" />
2
- import type { Root } from '@hapi/joi';
3
- export declare function getSchemas(): Record<string, (Joi: Root) => any>;
package/dist/schema.js DELETED
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSchemas = void 0;
4
- const types_1 = require("./types");
5
- const options = [
6
- 'cheap-source-map',
7
- 'cheap-eval-source-map',
8
- 'cheap-hidden-source-map',
9
- 'cheap-inline-source-map',
10
- 'cheap-module-source-map',
11
- 'cheap-module-eval-source-map',
12
- 'cheap-module-hidden-source-map',
13
- 'cheap-module-inline-source-map',
14
- 'eval',
15
- 'eval-source-map',
16
- 'source-map',
17
- 'hidden-source-map',
18
- 'inline-source-map',
19
- ];
20
- const DEVTOOL_REGEX = new RegExp('^' + // start of string
21
- '(#@|@|#)?' + // maybe one of the pragmas
22
- `(${options.join('$|')})`);
23
- function getSchemas() {
24
- return {
25
- alias: (Joi) => Joi.object(),
26
- autoCSSModules: (Joi) => Joi.boolean(),
27
- autoprefixer: (Joi) => Joi.object(),
28
- chainWebpack: (Joi) => Joi.function(),
29
- copy: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.object({
30
- from: Joi.string(),
31
- to: Joi.string(),
32
- }), Joi.string())),
33
- cssLoader: (Joi) => Joi.object(),
34
- cssLoaderModules: (Joi) => Joi.object(),
35
- cssMinifier: (Joi) => Joi.string().valid(types_1.CSSMinifier.cssnano, types_1.CSSMinifier.esbuild, types_1.CSSMinifier.parcelCSS, types_1.CSSMinifier.none),
36
- cssMinifierOptions: (Joi) => Joi.object(),
37
- deadCode: (Joi) => Joi.object(),
38
- define: (Joi) => Joi.object(),
39
- depTranspiler: (Joi) => Joi.string().valid(types_1.Transpiler.babel, types_1.Transpiler.esbuild, types_1.Transpiler.swc, types_1.Transpiler.none),
40
- devtool: (Joi) => Joi.alternatives().try(Joi.string().regex(DEVTOOL_REGEX), Joi.boolean()),
41
- esm: (Joi) => Joi.object(),
42
- externals: (Joi) => Joi.alternatives().try(Joi.object(), Joi.string(), Joi.func()),
43
- extraBabelIncludes: (Joi) => Joi.array().items(Joi.string()),
44
- extraBabelPlugins: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
45
- extraBabelPresets: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.array())),
46
- extraPostCSSPlugins: (Joi) => Joi.array(),
47
- fastRefresh: (Joi) => Joi.boolean(),
48
- forkTSChecker: (Joi) => Joi.object(),
49
- hash: (Joi) => Joi.boolean(),
50
- https: (Joi) => Joi.object(),
51
- ignoreMomentLocale: (Joi) => Joi.boolean(),
52
- inlineLimit: (Joi) => Joi.number(),
53
- jsMinifier: (Joi) => Joi.string().valid(types_1.JSMinifier.esbuild, types_1.JSMinifier.swc, types_1.JSMinifier.terser, types_1.JSMinifier.uglifyJs, types_1.JSMinifier.none),
54
- jsMinifierOptions: (Joi) => Joi.object(),
55
- lessLoader: (Joi) => Joi.object(),
56
- manifest: (Joi) => Joi.object(),
57
- mdx: (Joi) => Joi.object({
58
- loader: Joi.string(),
59
- loaderOptions: Joi.object(),
60
- }),
61
- mfsu: (Joi) => Joi.alternatives(Joi.object({
62
- cacheDirectory: Joi.string(),
63
- chainWebpack: Joi.function(),
64
- esbuild: Joi.boolean(),
65
- mfName: Joi.string(),
66
- runtimePublicPath: Joi.boolean(),
67
- }), Joi.boolean()),
68
- outputPath: (Joi) => Joi.string(),
69
- postcssLoader: (Joi) => Joi.object(),
70
- proxy: (Joi) => Joi.object(),
71
- publicPath: (Joi) => Joi.string(),
72
- purgeCSS: (Joi) => Joi.object(),
73
- runtimePublicPath: (Joi) => Joi.object(),
74
- sassLoader: (Joi) => Joi.object(),
75
- srcTranspiler: (Joi) => Joi.string().valid(types_1.Transpiler.babel, types_1.Transpiler.esbuild, types_1.Transpiler.swc, types_1.Transpiler.none),
76
- styleLoader: (Joi) => Joi.object(),
77
- svgo: (Joi) => Joi.alternatives().try(Joi.object(), Joi.boolean()),
78
- svgr: (Joi) => Joi.object(),
79
- targets: (Joi) => Joi.object(),
80
- theme: (Joi) => Joi.object(),
81
- writeToDisk: (Joi) => Joi.boolean(),
82
- };
83
- }
84
- exports.getSchemas = getSchemas;
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { RequestListener } from 'http';
3
- import { HttpsParams } from '../types';
4
- export declare function createHttpsServer(app: RequestListener, httpsConfig: HttpsParams): Promise<import("https").Server>;
@@ -1,74 +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.createHttpsServer = void 0;
16
- const utils_1 = require("@umijs/utils");
17
- const fs_1 = require("fs");
18
- const path_1 = require("path");
19
- const spdy_1 = __importDefault(require("spdy"));
20
- const defaultHttpsHosts = ['localhost', '127.0.0.1'];
21
- function createHttpsServer(app, httpsConfig) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- utils_1.logger.wait('[HTTPS] Starting service in https mode...');
24
- // Check if mkcert is installed
25
- try {
26
- yield utils_1.execa.execa('mkcert', ['--version']);
27
- }
28
- catch (e) {
29
- utils_1.logger.error('[HTTPS] The mkcert has not been installed.');
30
- utils_1.logger.info('[HTTPS] Please follow the guide to install manually.');
31
- switch (process.platform) {
32
- case 'darwin':
33
- console.log(utils_1.chalk.green('$ brew install mkcert'));
34
- console.log(utils_1.chalk.gray('# If you use firefox, please install nss.'));
35
- console.log(utils_1.chalk.green('$ brew install nss'));
36
- console.log(utils_1.chalk.green('$ mkcert -install'));
37
- break;
38
- case 'win32':
39
- console.log(utils_1.chalk.green('Checkout https://github.com/FiloSottile/mkcert#windows'));
40
- break;
41
- case 'linux':
42
- console.log(utils_1.chalk.green('Checkout https://github.com/FiloSottile/mkcert#linux'));
43
- break;
44
- default:
45
- break;
46
- }
47
- throw new Error(`[HTTPS] mkcert not found.`);
48
- }
49
- let { key, cert, hosts } = httpsConfig;
50
- hosts = hosts || defaultHttpsHosts;
51
- if (!key || !cert) {
52
- key = (0, path_1.join)(__dirname, 'umi.key.pem');
53
- cert = (0, path_1.join)(__dirname, 'umi.pem');
54
- }
55
- // Generate cert and key files if they are not exist.
56
- if (!(0, fs_1.existsSync)(key) || !(0, fs_1.existsSync)(cert)) {
57
- utils_1.logger.wait('[HTTPS] Generating cert and key files...');
58
- yield utils_1.execa.execa('mkcert', [
59
- '-cert-file',
60
- cert,
61
- '-key-file',
62
- key,
63
- ...hosts,
64
- ]);
65
- }
66
- // Create server
67
- const http2Service = spdy_1.default.createServer({
68
- key: (0, fs_1.readFileSync)(key, 'utf-8'),
69
- cert: (0, fs_1.readFileSync)(cert, 'utf-8'),
70
- }, app);
71
- return http2Service;
72
- });
73
- }
74
- exports.createHttpsServer = createHttpsServer;
@@ -1,17 +0,0 @@
1
- /// <reference types="node" />
2
- import { Configuration } from '@umijs/bundler-webpack/compiled/webpack';
3
- import http from 'http';
4
- import { IConfig } from '../types';
5
- interface IOpts {
6
- cwd: string;
7
- port?: number;
8
- host?: string;
9
- webpackConfig: Configuration;
10
- userConfig: IConfig;
11
- beforeMiddlewares?: any[];
12
- afterMiddlewares?: any[];
13
- onDevCompileDone?: Function;
14
- onProgress?: Function;
15
- }
16
- export declare function createServer(opts: IOpts): Promise<import("https").Server | http.Server | null>;
17
- export {};