@modern-js/core 1.6.0 → 1.7.1-beta.peer.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/js/modern/config/index.js +11 -7
  3. package/dist/js/modern/config/mergeConfig.js +1 -1
  4. package/dist/js/modern/config/schema/index.js +1 -1
  5. package/dist/js/modern/config/types/electron.js +1 -0
  6. package/dist/js/modern/config/types/index.js +1 -0
  7. package/dist/js/modern/config/types/less.js +0 -0
  8. package/dist/js/modern/config/types/sass.js +0 -0
  9. package/dist/js/modern/config/types/ssg.js +0 -0
  10. package/dist/js/modern/config/types/test.js +0 -0
  11. package/dist/js/modern/config/types/unbundle.js +0 -0
  12. package/dist/js/modern/context.js +9 -2
  13. package/dist/js/modern/index.js +27 -9
  14. package/dist/js/modern/initWatcher.js +2 -2
  15. package/dist/js/modern/loadPlugins.js +9 -4
  16. package/dist/js/modern/utils/commander.js +15 -15
  17. package/dist/js/node/config/index.js +38 -11
  18. package/dist/js/node/config/mergeConfig.js +2 -4
  19. package/dist/js/node/config/schema/index.js +3 -5
  20. package/dist/js/node/config/types/electron.js +5 -0
  21. package/dist/js/node/config/types/index.js +5 -0
  22. package/dist/js/node/config/types/less.js +0 -0
  23. package/dist/js/node/config/types/sass.js +0 -0
  24. package/dist/js/node/config/types/ssg.js +0 -0
  25. package/dist/js/node/config/types/test.js +0 -0
  26. package/dist/js/node/config/types/unbundle.js +0 -0
  27. package/dist/js/node/context.js +9 -2
  28. package/dist/js/node/index.js +32 -10
  29. package/dist/js/node/initWatcher.js +2 -3
  30. package/dist/js/node/loadPlugins.js +9 -4
  31. package/dist/js/node/utils/commander.js +16 -19
  32. package/dist/types/config/index.d.ts +4 -140
  33. package/dist/types/config/types/electron.d.ts +13 -0
  34. package/dist/types/config/types/index.d.ts +252 -0
  35. package/dist/types/config/types/less.d.ts +10 -0
  36. package/dist/types/config/types/sass.d.ts +8 -0
  37. package/dist/types/config/types/ssg.d.ts +13 -0
  38. package/dist/types/config/types/test.d.ts +15 -0
  39. package/dist/types/config/types/unbundle.d.ts +28 -0
  40. package/dist/types/context.d.ts +18 -6
  41. package/dist/types/index.d.ts +28 -1
  42. package/dist/types/initWatcher.d.ts +1 -2
  43. package/dist/types/loadPlugins.d.ts +3 -0
  44. package/dist/types/manager.d.ts +7 -6
  45. package/dist/types/utils/commander.d.ts +4 -7
  46. package/jest.config.js +0 -1
  47. package/package.json +18 -17
  48. package/tests/.eslintrc.js +0 -6
  49. package/tests/btsm.test.ts +0 -20
  50. package/tests/config.test.ts +0 -137
  51. package/tests/context.test.ts +0 -70
  52. package/tests/fixtures/index-test/package.json +0 -3
  53. package/tests/fixtures/load-plugin/not-found/package.json +0 -3
  54. package/tests/fixtures/load-plugin/not-found/test-plugin-a.js +0 -1
  55. package/tests/fixtures/load-plugin/user-plugins/package.json +0 -3
  56. package/tests/fixtures/load-plugin/user-plugins/test-plugin-a.js +0 -1
  57. package/tests/fixtures/load-plugin/user-plugins/test-plugin-b.js +0 -3
  58. package/tests/fixtures/load-plugin/user-plugins/test-plugin-c.js +0 -3
  59. package/tests/index.test.ts +0 -69
  60. package/tests/initWatcher.test.ts +0 -63
  61. package/tests/loadEnv.test.ts +0 -173
  62. package/tests/loadPlugin.test.ts +0 -116
  63. package/tests/mergeConfig.test.ts +0 -97
  64. package/tests/pluginAPI.test.ts +0 -19
  65. package/tests/repeatKeyWarning.test.ts +0 -68
  66. package/tests/schema.test.ts +0 -107
  67. package/tests/tsconfig.json +0 -11
  68. package/tests/utils.test.ts +0 -8
