@umijs/preset-umi 4.0.0-beta.10

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 (113) hide show
  1. package/README.md +3 -0
  2. package/assets/umi.png +0 -0
  3. package/compiled/body-parser/LICENSE +23 -0
  4. package/compiled/body-parser/connect/index.d.ts +93 -0
  5. package/compiled/body-parser/index.d.ts +107 -0
  6. package/compiled/body-parser/index.js +129 -0
  7. package/compiled/body-parser/package.json +1 -0
  8. package/compiled/multer/LICENSE +17 -0
  9. package/compiled/multer/body-parser/index.d.ts +104 -0
  10. package/compiled/multer/connect/index.d.ts +93 -0
  11. package/compiled/multer/express/index.d.ts +133 -0
  12. package/compiled/multer/express-serve-static-core/index.d.ts +1252 -0
  13. package/compiled/multer/index.d.ts +321 -0
  14. package/compiled/multer/index.js +41 -0
  15. package/compiled/multer/mime/index.d.ts +35 -0
  16. package/compiled/multer/package.json +1 -0
  17. package/compiled/multer/qs/index.d.ts +62 -0
  18. package/compiled/multer/range-parser/index.d.ts +35 -0
  19. package/compiled/multer/serve-static/index.d.ts +108 -0
  20. package/dist/commands/build.d.ts +3 -0
  21. package/dist/commands/build.js +120 -0
  22. package/dist/commands/config/config.d.ts +3 -0
  23. package/dist/commands/config/config.js +61 -0
  24. package/dist/commands/config/list.d.ts +2 -0
  25. package/dist/commands/config/list.js +34 -0
  26. package/dist/commands/config/remove.d.ts +1 -0
  27. package/dist/commands/config/remove.js +21 -0
  28. package/dist/commands/config/set.d.ts +1 -0
  29. package/dist/commands/config/set.js +21 -0
  30. package/dist/commands/dev/createRouteMiddleware.d.ts +5 -0
  31. package/dist/commands/dev/createRouteMiddleware.js +35 -0
  32. package/dist/commands/dev/dev.d.ts +3 -0
  33. package/dist/commands/dev/dev.js +269 -0
  34. package/dist/commands/dev/faviconMiddleware.d.ts +2 -0
  35. package/dist/commands/dev/faviconMiddleware.js +13 -0
  36. package/dist/commands/dev/getBabelOpts.d.ts +20 -0
  37. package/dist/commands/dev/getBabelOpts.js +57 -0
  38. package/dist/commands/dev/getMarkupArgs.d.ts +13 -0
  39. package/dist/commands/dev/getMarkupArgs.js +73 -0
  40. package/dist/commands/dev/watch.d.ts +19 -0
  41. package/dist/commands/dev/watch.js +55 -0
  42. package/dist/commands/generate/page.d.ts +3 -0
  43. package/dist/commands/generate/page.js +44 -0
  44. package/dist/commands/generate/prettier.d.ts +3 -0
  45. package/dist/commands/generate/prettier.js +31 -0
  46. package/dist/commands/help.d.ts +3 -0
  47. package/dist/commands/help.js +61 -0
  48. package/dist/commands/plugin.d.ts +3 -0
  49. package/dist/commands/plugin.js +38 -0
  50. package/dist/commands/setup.d.ts +3 -0
  51. package/dist/commands/setup.js +20 -0
  52. package/dist/commands/version.d.ts +3 -0
  53. package/dist/commands/version.js +16 -0
  54. package/dist/constants.d.ts +4 -0
  55. package/dist/constants.js +8 -0
  56. package/dist/features/__sample.d.ts +3 -0
  57. package/dist/features/__sample.js +5 -0
  58. package/dist/features/appData/appData.d.ts +3 -0
  59. package/dist/features/appData/appData.js +30 -0
  60. package/dist/features/check/check.d.ts +3 -0
  61. package/dist/features/check/check.js +34 -0
  62. package/dist/features/configPlugins/configPlugins.d.ts +3 -0
  63. package/dist/features/configPlugins/configPlugins.js +61 -0
  64. package/dist/features/configPlugins/schema.d.ts +2 -0
  65. package/dist/features/configPlugins/schema.js +16 -0
  66. package/dist/features/esmi/esmi.d.ts +3 -0
  67. package/dist/features/esmi/esmi.js +44 -0
  68. package/dist/features/favicon/favicon.d.ts +3 -0
  69. package/dist/features/favicon/favicon.js +58 -0
  70. package/dist/features/lowImport/babelPlugin.d.ts +17 -0
  71. package/dist/features/lowImport/babelPlugin.js +68 -0
  72. package/dist/features/lowImport/lowImport.d.ts +9 -0
  73. package/dist/features/lowImport/lowImport.js +108 -0
  74. package/dist/features/mock/constants.d.ts +3 -0
  75. package/dist/features/mock/constants.js +14 -0
  76. package/dist/features/mock/createMockMiddleware.d.ts +7 -0
  77. package/dist/features/mock/createMockMiddleware.js +82 -0
  78. package/dist/features/mock/getMockData.d.ts +9 -0
  79. package/dist/features/mock/getMockData.js +61 -0
  80. package/dist/features/mock/mock.d.ts +2 -0
  81. package/dist/features/mock/mock.js +50 -0
  82. package/dist/features/polyfill/polyfill.d.ts +3 -0
  83. package/dist/features/polyfill/polyfill.js +14 -0
  84. package/dist/features/tmpFiles/importsToStr.d.ts +4 -0
  85. package/dist/features/tmpFiles/importsToStr.js +16 -0
  86. package/dist/features/tmpFiles/routes.d.ts +8 -0
  87. package/dist/features/tmpFiles/routes.js +74 -0
  88. package/dist/features/tmpFiles/tmpFiles.d.ts +3 -0
  89. package/dist/features/tmpFiles/tmpFiles.js +124 -0
  90. package/dist/features/transform/babelPlugin.d.ts +11 -0
  91. package/dist/features/transform/babelPlugin.js +118 -0
  92. package/dist/features/transform/transform.d.ts +3 -0
  93. package/dist/features/transform/transform.js +29 -0
  94. package/dist/index.d.ts +5 -0
  95. package/dist/index.js +30 -0
  96. package/dist/libs/moduleGraph.d.ts +2 -0
  97. package/dist/libs/moduleGraph.js +6 -0
  98. package/dist/libs/scan.d.ts +28 -0
  99. package/dist/libs/scan.js +110 -0
  100. package/dist/registerMethods.d.ts +3 -0
  101. package/dist/registerMethods.js +89 -0
  102. package/dist/types.d.ts +147 -0
  103. package/dist/types.js +2 -0
  104. package/dist/utils/clearTmp.d.ts +1 -0
  105. package/dist/utils/clearTmp.js +17 -0
  106. package/dist/utils/isTypeScriptFile.d.ts +1 -0
  107. package/dist/utils/isTypeScriptFile.js +7 -0
  108. package/package.json +62 -0
  109. package/templates/generate/page/index.less.tpl +4 -0
  110. package/templates/generate/page/index.tsx.tpl +10 -0
  111. package/templates/plugin.tpl +18 -0
  112. package/templates/route.tpl +7 -0
  113. package/templates/umi.tpl +22 -0
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = () => {
4
+ return {
5
+ plugins: [
6
+ // registerMethods
7
+ require.resolve('./registerMethods'),
8
+ // features
9
+ require.resolve('./features/appData/appData'),
10
+ require.resolve('./features/check/check'),
11
+ require.resolve('./features/configPlugins/configPlugins'),
12
+ require.resolve('./features/esmi/esmi'),
13
+ require.resolve('./features/favicon/favicon'),
14
+ require.resolve('./features/mock/mock'),
15
+ require.resolve('./features/polyfill/polyfill'),
16
+ require.resolve('./features/tmpFiles/tmpFiles'),
17
+ require.resolve('./features/transform/transform'),
18
+ // commands
19
+ require.resolve('./commands/build'),
20
+ require.resolve('./commands/config/config'),
21
+ require.resolve('./commands/dev/dev'),
22
+ require.resolve('./commands/help'),
23
+ require.resolve('./commands/setup'),
24
+ require.resolve('./commands/version'),
25
+ require.resolve('./commands/generate/page'),
26
+ require.resolve('./commands/generate/prettier'),
27
+ require.resolve('./commands/plugin'),
28
+ ],
29
+ };
30
+ };
@@ -0,0 +1,2 @@
1
+ export declare class ModuleGraph {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModuleGraph = void 0;
4
+ class ModuleGraph {
5
+ }
6
+ exports.ModuleGraph = ModuleGraph;
@@ -0,0 +1,28 @@
1
+ declare enum ImportType {
2
+ import = "import",
3
+ dynamicImport = "dynamicImport",
4
+ export = "export"
5
+ }
6
+ interface Dep {
7
+ url: string;
8
+ importType: ImportType;
9
+ specifiers?: 'namespace' | string[];
10
+ }
11
+ export declare function scanContent(opts: {
12
+ content: string;
13
+ needDepSpecifier?: boolean;
14
+ }): Promise<{
15
+ deps: Dep[];
16
+ }>;
17
+ export declare function getContent(path: string): Promise<string>;
18
+ export declare function createResolver(opts: {
19
+ alias: any;
20
+ }): {
21
+ resolve: (context: string, path: string) => Promise<string>;
22
+ };
23
+ export declare function scan(opts: {
24
+ entry: string;
25
+ externals: any;
26
+ resolver: any;
27
+ }): Promise<Record<string, string>>;
28
+ export {};
@@ -0,0 +1,110 @@
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.scan = exports.createResolver = exports.getContent = exports.scanContent = void 0;
16
+ const es_module_lexer_1 = require("@umijs/bundler-utils/compiled/es-module-lexer");
17
+ const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
18
+ const utils_1 = require("@umijs/utils");
19
+ const assert_1 = __importDefault(require("assert"));
20
+ const enhanced_resolve_1 = __importDefault(require("enhanced-resolve"));
21
+ const fs_1 = require("fs");
22
+ const path_1 = require("path");
23
+ var ImportType;
24
+ (function (ImportType) {
25
+ ImportType["import"] = "import";
26
+ ImportType["dynamicImport"] = "dynamicImport";
27
+ ImportType["export"] = "export";
28
+ })(ImportType || (ImportType = {}));
29
+ // 项目文件都是 esm,无需考虑 cjs
30
+ function scanContent(opts) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ yield es_module_lexer_1.init;
33
+ const [imports] = (0, es_module_lexer_1.parse)(opts.content);
34
+ const deps = imports.map((imp) => {
35
+ let importType = ImportType.import;
36
+ if (imp.d > -1)
37
+ importType = ImportType.dynamicImport;
38
+ if (opts.content.slice(imp.ss, imp.se).startsWith('export ')) {
39
+ importType = ImportType.export;
40
+ }
41
+ return {
42
+ url: imp.n,
43
+ importType,
44
+ };
45
+ });
46
+ return { deps };
47
+ });
48
+ }
49
+ exports.scanContent = scanContent;
50
+ function getContent(path) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ let content = (0, fs_1.readFileSync)(path, 'utf-8');
53
+ // es-module-lexer don't support jsx
54
+ if (path.endsWith('.tsx') || path.endsWith('.jsx')) {
55
+ content = (0, esbuild_1.transformSync)(content, {
56
+ loader: (0, path_1.extname)(path).slice(1),
57
+ format: 'esm',
58
+ }).code;
59
+ }
60
+ return content;
61
+ });
62
+ }
63
+ exports.getContent = getContent;
64
+ function createResolver(opts) {
65
+ const resolver = enhanced_resolve_1.default.create({
66
+ mainFields: ['module', 'browser', 'main'],
67
+ extensions: ['.js', '.json', '.mjs', '.ts', '.tsx'],
68
+ exportsFields: [],
69
+ alias: opts.alias,
70
+ });
71
+ function resolve(context, path) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ return new Promise((resolve, reject) => {
74
+ resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
75
+ });
76
+ });
77
+ }
78
+ return { resolve };
79
+ }
80
+ exports.createResolver = createResolver;
81
+ function scan(opts) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const cache = new Map();
84
+ const queueDeps = [opts.entry];
85
+ const ret = {};
86
+ while (queueDeps.length) {
87
+ const depPath = queueDeps.shift();
88
+ if (cache.has(depPath))
89
+ continue;
90
+ const content = yield getContent(depPath);
91
+ const { deps } = yield scanContent({ content });
92
+ cache.set(depPath, deps);
93
+ for (const dep of deps) {
94
+ const resolved = yield opts.resolver.resolve((0, path_1.dirname)(depPath), dep.url);
95
+ if (resolved.includes('node_modules') ||
96
+ resolved.includes('umi-next/packages')) {
97
+ const pkgPath = utils_1.pkgUp.sync({ cwd: resolved });
98
+ (0, assert_1.default)(pkgPath, `package.json for found for ${resolved}`);
99
+ const pkg = require(pkgPath);
100
+ ret[pkg.name] = pkg.version;
101
+ }
102
+ else if (['.ts', '.tsx', '.js', '.jsx', '.mjs'].includes((0, path_1.extname)(resolved))) {
103
+ queueDeps.push(resolved);
104
+ }
105
+ }
106
+ }
107
+ return ret;
108
+ });
109
+ }
110
+ exports.scan = scan;
@@ -0,0 +1,3 @@
1
+ import { IApi } from './types';
2
+ declare const _default: (api: IApi) => void;
3
+ export default _default;
@@ -0,0 +1,89 @@
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 utils_1 = require("@umijs/utils");
7
+ const assert_1 = __importDefault(require("assert"));
8
+ const fs_1 = require("fs");
9
+ const path_1 = require("path");
10
+ const isTypeScriptFile_1 = require("./utils/isTypeScriptFile");
11
+ exports.default = (api) => {
12
+ [
13
+ 'onGenerateFiles',
14
+ 'onBeforeCompiler',
15
+ 'onBuildComplete',
16
+ // 'onPatchRoute',
17
+ // 'onPatchRouteBefore',
18
+ // 'onPatchRoutes',
19
+ // 'onPatchRoutesBefore',
20
+ 'onPkgJSONChanged',
21
+ 'onDevCompileDone',
22
+ 'onCheckPkgJSON',
23
+ 'onCheckCode',
24
+ 'onCheckConfig',
25
+ 'addBeforeMiddlewares',
26
+ 'addLayouts',
27
+ 'addMiddlewares',
28
+ 'addRuntimePlugin',
29
+ 'addRuntimePluginKey',
30
+ // 'addUmiExports',
31
+ 'addPolyfillImports',
32
+ 'addEntryImportsAhead',
33
+ 'addEntryImports',
34
+ 'addEntryCodeAhead',
35
+ 'addEntryCode',
36
+ 'addExtraBabelPresets',
37
+ 'addExtraBabelPlugins',
38
+ 'addBeforeBabelPresets',
39
+ 'addBeforeBabelPlugins',
40
+ 'addHTMLMetas',
41
+ 'addHTMLLinks',
42
+ 'addHTMLStyles',
43
+ 'addHTMLHeadScripts',
44
+ 'addHTMLScripts',
45
+ 'addTmpGenerateWatcherPaths',
46
+ 'chainWebpack',
47
+ 'modifyHTMLFavicon',
48
+ 'modifyHTML',
49
+ 'modifyWebpackConfig',
50
+ 'modifyViteConfig',
51
+ // 'modifyHTMLChunks',
52
+ // 'modifyExportRouteMap',
53
+ // 'modifyPublicPathStr',
54
+ 'modifyRendererPath',
55
+ // 'modifyRoutes',
56
+ ].forEach((name) => {
57
+ api.registerMethod({ name });
58
+ });
59
+ api.registerMethod({
60
+ name: 'writeTmpFile',
61
+ fn(opts) {
62
+ (0, assert_1.default)(api.service.stage >= api.ServiceStage.runCommand, `api.writeTmpFile() should not execute in register stage.`);
63
+ const absPath = (0, path_1.join)(api.paths.absTmpPath, opts.path);
64
+ utils_1.fsExtra.mkdirpSync((0, path_1.dirname)(absPath));
65
+ let content = opts.content;
66
+ if (!content) {
67
+ (0, assert_1.default)(!opts.tplPath ||
68
+ ((0, fs_1.existsSync)(opts.tplPath) && (0, fs_1.statSync)(opts.tplPath).isFile()), `opts.tplPath does not exists or is not a file.`);
69
+ const tpl = opts.tplPath
70
+ ? (0, fs_1.readFileSync)(opts.tplPath, 'utf-8')
71
+ : opts.tpl;
72
+ (0, assert_1.default)(tpl, `opts.tpl or opts.tplPath must be supplied.`);
73
+ (0, assert_1.default)(utils_1.lodash.isPlainObject(opts.context), `opts.context must be plain object.`);
74
+ content = utils_1.Mustache.render(tpl, opts.context);
75
+ }
76
+ content = [
77
+ (0, isTypeScriptFile_1.isTypeScriptFile)(opts.path) && `// @ts-nocheck`,
78
+ '// This file is generated by Umi automatically',
79
+ '// DO NOT CHANGE IT MANUALLY!',
80
+ content,
81
+ ]
82
+ .filter((text) => text !== false)
83
+ .join('\n');
84
+ if (!(0, fs_1.existsSync)(absPath) || (0, fs_1.readFileSync)(absPath, 'utf-8') !== content) {
85
+ (0, fs_1.writeFileSync)(absPath, content, 'utf-8');
86
+ }
87
+ },
88
+ });
89
+ };
@@ -0,0 +1,147 @@
1
+ import type { RequestHandler } from '@umijs/bundler-webpack';
2
+ import type webpack from '@umijs/bundler-webpack/compiled/webpack';
3
+ import type WebpackChain from '@umijs/bundler-webpack/compiled/webpack-5-chain';
4
+ import type { IAdd, IEvent, IModify, IRoute as ICoreRoute, IServicePluginAPI, PluginAPI } from '@umijs/core';
5
+ import { Env } from '@umijs/core';
6
+ import type { CheerioAPI } from '@umijs/utils/compiled/cheerio';
7
+ export declare type IScript = Partial<{
8
+ async: boolean;
9
+ charset: string;
10
+ crossOrigin: string | null;
11
+ defer: boolean;
12
+ src: string;
13
+ type: string;
14
+ content: string;
15
+ }> | string;
16
+ export declare type IStyle = Partial<{
17
+ type: string;
18
+ content: string;
19
+ }> | string;
20
+ export declare type ILink = Partial<{
21
+ as: string;
22
+ crossOrigin: string | null;
23
+ disabled: boolean;
24
+ href: string;
25
+ hreflang: string;
26
+ imageSizes: string;
27
+ imageSrcset: string;
28
+ integrity: string;
29
+ media: string;
30
+ referrerPolicy: string;
31
+ rel: string;
32
+ rev: string;
33
+ target: string;
34
+ type: string;
35
+ }>;
36
+ export declare type IMeta = Partial<{
37
+ content: string;
38
+ httpEquiv: string;
39
+ name: string;
40
+ scheme: string;
41
+ }>;
42
+ export declare type IEntryImport = {
43
+ source: string;
44
+ specifier?: string;
45
+ };
46
+ export declare type IRoute = ICoreRoute;
47
+ export declare type IApi = PluginAPI & IServicePluginAPI & {
48
+ restartServer: () => void;
49
+ writeTmpFile: (opts: {
50
+ path: string;
51
+ content?: string;
52
+ tpl?: string;
53
+ tplPath?: string;
54
+ context?: Record<string, any>;
55
+ }) => void;
56
+ addTmpGenerateWatcherPaths: IAdd<null, string[]>;
57
+ onGenerateFiles: IEvent<{
58
+ isFirstTime?: boolean;
59
+ files?: {
60
+ event: string;
61
+ path: string;
62
+ } | null;
63
+ }>;
64
+ onPkgJSONChanged: IEvent<{
65
+ origin: Record<string, any>;
66
+ current: Record<string, any>;
67
+ }>;
68
+ onBeforeCompiler: IEvent<{}>;
69
+ onBuildComplete: IEvent<{
70
+ isFirstCompile: boolean;
71
+ stats: any;
72
+ time: number;
73
+ err?: Error;
74
+ }>;
75
+ onCheckPkgJSON: IEvent<{
76
+ origin?: Record<string, any>;
77
+ current: Record<string, any>;
78
+ }>;
79
+ onCheckConfig: IEvent<{
80
+ config: Record<string, any>;
81
+ userConfig: Record<string, any>;
82
+ }>;
83
+ onCheckCode: IEvent<{
84
+ file: string;
85
+ code: string;
86
+ isFromTmp: boolean;
87
+ imports: {
88
+ source: string;
89
+ loc: any;
90
+ default: string;
91
+ namespace: string;
92
+ specifiers: Record<string, string>;
93
+ }[];
94
+ exports: any[];
95
+ cjsExports: string[];
96
+ }>;
97
+ onDevCompileDone: IEvent<{
98
+ isFirstCompile: boolean;
99
+ stats: any;
100
+ time: number;
101
+ }>;
102
+ addEntryImports: IAdd<null, IEntryImport[]>;
103
+ addEntryImportsAhead: IAdd<null, IEntryImport[]>;
104
+ addEntryCodeAhead: IAdd<null, string[]>;
105
+ addEntryCode: IAdd<null, string[]>;
106
+ addExtraBabelPresets: IAdd<null, any[]>;
107
+ addExtraBabelPlugins: IAdd<null, any[]>;
108
+ addBeforeBabelPresets: IAdd<null, any[]>;
109
+ addBeforeBabelPlugins: IAdd<null, any[]>;
110
+ addBeforeMiddlewares: IAdd<null, RequestHandler[]>;
111
+ addMiddlewares: IAdd<null, RequestHandler[]>;
112
+ addHTMLHeadScripts: IAdd<null, IScript[]>;
113
+ addHTMLScripts: IAdd<null, IScript[]>;
114
+ addHTMLStyles: IAdd<null, IStyle[]>;
115
+ addHTMLLinks: IAdd<null, ILink[]>;
116
+ addHTMLMetas: IAdd<null, IMeta[]>;
117
+ addLayouts: IAdd<null, {
118
+ id: string;
119
+ file: string;
120
+ }[]>;
121
+ addPolyfillImports: IAdd<null, {
122
+ source: string;
123
+ specifier?: string;
124
+ }[]>;
125
+ addRuntimePlugin: IAdd<null, string[]>;
126
+ addRuntimePluginKey: IAdd<null, string[]>;
127
+ modifyHTMLFavicon: IModify<string, {}>;
128
+ modifyHTML: IModify<CheerioAPI, {
129
+ path: string;
130
+ }>;
131
+ modifyRendererPath: IModify<string, {}>;
132
+ modifyWebpackConfig: IModify<webpack.Configuration, {
133
+ webpack: typeof webpack;
134
+ env: Env;
135
+ }>;
136
+ modifyViteConfig: IModify<webpack.Configuration, {
137
+ env: Env;
138
+ }>;
139
+ chainWebpack: {
140
+ (fn: {
141
+ (memo: WebpackChain, args: {
142
+ webpack: typeof webpack;
143
+ env: Env;
144
+ }): void;
145
+ }): void;
146
+ };
147
+ };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare function clearTmp(absTmpPath: string): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearTmp = void 0;
4
+ const utils_1 = require("@umijs/utils");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const constants_1 = require("../constants");
8
+ function clearTmp(absTmpPath) {
9
+ if (!(0, fs_1.existsSync)(absTmpPath))
10
+ return;
11
+ (0, fs_1.readdirSync)(absTmpPath).forEach((file) => {
12
+ if (file === constants_1.CACHE_DIR_NAME)
13
+ return;
14
+ utils_1.rimraf.sync((0, path_1.join)(absTmpPath, file));
15
+ });
16
+ }
17
+ exports.clearTmp = clearTmp;
@@ -0,0 +1 @@
1
+ export declare function isTypeScriptFile(path: string): boolean;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTypeScriptFile = void 0;
4
+ function isTypeScriptFile(path) {
5
+ return !/\.d\.ts$/.test(path) && /\.(ts|tsx)$/.test(path);
6
+ }
7
+ exports.isTypeScriptFile = isTypeScriptFile;
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@umijs/preset-umi",
3
+ "version": "4.0.0-beta.10",
4
+ "description": "@umijs/preset-umi",
5
+ "homepage": "https://github.com/umijs/umi-next/tree/master/packages/preset-umi#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",
12
+ "main": "dist/index.js",
13
+ "types": "dist/index.d.ts",
14
+ "files": [
15
+ "assets",
16
+ "dist",
17
+ "templates",
18
+ "compiled"
19
+ ],
20
+ "scripts": {
21
+ "build": "pnpm tsc",
22
+ "build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
23
+ "dev": "pnpm build -- --watch"
24
+ },
25
+ "dependencies": {
26
+ "@types/multer": "1.4.7",
27
+ "@umijs/ast": "4.0.0-beta.10",
28
+ "@umijs/babel-preset-umi": "4.0.0-beta.10",
29
+ "@umijs/bundler-utils": "4.0.0-beta.10",
30
+ "@umijs/bundler-vite": "4.0.0-beta.10",
31
+ "@umijs/bundler-webpack": "4.0.0-beta.10",
32
+ "@umijs/core": "4.0.0-beta.10",
33
+ "@umijs/renderer-react": "4.0.0-beta.10",
34
+ "@umijs/server": "4.0.0-beta.10",
35
+ "@umijs/utils": "4.0.0-beta.10",
36
+ "current-script-polyfill": "1.0.0",
37
+ "enhanced-resolve": "5.8.3",
38
+ "path-to-regexp": "1.7.0",
39
+ "react": "18.0.0-alpha-f2c381131-20211004",
40
+ "react-dom": "18.0.0-alpha-f2c381131-20211004",
41
+ "react-router": "6.0.0-beta.7",
42
+ "react-router-dom": "6.0.0-beta.7"
43
+ },
44
+ "devDependencies": {
45
+ "@types/body-parser": "1.19.2",
46
+ "@types/multer": "1.4.7",
47
+ "body-parser": "1.19.0",
48
+ "multer": "1.4.3"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "authors": [
54
+ "chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"
55
+ ],
56
+ "compiledConfig": {
57
+ "deps": [
58
+ "body-parser",
59
+ "multer"
60
+ ]
61
+ }
62
+ }
@@ -0,0 +1,4 @@
1
+
2
+ .title {
3
+ background: {{{ color }}};
4
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import styles from './{{{ name }}}{{{ cssExt }}}';
3
+
4
+ export default function Page() {
5
+ return (
6
+ <div>
7
+ <h1 className={styles.title}>Page {{{ name }}}</h1>
8
+ </div>
9
+ );
10
+ }
@@ -0,0 +1,18 @@
1
+ {{#plugins}}
2
+ import * as Plugin_{{{ index }}} from '{{{ path }}}';
3
+ {{/plugins}}
4
+
5
+ export function getPlugins() {
6
+ return [
7
+ {{#plugins}}
8
+ {
9
+ apply: Plugin_{{{ index }}},
10
+ path: '{{{ path }}}',
11
+ },
12
+ {{/plugins}}
13
+ ];
14
+ }
15
+
16
+ export function getValidKeys() {
17
+ return [{{#validKeys}}'{{{ . }}}',{{/validKeys}}];
18
+ }
@@ -0,0 +1,7 @@
1
+
2
+ export async function getRoutes() {
3
+ return {
4
+ routes: {{{ routes }}},
5
+ routeComponents: {{{ routeComponents }}},
6
+ };
7
+ }
@@ -0,0 +1,22 @@
1
+ {{{ polyfillImports }}}
2
+ {{{ importsAhead }}}
3
+ import { renderClient } from '{{{ rendererPath }}}';
4
+ import { getRoutes } from './core/route';
5
+ import { getPlugins, getValidKeys } from './core/plugin';
6
+ import { PluginManager } from 'umi';
7
+ {{{ imports }}}
8
+
9
+ async function render() {
10
+ const context = {
11
+ ...await getRoutes(),
12
+ pluginManager: PluginManager.create({
13
+ plugins: getPlugins(),
14
+ validKeys: getValidKeys(),
15
+ }),
16
+ };
17
+ return renderClient(context);
18
+ }
19
+
20
+ {{{ entryCodeAhead }}}
21
+ render();
22
+ {{{ entryCode }}}