@modern-js/core 1.8.0 → 1.9.0
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.
- package/.eslintrc.js +1 -0
- package/CHANGELOG.md +22 -0
- package/bin/modern-js.js +1 -1
- package/compiled/ajv/codegen.js +1 -0
- package/compiled/ajv/dist/ajv.d.ts +16 -0
- package/compiled/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/compiled/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/ajv/dist/compile/ref_error.d.ts +6 -0
- package/compiled/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/ajv/dist/core.d.ts +173 -0
- package/compiled/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/ajv/dist/types/index.d.ts +183 -0
- package/compiled/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/ajv/dist/types/jtd-schema.d.ts +169 -0
- package/compiled/ajv/index.js +9 -0
- package/compiled/ajv/license +22 -0
- package/compiled/ajv/package.json +1 -0
- package/compiled/ajv/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/ajv-keywords/ajv/dist/ajv.d.ts +16 -0
- package/compiled/ajv-keywords/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/compiled/ajv-keywords/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/ajv-keywords/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/ajv-keywords/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/ajv-keywords/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/ajv-keywords/ajv/dist/compile/ref_error.d.ts +6 -0
- package/compiled/ajv-keywords/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/ajv-keywords/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/ajv-keywords/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/ajv-keywords/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/ajv-keywords/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/ajv-keywords/ajv/dist/core.d.ts +173 -0
- package/compiled/ajv-keywords/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/ajv-keywords/ajv/dist/types/index.d.ts +183 -0
- package/compiled/ajv-keywords/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/ajv-keywords/ajv/dist/types/jtd-schema.d.ts +169 -0
- package/compiled/ajv-keywords/dist/index.d.ts +4 -0
- package/compiled/ajv-keywords/index.js +1 -0
- package/compiled/ajv-keywords/license +21 -0
- package/compiled/ajv-keywords/package.json +1 -0
- package/compiled/ajv-keywords/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/better-ajv-errors/ajv/dist/ajv.d.ts +16 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/code.d.ts +40 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/ref_error.d.ts +6 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/better-ajv-errors/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/better-ajv-errors/ajv/dist/core.d.ts +173 -0
- package/compiled/better-ajv-errors/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/better-ajv-errors/ajv/dist/types/index.d.ts +183 -0
- package/compiled/better-ajv-errors/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/better-ajv-errors/ajv/dist/types/jtd-schema.d.ts +169 -0
- package/compiled/better-ajv-errors/index.js +1 -0
- package/compiled/better-ajv-errors/license +13 -0
- package/compiled/better-ajv-errors/package.json +1 -0
- package/compiled/better-ajv-errors/typings.d.ts +24 -0
- package/compiled/better-ajv-errors/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/v8-compile-cache/index.js +1 -0
- package/compiled/v8-compile-cache/license +21 -0
- package/compiled/v8-compile-cache/package.json +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +33 -0
- package/dist/config/defaults.d.ts +28 -0
- package/dist/config/defaults.js +98 -0
- package/dist/{types/config → config}/index.d.ts +2 -2
- package/dist/config/index.js +120 -0
- package/dist/config/mergeConfig.d.ts +30 -0
- package/dist/config/mergeConfig.js +26 -0
- package/dist/config/schema/deploy.d.ts +16 -0
- package/dist/config/schema/deploy.js +16 -0
- package/dist/config/schema/index.d.ts +466 -0
- package/dist/config/schema/index.js +95 -0
- package/dist/config/schema/output.d.ts +146 -0
- package/dist/config/schema/output.js +68 -0
- package/dist/config/schema/server.d.ts +182 -0
- package/dist/config/schema/server.js +107 -0
- package/dist/config/schema/source.d.ts +58 -0
- package/dist/config/schema/source.js +36 -0
- package/dist/config/schema/tools.d.ts +36 -0
- package/dist/config/schema/tools.js +19 -0
- package/dist/config/types/electron.d.ts +13 -0
- package/dist/config/types/electron.js +2 -0
- package/dist/config/types/index.d.ts +240 -0
- package/dist/config/types/index.js +2 -0
- package/dist/config/types/less.d.ts +10 -0
- package/dist/config/types/less.js +2 -0
- package/dist/config/types/sass.d.ts +8 -0
- package/dist/config/types/sass.js +2 -0
- package/dist/{types/config → config}/types/ssg.d.ts +8 -8
- package/dist/config/types/ssg.js +2 -0
- package/dist/config/types/test.d.ts +14 -0
- package/dist/config/types/test.js +2 -0
- package/dist/config/types/unbundle.d.ts +25 -0
- package/dist/config/types/unbundle.js +2 -0
- package/dist/{types/context.d.ts → context.d.ts} +12 -22
- package/dist/context.js +59 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +177 -0
- package/dist/{types/initWatcher.d.ts → initWatcher.d.ts} +1 -1
- package/dist/initWatcher.js +75 -0
- package/dist/{types/loadEnv.d.ts → loadEnv.d.ts} +1 -1
- package/dist/loadEnv.js +21 -0
- package/dist/{types/loadPlugins.d.ts → loadPlugins.d.ts} +13 -16
- package/dist/loadPlugins.js +109 -0
- package/dist/manager.d.ts +72 -0
- package/dist/manager.js +24 -0
- package/dist/{types/pluginAPI.d.ts → pluginAPI.d.ts} +5 -6
- package/dist/pluginAPI.js +16 -0
- package/dist/{types/utils → utils}/commander.d.ts +1 -1
- package/dist/utils/commander.js +20 -0
- package/dist/{types/utils → utils}/repeatKeyWarning.d.ts +1 -1
- package/dist/utils/repeatKeyWarning.js +22 -0
- package/package.json +12 -26
- package/tsconfig.json +3 -4
- package/dist/js/modern/cli.js +0 -29
- package/dist/js/modern/config/defaults.js +0 -103
- package/dist/js/modern/config/index.js +0 -115
- package/dist/js/modern/config/mergeConfig.js +0 -22
- package/dist/js/modern/config/schema/deploy.js +0 -17
- package/dist/js/modern/config/schema/index.js +0 -107
- package/dist/js/modern/config/schema/output.js +0 -147
- package/dist/js/modern/config/schema/server.js +0 -170
- package/dist/js/modern/config/schema/source.js +0 -59
- package/dist/js/modern/config/schema/tools.js +0 -36
- package/dist/js/modern/config/types/electron.js +0 -1
- package/dist/js/modern/config/types/index.js +0 -1
- package/dist/js/modern/config/types/less.js +0 -0
- package/dist/js/modern/config/types/sass.js +0 -0
- package/dist/js/modern/config/types/ssg.js +0 -0
- package/dist/js/modern/config/types/test.js +0 -0
- package/dist/js/modern/config/types/unbundle.js +0 -0
- package/dist/js/modern/context.js +0 -63
- package/dist/js/modern/index.js +0 -169
- package/dist/js/modern/initWatcher.js +0 -62
- package/dist/js/modern/loadEnv.js +0 -14
- package/dist/js/modern/loadPlugins.js +0 -122
- package/dist/js/modern/manager.js +0 -28
- package/dist/js/modern/pluginAPI.js +0 -11
- package/dist/js/modern/utils/commander.js +0 -19
- package/dist/js/modern/utils/repeatKeyWarning.js +0 -18
- package/dist/js/node/cli.js +0 -35
- package/dist/js/node/config/defaults.js +0 -110
- package/dist/js/node/config/index.js +0 -182
- package/dist/js/node/config/mergeConfig.js +0 -32
- package/dist/js/node/config/schema/deploy.js +0 -26
- package/dist/js/node/config/schema/index.js +0 -127
- package/dist/js/node/config/schema/output.js +0 -156
- package/dist/js/node/config/schema/server.js +0 -179
- package/dist/js/node/config/schema/source.js +0 -68
- package/dist/js/node/config/schema/tools.js +0 -43
- package/dist/js/node/config/types/electron.js +0 -5
- package/dist/js/node/config/types/index.js +0 -5
- package/dist/js/node/config/types/less.js +0 -0
- package/dist/js/node/config/types/sass.js +0 -0
- package/dist/js/node/config/types/ssg.js +0 -0
- package/dist/js/node/config/types/test.js +0 -0
- package/dist/js/node/config/types/unbundle.js +0 -0
- package/dist/js/node/context.js +0 -93
- package/dist/js/node/index.js +0 -329
- package/dist/js/node/initWatcher.js +0 -82
- package/dist/js/node/loadEnv.js +0 -30
- package/dist/js/node/loadPlugins.js +0 -134
- package/dist/js/node/manager.js +0 -45
- package/dist/js/node/pluginAPI.js +0 -54
- package/dist/js/node/utils/commander.js +0 -32
- package/dist/js/node/utils/repeatKeyWarning.js +0 -31
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/config/defaults.d.ts +0 -28
- package/dist/types/config/mergeConfig.d.ts +0 -31
- package/dist/types/config/schema/deploy.d.ts +0 -16
- package/dist/types/config/schema/index.d.ts +0 -466
- package/dist/types/config/schema/output.d.ts +0 -146
- package/dist/types/config/schema/server.d.ts +0 -182
- package/dist/types/config/schema/source.d.ts +0 -58
- package/dist/types/config/schema/tools.d.ts +0 -36
- package/dist/types/config/types/electron.d.ts +0 -13
- package/dist/types/config/types/index.d.ts +0 -252
- package/dist/types/config/types/less.d.ts +0 -10
- package/dist/types/config/types/sass.d.ts +0 -8
- package/dist/types/config/types/test.d.ts +0 -15
- package/dist/types/config/types/unbundle.d.ts +0 -28
- package/dist/types/index.d.ts +0 -64
- package/dist/types/manager.d.ts +0 -75
- package/modern.config.js +0 -6
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const tools: {
|
|
2
|
+
type: string;
|
|
3
|
+
additionalProperties: boolean;
|
|
4
|
+
properties: {
|
|
5
|
+
webpack: {
|
|
6
|
+
typeof: string[];
|
|
7
|
+
};
|
|
8
|
+
babel: {
|
|
9
|
+
typeof: string[];
|
|
10
|
+
};
|
|
11
|
+
postcss: {
|
|
12
|
+
typeof: string[];
|
|
13
|
+
};
|
|
14
|
+
lodash: {
|
|
15
|
+
typeof: string[];
|
|
16
|
+
};
|
|
17
|
+
devServer: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
tsLoader: {
|
|
21
|
+
typeof: string[];
|
|
22
|
+
};
|
|
23
|
+
autoprefixer: {
|
|
24
|
+
typeof: string[];
|
|
25
|
+
};
|
|
26
|
+
terser: {
|
|
27
|
+
typeof: string[];
|
|
28
|
+
};
|
|
29
|
+
minifyCss: {
|
|
30
|
+
typeof: string[];
|
|
31
|
+
};
|
|
32
|
+
styledComponents: {
|
|
33
|
+
typeof: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tools = void 0;
|
|
4
|
+
exports.tools = {
|
|
5
|
+
type: 'object',
|
|
6
|
+
additionalProperties: false,
|
|
7
|
+
properties: {
|
|
8
|
+
webpack: { typeof: ['object', 'function'] },
|
|
9
|
+
babel: { typeof: ['object', 'function'] },
|
|
10
|
+
postcss: { typeof: ['object', 'function'] },
|
|
11
|
+
lodash: { typeof: ['object', 'function'] },
|
|
12
|
+
devServer: { type: 'object' },
|
|
13
|
+
tsLoader: { typeof: ['object', 'function'] },
|
|
14
|
+
autoprefixer: { typeof: ['object', 'function'] },
|
|
15
|
+
terser: { typeof: ['object', 'function'] },
|
|
16
|
+
minifyCss: { typeof: ['object', 'function'] },
|
|
17
|
+
styledComponents: { typeof: ['object', 'function'] },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -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,240 @@
|
|
|
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
|
+
designSystem?: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
export interface OutputConfig {
|
|
43
|
+
assetPrefix?: string;
|
|
44
|
+
htmlPath?: string;
|
|
45
|
+
jsPath?: string;
|
|
46
|
+
cssPath?: string;
|
|
47
|
+
mediaPath?: string;
|
|
48
|
+
path?: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
titleByEntries?: Record<string, string>;
|
|
51
|
+
meta?: MetaOptions;
|
|
52
|
+
metaByEntries?: Record<string, MetaOptions>;
|
|
53
|
+
inject?: 'body' | 'head' | boolean;
|
|
54
|
+
injectByEntries?: Record<string, 'body' | 'head' | boolean>;
|
|
55
|
+
mountId?: string;
|
|
56
|
+
favicon?: string;
|
|
57
|
+
faviconByEntries?: Record<string, string | undefined>;
|
|
58
|
+
copy?: Array<Record<string, unknown> & {
|
|
59
|
+
from: string;
|
|
60
|
+
}>;
|
|
61
|
+
scriptExt?: Record<string, unknown>;
|
|
62
|
+
disableTsChecker?: boolean;
|
|
63
|
+
disableHtmlFolder?: boolean;
|
|
64
|
+
disableCssModuleExtension?: boolean;
|
|
65
|
+
disableCssExtract?: boolean;
|
|
66
|
+
enableCssModuleTSDeclaration?: boolean;
|
|
67
|
+
disableMinimize?: boolean;
|
|
68
|
+
enableInlineStyles?: boolean;
|
|
69
|
+
enableInlineScripts?: boolean;
|
|
70
|
+
disableSourceMap?: boolean;
|
|
71
|
+
disableInlineRuntimeChunk?: boolean;
|
|
72
|
+
disableAssetsCache?: boolean;
|
|
73
|
+
enableLatestDecorators?: boolean;
|
|
74
|
+
polyfill?: 'off' | 'usage' | 'entry' | 'ua';
|
|
75
|
+
dataUriLimit?: number;
|
|
76
|
+
templateParameters?: Record<string, unknown>;
|
|
77
|
+
templateParametersByEntries?: Record<string, Record<string, unknown> | undefined>;
|
|
78
|
+
cssModuleLocalIdentName?: string;
|
|
79
|
+
enableModernMode?: boolean;
|
|
80
|
+
federation?: boolean;
|
|
81
|
+
disableNodePolyfill?: boolean;
|
|
82
|
+
enableTsLoader?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Disables lazy import support for styles, currently supports antd and arco-design.
|
|
85
|
+
* The configuration of `output.disableAutoImportStyle` is provided by plugin `@modern-js/plugin-unbundle`.
|
|
86
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
87
|
+
* @requires `@modern-js/plugin-unbundle`
|
|
88
|
+
*/
|
|
89
|
+
disableAutoImportStyle?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The configuration of `output.ssg` is provided by plugin `@modern-js/plugin-ssg`.
|
|
92
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
93
|
+
* @requires `@modern-js/plugin-ssg`
|
|
94
|
+
*/
|
|
95
|
+
ssg?: SSGConfig;
|
|
96
|
+
}
|
|
97
|
+
export interface ServerConfig {
|
|
98
|
+
routes?: Record<string, string | string[] | {
|
|
99
|
+
route: string | string[];
|
|
100
|
+
disableSpa?: boolean;
|
|
101
|
+
}>;
|
|
102
|
+
publicRoutes?: {
|
|
103
|
+
[filepath: string]: string;
|
|
104
|
+
};
|
|
105
|
+
ssr?: boolean | Record<string, unknown>;
|
|
106
|
+
ssrByEntries?: Record<string, boolean | Record<string, unknown>>;
|
|
107
|
+
baseUrl?: string | Array<string>;
|
|
108
|
+
port?: number;
|
|
109
|
+
logger?: boolean | Record<string, any>;
|
|
110
|
+
metrics?: boolean | Record<string, any>;
|
|
111
|
+
enableMicroFrontendDebug?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export declare type DevProxyOptions = string | Record<string, string>;
|
|
114
|
+
export interface DevConfig {
|
|
115
|
+
assetPrefix?: string | boolean;
|
|
116
|
+
https?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The configuration of `dev.proxy` is provided by plugin `@modern-js/plugin-proxy`.
|
|
119
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
120
|
+
* @requires `@modern-js/plugin-proxy`
|
|
121
|
+
*/
|
|
122
|
+
proxy?: DevProxyOptions;
|
|
123
|
+
/**
|
|
124
|
+
* The configuration of `dev.unbundle` is provided by plugin `@modern-js/plugin-unbundle`.
|
|
125
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
126
|
+
* @requires `@modern-js/plugin-unbundle`
|
|
127
|
+
*/
|
|
128
|
+
unbundle?: UnbundleConfig;
|
|
129
|
+
}
|
|
130
|
+
export interface MicroFrontend {
|
|
131
|
+
enableHtmlEntry?: boolean;
|
|
132
|
+
externalBasicLibrary?: boolean;
|
|
133
|
+
moduleApp?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface DeployConfig {
|
|
136
|
+
microFrontend?: false | MicroFrontend;
|
|
137
|
+
domain?: string | Array<string>;
|
|
138
|
+
domainByEntries?: Record<string, string | Array<string>>;
|
|
139
|
+
}
|
|
140
|
+
declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>, utils?: any) => Record<string, unknown> | void);
|
|
141
|
+
export declare type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
|
|
142
|
+
export declare type DevServerConfig = {
|
|
143
|
+
proxy?: BffProxyOptions;
|
|
144
|
+
headers?: Record<string, string>;
|
|
145
|
+
before?: RequestHandler[];
|
|
146
|
+
after?: RequestHandler[];
|
|
147
|
+
[propsName: string]: any;
|
|
148
|
+
};
|
|
149
|
+
export declare type WebpackConfig = WebpackConfiguration | ((config: WebpackConfiguration, utils: {
|
|
150
|
+
env: string;
|
|
151
|
+
webpack: typeof webpack;
|
|
152
|
+
[key: string]: any;
|
|
153
|
+
}) => WebpackConfiguration | void);
|
|
154
|
+
export declare type BabelConfig = TransformOptions | ((config: TransformOptions, utils?: any) => TransformOptions | void);
|
|
155
|
+
export declare type AutoprefixerConfig = AutoprefixerOptions | ((config: AutoprefixerOptions) => AutoprefixerOptions | void);
|
|
156
|
+
export declare type TerserConfig = TerserOptions | ((config: TerserOptions) => TerserOptions | void);
|
|
157
|
+
export interface ToolsConfig {
|
|
158
|
+
webpack?: WebpackConfig;
|
|
159
|
+
babel?: BabelConfig;
|
|
160
|
+
autoprefixer?: AutoprefixerConfig;
|
|
161
|
+
postcss?: ConfigFunction;
|
|
162
|
+
styledComponents?: ConfigFunction;
|
|
163
|
+
lodash?: ConfigFunction;
|
|
164
|
+
devServer?: DevServerConfig;
|
|
165
|
+
tsLoader?: ConfigFunction;
|
|
166
|
+
terser?: TerserConfig;
|
|
167
|
+
minifyCss?: ConfigFunction;
|
|
168
|
+
esbuild?: Record<string, unknown>;
|
|
169
|
+
/**
|
|
170
|
+
* The configuration of `tools.tailwindcss` is provided by plugin `@modern-js/plugin-tailwindcss`.
|
|
171
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
172
|
+
* @requires `@modern-js/plugin-tailwindcss`
|
|
173
|
+
*/
|
|
174
|
+
tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
|
175
|
+
/**
|
|
176
|
+
* The configuration of `tools.jest` is provided by plugin `@modern-js/plugin-testing`.
|
|
177
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
178
|
+
* @requires `@modern-js/plugin-testing`
|
|
179
|
+
*/
|
|
180
|
+
jest?: TestConfig['jest'];
|
|
181
|
+
/**
|
|
182
|
+
* The configuration of `tools.sass` is provided by plugin `@modern-js/plugin-sass`.
|
|
183
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
184
|
+
* @requires `@modern-js/plugin-sass`
|
|
185
|
+
*/
|
|
186
|
+
sass?: SassConfig;
|
|
187
|
+
/**
|
|
188
|
+
* The configuration of `tools.less` is provided by plugin `@modern-js/plugin-less`.
|
|
189
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
190
|
+
* @requires `@modern-js/plugin-less`
|
|
191
|
+
*/
|
|
192
|
+
less?: LessConfig;
|
|
193
|
+
}
|
|
194
|
+
export declare type RuntimeConfig = Record<string, any>;
|
|
195
|
+
export interface RuntimeByEntriesConfig {
|
|
196
|
+
[name: string]: RuntimeConfig;
|
|
197
|
+
}
|
|
198
|
+
export declare type BffConfig = Partial<{
|
|
199
|
+
prefix: string;
|
|
200
|
+
requestCreator: string;
|
|
201
|
+
fetcher: string;
|
|
202
|
+
proxy: Record<string, any>;
|
|
203
|
+
}>;
|
|
204
|
+
export interface UserConfig {
|
|
205
|
+
source?: SourceConfig;
|
|
206
|
+
output?: OutputConfig;
|
|
207
|
+
server?: ServerConfig;
|
|
208
|
+
dev?: DevConfig;
|
|
209
|
+
deploy?: DeployConfig;
|
|
210
|
+
tools?: ToolsConfig;
|
|
211
|
+
plugins?: PluginConfig;
|
|
212
|
+
runtime?: RuntimeConfig;
|
|
213
|
+
runtimeByEntries?: RuntimeByEntriesConfig;
|
|
214
|
+
/**
|
|
215
|
+
* The configuration of `bff` is provided by plugin `@modern-js/plugin-bff`.
|
|
216
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
217
|
+
* @requires `@modern-js/plugin-bff`
|
|
218
|
+
*/
|
|
219
|
+
bff?: BffConfig;
|
|
220
|
+
/**
|
|
221
|
+
* The configuration of `testing` is provided by plugin `@modern-js/plugin-testing`.
|
|
222
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
223
|
+
* @requires `@modern-js/plugin-testing`
|
|
224
|
+
*/
|
|
225
|
+
testing?: TestConfig;
|
|
226
|
+
/**
|
|
227
|
+
* The configuration of `electron` is provided by plugin `@modern-js/plugin-electron`.
|
|
228
|
+
* Please use `yarn new` to enable the corresponding capability.
|
|
229
|
+
* @requires `@modern-js/plugin-electron`
|
|
230
|
+
*/
|
|
231
|
+
electron?: ElectronConfig;
|
|
232
|
+
}
|
|
233
|
+
export declare type ConfigParam = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
|
|
234
|
+
export interface LoadedConfig {
|
|
235
|
+
config: UserConfig;
|
|
236
|
+
filePath: string | false;
|
|
237
|
+
dependencies: string[];
|
|
238
|
+
pkgConfig: UserConfig;
|
|
239
|
+
jsConfig: UserConfig;
|
|
240
|
+
}
|
|
@@ -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);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare type SSGRouteOptions = string | {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
url: string;
|
|
3
|
+
output?: string;
|
|
4
|
+
params?: Record<string, any>[];
|
|
5
|
+
headers?: Record<string, any>;
|
|
6
6
|
};
|
|
7
7
|
export declare type SSGSingleEntryOptions = boolean | {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
preventDefault?: string[];
|
|
9
|
+
headers?: Record<string, any>;
|
|
10
|
+
routes?: SSGRouteOptions[];
|
|
11
11
|
};
|
|
12
12
|
export declare type SSGMultiEntryOptions = Record<string, SSGSingleEntryOptions>;
|
|
13
|
-
export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string) => SSGSingleEntryOptions);
|
|
13
|
+
export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string) => SSGSingleEntryOptions);
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
ignoreModuleCache?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* clears cache of downloaded esm modules (from PDN) on dev start.
|
|
18
|
+
* default: false
|
|
19
|
+
*/
|
|
20
|
+
clearPdnCache?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* modifies host to attempt to download esm modules from
|
|
23
|
+
*/
|
|
24
|
+
pdnHost?: string;
|
|
25
|
+
};
|
|
@@ -10,38 +10,28 @@ export declare const ResolvedConfigContext: import("@modern-js/plugin").Context<
|
|
|
10
10
|
* Set app context.
|
|
11
11
|
* @param value new app context. It will override previous app context.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
13
|
export declare const setAppContext: (value: IAppContext) => void;
|
|
15
14
|
/**
|
|
16
15
|
* Get app context, including directories, plugins and some static infos.
|
|
17
16
|
*/
|
|
18
|
-
|
|
19
17
|
export declare const useAppContext: () => IAppContext;
|
|
20
18
|
/**
|
|
21
19
|
* Get original content of user config.
|
|
22
20
|
*/
|
|
23
|
-
|
|
24
21
|
export declare const useConfigContext: () => UserConfig;
|
|
25
22
|
/**
|
|
26
23
|
* Get normalized content of user config.
|
|
27
24
|
*/
|
|
28
|
-
|
|
29
25
|
export declare const useResolvedConfigContext: () => NormalizedConfig;
|
|
30
|
-
export declare const initAppContext: ({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
srcDir?: string | undefined;
|
|
43
|
-
distDir?: string | undefined;
|
|
44
|
-
sharedDir?: string | undefined;
|
|
45
|
-
} | undefined;
|
|
46
|
-
serverConfigFile: string;
|
|
47
|
-
}) => IAppContext;
|
|
26
|
+
export declare const initAppContext: ({ appDirectory, plugins, configFile, options, serverConfigFile, }: {
|
|
27
|
+
appDirectory: string;
|
|
28
|
+
plugins: LoadedPlugin[];
|
|
29
|
+
configFile: string | false;
|
|
30
|
+
options?: {
|
|
31
|
+
metaName?: string | undefined;
|
|
32
|
+
srcDir?: string | undefined;
|
|
33
|
+
distDir?: string | undefined;
|
|
34
|
+
sharedDir?: string | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
serverConfigFile: string;
|
|
37
|
+
}) => IAppContext;
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
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.initAppContext = exports.useResolvedConfigContext = exports.useConfigContext = exports.useAppContext = exports.setAppContext = exports.ResolvedConfigContext = exports.ConfigContext = exports.AppContext = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const utils_1 = require("@modern-js/utils");
|
|
9
|
+
const plugin_1 = require("@modern-js/plugin");
|
|
10
|
+
exports.AppContext = (0, plugin_1.createContext)({});
|
|
11
|
+
exports.ConfigContext = (0, plugin_1.createContext)({});
|
|
12
|
+
exports.ResolvedConfigContext = (0, plugin_1.createContext)({});
|
|
13
|
+
/**
|
|
14
|
+
* Set app context.
|
|
15
|
+
* @param value new app context. It will override previous app context.
|
|
16
|
+
*/
|
|
17
|
+
const setAppContext = (value) => exports.AppContext.set(value);
|
|
18
|
+
exports.setAppContext = setAppContext;
|
|
19
|
+
/**
|
|
20
|
+
* Get app context, including directories, plugins and some static infos.
|
|
21
|
+
*/
|
|
22
|
+
const useAppContext = () => exports.AppContext.use().value;
|
|
23
|
+
exports.useAppContext = useAppContext;
|
|
24
|
+
/**
|
|
25
|
+
* Get original content of user config.
|
|
26
|
+
*/
|
|
27
|
+
const useConfigContext = () => exports.ConfigContext.use().value;
|
|
28
|
+
exports.useConfigContext = useConfigContext;
|
|
29
|
+
/**
|
|
30
|
+
* Get normalized content of user config.
|
|
31
|
+
*/
|
|
32
|
+
const useResolvedConfigContext = () => exports.ResolvedConfigContext.use().value;
|
|
33
|
+
exports.useResolvedConfigContext = useResolvedConfigContext;
|
|
34
|
+
const initAppContext = ({ appDirectory, plugins, configFile, options, serverConfigFile, }) => {
|
|
35
|
+
const { metaName = 'modern-js', srcDir = 'src', distDir = '', sharedDir = 'shared', } = options || {};
|
|
36
|
+
return {
|
|
37
|
+
metaName,
|
|
38
|
+
appDirectory,
|
|
39
|
+
configFile,
|
|
40
|
+
serverConfigFile,
|
|
41
|
+
ip: utils_1.address.ip(),
|
|
42
|
+
port: 0,
|
|
43
|
+
packageName: require(path_1.default.resolve(appDirectory, './package.json')).name,
|
|
44
|
+
srcDirectory: path_1.default.resolve(appDirectory, srcDir),
|
|
45
|
+
distDirectory: distDir,
|
|
46
|
+
sharedDirectory: path_1.default.resolve(appDirectory, sharedDir),
|
|
47
|
+
nodeModulesDirectory: path_1.default.resolve(appDirectory, './node_modules'),
|
|
48
|
+
internalDirectory: path_1.default.resolve(appDirectory, `./node_modules/.${metaName}`),
|
|
49
|
+
plugins,
|
|
50
|
+
htmlTemplates: {},
|
|
51
|
+
serverRoutes: [],
|
|
52
|
+
entrypoints: [],
|
|
53
|
+
checkedEntries: [],
|
|
54
|
+
apiOnly: false,
|
|
55
|
+
internalDirAlias: `@_${metaName.replace(/-/g, '_')}_internal`,
|
|
56
|
+
internalSrcAlias: `@_${metaName.replace(/-/g, '_')}_src`,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.initAppContext = initAppContext;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { INTERNAL_PLUGINS } from '@modern-js/utils';
|
|
2
|
+
import type { Hooks } from '@modern-js/types';
|
|
3
|
+
import type { ErrorObject } from '../compiled/ajv';
|
|
4
|
+
import { TransformPlugin } from './loadPlugins';
|
|
5
|
+
import { IAppContext, initAppContext } from './context';
|
|
6
|
+
import type { NormalizedConfig } from './config/mergeConfig';
|
|
7
|
+
export type { Hooks };
|
|
8
|
+
export * from './config';
|
|
9
|
+
export * from '@modern-js/plugin';
|
|
10
|
+
export * from '@modern-js/plugin/node';
|
|
11
|
+
export { manager, mountHook, usePlugins, createPlugin, registerHook, } from './manager';
|
|
12
|
+
export type { CliHooks, CliPlugin, CliHookCallbacks } from './manager';
|
|
13
|
+
export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, } from './pluginAPI';
|
|
14
|
+
export type { PluginAPI } from './pluginAPI';
|
|
15
|
+
export type { NormalizedConfig, IAppContext };
|
|
16
|
+
declare const initAppDir: (cwd?: string | undefined) => Promise<string>;
|
|
17
|
+
export interface CoreOptions {
|
|
18
|
+
configFile?: string;
|
|
19
|
+
serverConfigFile?: string;
|
|
20
|
+
packageJsonConfig?: string;
|
|
21
|
+
plugins?: typeof INTERNAL_PLUGINS;
|
|
22
|
+
transformPlugin?: TransformPlugin;
|
|
23
|
+
onSchemaError?: (error: ErrorObject) => void;
|
|
24
|
+
options?: {
|
|
25
|
+
metaName?: string;
|
|
26
|
+
srcDir?: string;
|
|
27
|
+
distDir?: string;
|
|
28
|
+
sharedDir?: string;
|
|
29
|
+
};
|
|
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
|
+
};
|
|
50
|
+
export declare const cli: {
|
|
51
|
+
init: (argv?: string[], options?: CoreOptions | undefined) => Promise<{
|
|
52
|
+
loadedConfig: import("./config").LoadedConfig;
|
|
53
|
+
appContext: IAppContext;
|
|
54
|
+
resolved: NormalizedConfig;
|
|
55
|
+
}>;
|
|
56
|
+
run: (argv: string[], options?: CoreOptions | undefined) => Promise<void>;
|
|
57
|
+
restart: () => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
export { initAppDir, initAppContext };
|
|
60
|
+
declare module '@modern-js/utils/compiled/commander' {
|
|
61
|
+
interface Command {
|
|
62
|
+
commandsMap: Map<string, Command>;
|
|
63
|
+
}
|
|
64
|
+
}
|