@@ -52,13 +52,17 @@ function getAppPlugins(appDirectory, oldPluginConfig, internalPlugins) {
52
52
  return appPlugins;
53
53
  }
54
54
 
55
- const resolveCliPlugin = (p, appDirectory) => {
55
+ const resolveCliPlugin = (p, userConfig, appDirectory, transformPlugin) => {
56
56
  const pkg = typeof p === 'string' ? p : p[0];
57
+ const pluginOptions = typeof p === 'string' ? undefined : p[1];
57
58
  const path = tryResolve(pkg, appDirectory);
58
- const module = (0, _utils.compatRequire)(path);
59
+ let module = (0, _utils.compatRequire)(path);
60
+
61
+ if (transformPlugin) {
62
+ module = transformPlugin(module, userConfig, pluginOptions);
63
+ }
59
64
 
60
65
  if (typeof module === 'function') {
61
- const pluginOptions = Array.isArray(p) ? p[1] : undefined;
62
66
  const result = module(pluginOptions);
63
67
  return (0, _manager.createPlugin)(result.setup, result);
64
68
  }
@@ -78,6 +82,7 @@ const isOldPluginConfig = config => Array.isArray(config) && config.some(item =>
78
82
  * @param appDirectory - Application root directory.
79
83
  * @param userConfig - Resolved user config.
80
84
  * @param options.internalPlugins - Internal plugins.
85
+ * @param options.transformPlugin - transform plugin before using it. Used for compatible with legacy jupiter plugins.
81
86
  * @returns Plugin Objects has been required.
82
87
  */
83
88
 
@@ -97,7 +102,7 @@ const loadPlugins = (appDirectory, userConfig, options = {}) => {
97
102
  const loadedPlugin = {};
98
103
 
99
104
  if (cli) {
100
- loadedPlugin.cli = resolveCliPlugin(cli, appDirectory);
105
+ loadedPlugin.cli = resolveCliPlugin(cli, userConfig, appDirectory, options.transformPlugin);
101
106
  } // server plugins don't support to accept params
102
107
 
103
108
 
@@ -3,33 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "Command", {
7
- enumerable: true,
8
- get: function () {
9
- return _commander.Command;
10
- }
11
- });
6
+ exports.initCommandsMap = initCommandsMap;
12
7
  Object.defineProperty(exports, "program", {
13
8
  enumerable: true,
14
9
  get: function () {
15
- return _commander.program;
10
+ return _utils.program;
16
11
  }
17
12
  });
18
13
 
19
- var _commander = require("commander");
14
+ var _utils = require("@modern-js/utils");
20
15
 
21
- if (!_commander.program.hasOwnProperty('commandsMap')) {
22
- Object.defineProperty(_commander.program, 'commandsMap', {
23
- get() {
24
- const map = new Map();
16
+ function initCommandsMap() {
17
+ if (!_utils.program.hasOwnProperty('commandsMap')) {
18
+ Object.defineProperty(_utils.program, 'commandsMap', {
19
+ get() {
20
+ const map = new Map();
25
21
 
26
- for (const command of _commander.program.commands) {
27
- map.set(command._name, command);
28
- }
22
+ for (const command of _utils.program.commands) {
23
+ map.set(command._name, command);
24
+ }
29
25
 
30
- return map;
31
- },
26
+ return map;
27
+ },
32
28
 
33
- configurable: false
34
- });
29
+ configurable: false
30
+ });
31
+ }
35
32
  }
@@ -1,148 +1,12 @@
1
- /// <reference types="node" />
2
- import http from 'http';
3
1
  import { ErrorObject } from 'ajv';
4
- import { MetaOptions } from '@modern-js/utils';
5
- import type { NextFunction, ProxyOptions } from '@modern-js/types';
6
- import { PluginConfig } from '../loadPlugins';
7
2
  import { defaults } from './defaults';
8
3
  import { mergeConfig, NormalizedConfig } from './mergeConfig';
9
4
  import { PluginValidateSchema } from './schema';
5
+ import type { UserConfig, ConfigParam, LoadedConfig } from './types';
10
6
  export { defaults as defaultsConfig };
11
7
  export { mergeConfig };
12
- interface SourceConfig {
13
- entries?: Record<string, string | {
14
- entry: string;
15
- enableFileSystemRoutes?: boolean;
16
- disableMount?: boolean;
17
- }>;
18
- disableDefaultEntries?: boolean;
19
- entriesDir?: string;
20
- configDir?: string;
21
- apiDir?: string;
22
- envVars?: Array<string>;
23
- globalVars?: Record<string, string>;
24
- alias?: Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>);
25
- moduleScopes?: Array<string | RegExp> | ((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>);
26
- include?: Array<string | RegExp>;
27
- }
28
- interface OutputConfig {
29
- assetPrefix?: string;
30
- htmlPath?: string;
31
- jsPath?: string;
32
- cssPath?: string;
33
- mediaPath?: string;
34
- path?: string;
35
- title?: string;
36
- titleByEntries?: Record<string, string>;
37
- meta?: MetaOptions;
38
- metaByEntries?: Record<string, MetaOptions>;
39
- inject?: 'body' | 'head' | boolean;
40
- injectByEntries?: Record<string, 'body' | 'head' | boolean>;
41
- mountId?: string;
42
- favicon?: string;
43
- faviconByEntries?: Record<string, string | undefined>;
44
- copy?: Array<Record<string, unknown> & {
45
- from: string;
46
- }>;
47
- scriptExt?: Record<string, unknown>;
48
- disableTsChecker?: boolean;
49
- disableHtmlFolder?: boolean;
50
- disableCssModuleExtension?: boolean;
51
- disableCssExtract?: boolean;
52
- enableCssModuleTSDeclaration?: boolean;
53
- disableMinimize?: boolean;
54
- enableInlineStyles?: boolean;
55
- enableInlineScripts?: boolean;
56
- disableSourceMap?: boolean;
57
- disableInlineRuntimeChunk?: boolean;
58
- disableAssetsCache?: boolean;
59
- enableLatestDecorators?: boolean;
60
- polyfill?: 'off' | 'usage' | 'entry' | 'ua';
61
- dataUriLimit?: number;
62
- templateParameters?: Record<string, unknown>;
63
- templateParametersByEntries?: Record<string, Record<string, unknown> | undefined>;
64
- cssModuleLocalIdentName?: string;
65
- enableModernMode?: boolean;
66
- federation?: boolean;
67
- disableNodePolyfill?: boolean;
68
- enableTsLoader?: boolean;
69
- }
70
- interface ServerConfig {
71
- routes?: Record<string, string | string[] | {
72
- route: string | string[];
73
- disableSpa?: boolean;
74
- }>;
75
- publicRoutes?: {
76
- [filepath: string]: string;
77
- };
78
- ssr?: boolean | Record<string, unknown>;
79
- ssrByEntries?: Record<string, boolean | Record<string, unknown>>;
80
- baseUrl?: string | Array<string>;
81
- port?: number;
82
- logger?: boolean | Record<string, any>;
83
- metrics?: boolean | Record<string, any>;
84
- enableMicroFrontendDebug?: boolean;
85
- }
86
- interface DevConfig {
87
- assetPrefix?: string | boolean;
88
- https?: boolean;
89
- }
90
- interface MicroFrontend {
91
- enableHtmlEntry?: boolean;
92
- externalBasicLibrary?: boolean;
93
- moduleApp?: string;
94
- }
95
- interface DeployConfig {
96
- microFrontend?: false | MicroFrontend;
97
- domain?: string | Array<string>;
98
- domainByEntries?: Record<string, string | Array<string>>;
99
- }
100
- declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>) => Record<string, unknown> | void);
101
- declare type RequestHandler = (req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
102
- declare type DevServerConfig = {
103
- proxy?: ProxyOptions;
104
- headers?: Record<string, string>;
105
- before?: RequestHandler[];
106
- after?: RequestHandler[];
107
- [propsName: string]: any;
108
- };
109
- interface ToolsConfig {
110
- webpack?: ConfigFunction;
111
- babel?: ConfigFunction;
112
- autoprefixer?: ConfigFunction;
113
- postcss?: ConfigFunction;
114
- styledComponents?: ConfigFunction;
115
- lodash?: ConfigFunction;
116
- devServer?: DevServerConfig;
117
- tsLoader?: ConfigFunction;
118
- terser?: ConfigFunction;
119
- minifyCss?: ConfigFunction;
120
- esbuild?: Record<string, unknown>;
121
- }
122
- declare type RuntimeConfig = Record<string, any>;
123
- interface RuntimeByEntriesConfig {
124
- [name: string]: RuntimeConfig;
125
- }
126
- interface UserConfig {
127
- source?: SourceConfig;
128
- output?: OutputConfig;
129
- server?: ServerConfig;
130
- dev?: DevConfig;
131
- deploy?: DeployConfig;
132
- tools?: ToolsConfig;
133
- plugins?: PluginConfig;
134
- runtime?: RuntimeConfig;
135
- runtimeByEntries?: RuntimeByEntriesConfig;
136
- }
137
- declare type ConfigParam = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
138
- interface LoadedConfig {
139
- config: UserConfig;
140
- filePath: string | false;
141
- dependencies: string[];
142
- pkgConfig: UserConfig;
143
- jsConfig: UserConfig;
144
- }
8
+ export * from './types';
9
+ export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
145
10
  export declare const defineConfig: (config: ConfigParam) => ConfigParam;
146
11
  export declare const loadUserConfig: (appDirectory: string, filePath?: string | undefined, packageJsonConfig?: string | undefined) => Promise<LoadedConfig>;
147
- export declare const resolveConfig: (loaded: LoadedConfig, configs: UserConfig[], schemas: PluginValidateSchema[], restartWithExistingPort: number, argv: string[], onSchemaError?: (error: ErrorObject) => void) => Promise<NormalizedConfig>;
148
- export type { SourceConfig, OutputConfig, ServerConfig, DevConfig, DeployConfig, ToolsConfig, RuntimeConfig, RuntimeByEntriesConfig, UserConfig, ConfigParam, LoadedConfig };
12
+ export declare const resolveConfig: (loaded: LoadedConfig, configs: UserConfig[], schemas: PluginValidateSchema[], restartWithExistingPort: number, argv: string[], onSchemaError?: (error: ErrorObject) => void) => Promise<NormalizedConfig>;
@@ -0,0 +1,13 @@
1
+ import { TransformOptions } from '@babel/core';
2
+ import { Configuration } from 'electron-builder';
3
+ export declare type BuildConfig = {
4
+ baseConfig: Configuration;
5
+ macConfig?: Configuration;
6
+ winConfig?: Configuration;
7
+ win64Config?: Configuration;
8
+ linuxConfig?: Configuration;
9
+ };
10
+ export declare type ElectronConfig = {
11
+ builder?: BuildConfig;
12
+ babel?: TransformOptions | ((defaultBabelConfig: TransformOptions) => TransformOptions);
13
+ };
@@ -0,0 +1,252 @@
1
+ /// <reference types="node" />
2
+ import type { IncomingMessage, ServerResponse } from 'http';
3
+ import type { NextFunction, BffProxyOptions } from '@modern-js/types';
4
+ import type { MetaOptions } from '@modern-js/utils';
5
+ import type { TransformOptions } from '@babel/core';
6
+ import type webpack from 'webpack';
7
+ import type { Configuration as WebpackConfiguration } from 'webpack';
8
+ import autoprefixer from 'autoprefixer';
9
+ import type { BasePluginOptions, TerserOptions as RawTerserOptions } from 'terser-webpack-plugin';
10
+ import type { PluginConfig } from '../../loadPlugins';
11
+ import type { TestConfig, JestConfig } from './test';
12
+ import type { SassConfig, SassLoaderOptions } from './sass';
13
+ import type { LessConfig, LessLoaderOptions } from './less';
14
+ import type { UnbundleConfig } from './unbundle';
15
+ import type { SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions } from './ssg';
16
+ import { ElectronConfig } from './electron';
17
+ declare type AutoprefixerOptions = autoprefixer.Options;
18
+ declare type TerserOptions = BasePluginOptions & RawTerserOptions;
19
+ export type { TestConfig, JestConfig, UnbundleConfig, SassConfig, SassLoaderOptions, LessConfig, LessLoaderOptions, SSGConfig, SSGRouteOptions, SSGMultiEntryOptions, SSGSingleEntryOptions, TransformOptions, AutoprefixerOptions, TerserOptions };
20
+ export interface SourceConfig {
21
+ entries?: Record<string, string | {
22
+ entry: string;
23
+ enableFileSystemRoutes?: boolean;
24
+ disableMount?: boolean;
25
+ }>;
26
+ disableDefaultEntries?: boolean;
27
+ entriesDir?: string;
28
+ configDir?: string;
29
+ apiDir?: string;
30
+ envVars?: Array<string>;
31
+ globalVars?: Record<string, string>;
32
+ alias?: Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>);
33
+ moduleScopes?: Array<string | RegExp> | ((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>);
34
+ include?: Array<string | RegExp>;
35
+ /**
36
+ * The configuration of `source.designSystem` is provided by plugin `@modern-js/plugin-tailwindcss`.
37
+ * Please use `yarn new` to enable the corresponding capability.
38
+ * @requires `@modern-js/plugin-tailwindcss`
39
+ */
40
+
41
+ designSystem?: Record<string, any>;
42
+ }
43
+ export interface OutputConfig {
44
+ assetPrefix?: string;
45
+ htmlPath?: string;
46
+ jsPath?: string;
47
+ cssPath?: string;
48
+ mediaPath?: string;
49
+ path?: string;
50
+ title?: string;
51
+ titleByEntries?: Record<string, string>;
52
+ meta?: MetaOptions;
53
+ metaByEntries?: Record<string, MetaOptions>;
54
+ inject?: 'body' | 'head' | boolean;
55
+ injectByEntries?: Record<string, 'body' | 'head' | boolean>;
56
+ mountId?: string;
57
+ favicon?: string;
58
+ faviconByEntries?: Record<string, string | undefined>;
59
+ copy?: Array<Record<string, unknown> & {
60
+ from: string;
61
+ }>;
62
+ scriptExt?: Record<string, unknown>;
63
+ disableTsChecker?: boolean;
64
+ disableHtmlFolder?: boolean;
65
+ disableCssModuleExtension?: boolean;
66
+ disableCssExtract?: boolean;
67
+ enableCssModuleTSDeclaration?: boolean;
68
+ disableMinimize?: boolean;
69
+ enableInlineStyles?: boolean;
70
+ enableInlineScripts?: boolean;
71
+ disableSourceMap?: boolean;
72
+ disableInlineRuntimeChunk?: boolean;
73
+ disableAssetsCache?: boolean;
74
+ enableLatestDecorators?: boolean;
75
+ polyfill?: 'off' | 'usage' | 'entry' | 'ua';
76
+ dataUriLimit?: number;
77
+ templateParameters?: Record<string, unknown>;
78
+ templateParametersByEntries?: Record<string, Record<string, unknown> | undefined>;
79
+ cssModuleLocalIdentName?: string;
80
+ enableModernMode?: boolean;
81
+ federation?: boolean;
82
+ disableNodePolyfill?: boolean;
83
+ enableTsLoader?: boolean;
84
+ /**
85
+ * Disables lazy import support for styles, currently supports antd and arco-design.
86
+ * The configuration of `output.disableAutoImportStyle` is provided by plugin `@modern-js/plugin-unbundle`.
87
+ * Please use `yarn new` to enable the corresponding capability.
88
+ * @requires `@modern-js/plugin-unbundle`
89
+ */
90
+
91
+ disableAutoImportStyle?: boolean;
92
+ /**
93
+ * The configuration of `output.ssg` is provided by plugin `@modern-js/plugin-ssg`.
94
+ * Please use `yarn new` to enable the corresponding capability.
95
+ * @requires `@modern-js/plugin-ssg`
96
+ */
97
+
98
+ ssg?: SSGConfig;
99
+ }
100
+ export interface ServerConfig {
101
+ routes?: Record<string, string | string[] | {
102
+ route: string | string[];
103
+ disableSpa?: boolean;
104
+ }>;
105
+ publicRoutes?: {
106
+ [filepath: string]: string;
107
+ };
108
+ ssr?: boolean | Record<string, unknown>;
109
+ ssrByEntries?: Record<string, boolean | Record<string, unknown>>;
110
+ baseUrl?: string | Array<string>;
111
+ port?: number;
112
+ logger?: boolean | Record<string, any>;
113
+ metrics?: boolean | Record<string, any>;
114
+ enableMicroFrontendDebug?: boolean;
115
+ }
116
+ export declare type DevProxyOptions = string | Record<string, string>;
117
+ export interface DevConfig {
118
+ assetPrefix?: string | boolean;
119
+ https?: boolean;
120
+ /**
121
+ * The configuration of `dev.proxy` is provided by plugin `@modern-js/plugin-proxy`.
122
+ * Please use `yarn new` to enable the corresponding capability.
123
+ * @requires `@modern-js/plugin-proxy`
124
+ */
125
+
126
+ proxy?: DevProxyOptions;
127
+ /**
128
+ * The configuration of `dev.unbundle` is provided by plugin `@modern-js/plugin-unbundle`.
129
+ * Please use `yarn new` to enable the corresponding capability.
130
+ * @requires `@modern-js/plugin-unbundle`
131
+ */
132
+
133
+ unbundle?: UnbundleConfig;
134
+ }
135
+ export interface MicroFrontend {
136
+ enableHtmlEntry?: boolean;
137
+ externalBasicLibrary?: boolean;
138
+ moduleApp?: string;
139
+ }
140
+ export interface DeployConfig {
141
+ microFrontend?: false | MicroFrontend;
142
+ domain?: string | Array<string>;
143
+ domainByEntries?: Record<string, string | Array<string>>;
144
+ }
145
+ declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>, utils?: any) => Record<string, unknown> | void);
146
+ export declare type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
147
+ export declare type DevServerConfig = {
148
+ proxy?: BffProxyOptions;
149
+ headers?: Record<string, string>;
150
+ before?: RequestHandler[];
151
+ after?: RequestHandler[];
152
+ [propsName: string]: any;
153
+ };
154
+ export declare type WebpackConfig = WebpackConfiguration | ((config: WebpackConfiguration, utils: {
155
+ env: string;
156
+ webpack: typeof webpack;
157
+ [key: string]: any;
158
+ }) => WebpackConfiguration | void);
159
+ export declare type BabelConfig = TransformOptions | ((config: TransformOptions, utils?: any) => TransformOptions | void);
160
+ export declare type AutoprefixerConfig = AutoprefixerOptions | ((config: AutoprefixerOptions) => AutoprefixerOptions | void);
161
+ export declare type TerserConfig = TerserOptions | ((config: TerserOptions) => TerserOptions | void);
162
+ export interface ToolsConfig {
163
+ webpack?: WebpackConfig;
164
+ babel?: BabelConfig;
165
+ autoprefixer?: AutoprefixerConfig;
166
+ postcss?: ConfigFunction;
167
+ styledComponents?: ConfigFunction;
168
+ lodash?: ConfigFunction;
169
+ devServer?: DevServerConfig;
170
+ tsLoader?: ConfigFunction;
171
+ terser?: TerserConfig;
172
+ minifyCss?: ConfigFunction;
173
+ esbuild?: Record<string, unknown>;
174
+ /**
175
+ * The configuration of `tools.tailwindcss` is provided by plugin `@modern-js/plugin-tailwindcss`.
176
+ * Please use `yarn new` to enable the corresponding capability.
177
+ * @requires `@modern-js/plugin-tailwindcss`
178
+ */
179
+
180
+ tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
181
+ /**
182
+ * The configuration of `tools.jest` is provided by plugin `@modern-js/plugin-testing`.
183
+ * Please use `yarn new` to enable the corresponding capability.
184
+ * @requires `@modern-js/plugin-testing`
185
+ */
186
+
187
+ jest?: TestConfig['jest'];
188
+ /**
189
+ * The configuration of `tools.sass` is provided by plugin `@modern-js/plugin-sass`.
190
+ * Please use `yarn new` to enable the corresponding capability.
191
+ * @requires `@modern-js/plugin-sass`
192
+ */
193
+
194
+ sass?: SassConfig;
195
+ /**
196
+ * The configuration of `tools.less` is provided by plugin `@modern-js/plugin-less`.
197
+ * Please use `yarn new` to enable the corresponding capability.
198
+ * @requires `@modern-js/plugin-less`
199
+ */
200
+
201
+ less?: LessConfig;
202
+ }
203
+ export declare type RuntimeConfig = Record<string, any>;
204
+ export interface RuntimeByEntriesConfig {
205
+ [name: string]: RuntimeConfig;
206
+ }
207
+ export declare type BffConfig = Partial<{
208
+ prefix: string;
209
+ requestCreator: string;
210
+ fetcher: string;
211
+ proxy: Record<string, any>;
212
+ }>;
213
+ export interface UserConfig {
214
+ source?: SourceConfig;
215
+ output?: OutputConfig;
216
+ server?: ServerConfig;
217
+ dev?: DevConfig;
218
+ deploy?: DeployConfig;
219
+ tools?: ToolsConfig;
220
+ plugins?: PluginConfig;
221
+ runtime?: RuntimeConfig;
222
+ runtimeByEntries?: RuntimeByEntriesConfig;
223
+ /**
224
+ * The configuration of `bff` is provided by plugin `@modern-js/plugin-bff`.
225
+ * Please use `yarn new` to enable the corresponding capability.
226
+ * @requires `@modern-js/plugin-bff`
227
+ */
228
+
229
+ bff?: BffConfig;
230
+ /**
231
+ * The configuration of `testing` is provided by plugin `@modern-js/plugin-testing`.
232
+ * Please use `yarn new` to enable the corresponding capability.
233
+ * @requires `@modern-js/plugin-testing`
234
+ */
235
+
236
+ testing?: TestConfig;
237
+ /**
238
+ * The configuration of `electron` is provided by plugin `@modern-js/plugin-electron`.
239
+ * Please use `yarn new` to enable the corresponding capability.
240
+ * @requires `@modern-js/plugin-electron`
241
+ */
242
+
243
+ electron?: ElectronConfig;
244
+ }
245
+ export declare type ConfigParam = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
246
+ export interface LoadedConfig {
247
+ config: UserConfig;
248
+ filePath: string | false;
249
+ dependencies: string[];
250
+ pkgConfig: UserConfig;
251
+ jsConfig: UserConfig;
252
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="less" />
2
+ import type { LoaderContext } from 'webpack';
3
+ export declare type LessLoaderOptions = {
4
+ lessOptions?: Less.Options;
5
+ additionalData?: string | ((content: string, loaderContext: LoaderContext<LessLoaderOptions>) => string);
6
+ sourceMap?: boolean;
7
+ webpackImporter?: boolean;
8
+ implementation?: boolean;
9
+ };
10
+ export declare type LessConfig = LessLoaderOptions | ((options: LessLoaderOptions, utils?: any) => LessLoaderOptions | void);
@@ -0,0 +1,8 @@
1
+ import type { LegacyFileOptions } from 'sass';
2
+ export interface SassLoaderOptions {
3
+ sassOptions?: LegacyFileOptions<'sync'>;
4
+ sourceMap?: boolean;
5
+ implementation?: string;
6
+ additionalData?: string | ((content: string, filename: string) => string);
7
+ }
8
+ export declare type SassConfig = SassLoaderOptions | ((options: SassLoaderOptions, utils?: any) => SassLoaderOptions | void);
@@ -0,0 +1,13 @@
1
+ export declare type SSGRouteOptions = string | {
2
+ url: string;
3
+ output?: string;
4
+ params?: Record<string, any>[];
5
+ headers?: Record<string, any>;
6
+ };
7
+ export declare type SSGSingleEntryOptions = boolean | {
8
+ preventDefault?: string[];
9
+ headers?: Record<string, any>;
10
+ routes?: SSGRouteOptions[];
11
+ };
12
+ export declare type SSGMultiEntryOptions = Record<string, SSGSingleEntryOptions>;
13
+ export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string) => SSGSingleEntryOptions);
@@ -0,0 +1,15 @@
1
+ import type { Config as JestConfigTypes } from '@jest/types';
2
+ export declare type JestConfig = JestConfigTypes.InitialOptions;
3
+ export interface TestConfig {
4
+ /**
5
+ * Decide which transformer will be used to compile file
6
+ * Default: babel-jest
7
+ */
8
+ transformer?: 'babel-jest' | 'ts-jest';
9
+ /**
10
+ * Original jest config
11
+ * Doc: https://jestjs.io/docs/configuration
12
+ */
13
+
14
+ jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
15
+ }
@@ -0,0 +1,28 @@
1
+ export declare type UnbundleConfig = {
2
+ /**
3
+ * Some package A may require another package B that is intended for Node.js
4
+ * use only. In such a case, if package B cannot be converted to ESM, it will
5
+ * cause package A to fail during unbundle development, even though package B
6
+ * is not really required. Package B can thus be safely ignored via this option
7
+ * to ensure transpilation of package A to ESM
8
+ */
9
+ ignore?: string | string[];
10
+ /**
11
+ * ignores cached esm modules and recompiles dependencies not available
12
+ * from PDN host on dev start.
13
+ * default: false
14
+ */
15
+
16
+ ignoreModuleCache?: boolean;
17
+ /**
18
+ * clears cache of downloaded esm modules (from PDN) on dev start.
19
+ * default: false
20
+ */
21
+
22
+ clearPdnCache?: boolean;
23
+ /**
24
+ * modifies host to attempt to download esm modules from
25
+ */
26
+
27
+ pdnHost?: string;
28
+ };
@@ -27,9 +27,21 @@ export declare const useConfigContext: () => UserConfig;
27
27
  */
28
28
 
29
29
  export declare const useResolvedConfigContext: () => NormalizedConfig;
30
- export declare const initAppContext: (appDirectory: string, plugins: LoadedPlugin[], configFile: string | false, options?: {
31
- metaName?: string | undefined;
32
- srcDir?: string | undefined;
33
- distDir?: string | undefined;
34
- sharedDir?: string | undefined;
35
- } | undefined) => IAppContext;
30
+ export declare const initAppContext: ({
31
+ appDirectory,
32
+ plugins,
33
+ configFile,
34
+ options,
35
+ serverConfigFile
36
+ }: {
37
+ appDirectory: string;
38
+ plugins: LoadedPlugin[];
39
+ configFile: string | false;
40
+ options?: {
41
+ metaName?: string | undefined;
42
+ srcDir?: string | undefined;
43
+ distDir?: string | undefined;
44
+ sharedDir?: string | undefined;
45
+ } | undefined;
46
+ serverConfigFile: string;
47
+ }) => IAppContext;
@@ -1,6 +1,7 @@
1
1
  import { INTERNAL_PLUGINS } from '@modern-js/utils';
2
2
  import type { Hooks } from '@modern-js/types';
3
3
  import { ErrorObject } from 'ajv';
4
+ import { TransformPlugin } from './loadPlugins';
4
5
  import { IAppContext, initAppContext } from './context';
5
6
  import type { NormalizedConfig } from './config/mergeConfig';
6
7
  export type { Hooks };
@@ -15,8 +16,10 @@ export type { NormalizedConfig, IAppContext };
15
16
  declare const initAppDir: (cwd?: string | undefined) => Promise<string>;
16
17
  export interface CoreOptions {
17
18
  configFile?: string;
19
+ serverConfigFile?: string;
18
20
  packageJsonConfig?: string;
19
21
  plugins?: typeof INTERNAL_PLUGINS;
22
+ transformPlugin?: TransformPlugin;
20
23
  onSchemaError?: (error: ErrorObject) => void;
21
24
  options?: {
22
25
  metaName?: string;
@@ -25,6 +28,25 @@ export interface CoreOptions {
25
28
  sharedDir?: string;
26
29
  };
27
30
  }
31
+ export declare const mergeOptions: (options?: CoreOptions | undefined) => {
32
+ configFile?: string | undefined;
33
+ serverConfigFile: string;
34
+ packageJsonConfig?: string | undefined;
35
+ plugins?: {
36
+ [name: string]: {
37
+ cli?: string | undefined;
38
+ server?: string | undefined;
39
+ };
40
+ } | undefined;
41
+ transformPlugin?: TransformPlugin | undefined;
42
+ onSchemaError?: ((error: ErrorObject) => void) | undefined;
43
+ options?: {
44
+ metaName?: string | undefined;
45
+ srcDir?: string | undefined;
46
+ distDir?: string | undefined;
47
+ sharedDir?: string | undefined;
48
+ } | undefined;
49
+ };
28
50
  export declare const cli: {
29
51
  init: (argv?: string[], options?: CoreOptions | undefined) => Promise<{
30
52
  loadedConfig: import("./config").LoadedConfig;
@@ -34,4 +56,9 @@ export declare const cli: {
34
56
  run: (argv: string[], options?: CoreOptions | undefined) => Promise<void>;
35
57
  restart: () => Promise<void>;
36
58
  };
37
- export { initAppDir, initAppContext };
59
+ export { initAppDir, initAppContext };
60
+ declare module '@modern-js/utils/compiled/commander' {
61
+ interface Command {
62
+ commandsMap: Map<string, Command>;
63
+ }
64
+ }
@@ -1,4 +1,3 @@
1
- import chokidar from 'chokidar';
2
1
  import { LoadedConfig } from './config';
3
2
  import { HooksRunner } from './manager';
4
- export declare const initWatcher: (loaded: LoadedConfig, appDirectory: string, configDir: string | undefined, hooksRunner: HooksRunner, argv: string[]) => Promise<chokidar.FSWatcher | undefined>;
3
+ export declare const initWatcher: (loaded: LoadedConfig, appDirectory: string, configDir: string | undefined, hooksRunner: HooksRunner, argv: string[]) => Promise<import("@modern-js/utils").FSWatcher | undefined>;