@modern-js/core 1.9.2 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/compiled/ajv/package.json +1 -1
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/ajv.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/codegen/code.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/codegen/index.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/codegen/scope.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/errors.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/index.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/ref_error.d.ts +0 -0
- package/compiled/ajv/{dist → types}/compile/resolve.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/rules.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/util.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/validate/index.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/compile/validate/subschema.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/core.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/runtime/validation_error.d.ts +0 -0
- package/compiled/ajv/{dist → types}/types/index.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/types/json-schema.d.ts +0 -0
- package/compiled/{ajv-keywords/ajv/dist → ajv/types}/types/jtd-schema.d.ts +0 -0
- package/compiled/ajv-keywords/index.d.ts +1 -0
- package/compiled/ajv-keywords/package.json +1 -1
- package/compiled/better-ajv-errors/index.d.ts +1 -0
- package/compiled/better-ajv-errors/package.json +1 -1
- package/compiled/v8-compile-cache/index.d.ts +1 -0
- package/compiled/v8-compile-cache/package.json +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +19 -28
- package/dist/config/mergeConfig.js +5 -1
- package/dist/config/types/index.d.ts +37 -37
- package/dist/index.js +55 -60
- package/dist/initWatcher.js +3 -12
- package/dist/loadPlugins.d.ts +1 -1
- package/package.json +34 -13
- package/.eslintrc.js +0 -9
- package/compiled/ajv/dist/ajv.d.ts +0 -16
- package/compiled/ajv/dist/compile/codegen/code.d.ts +0 -40
- package/compiled/ajv/dist/compile/codegen/index.d.ts +0 -79
- package/compiled/ajv/dist/compile/codegen/scope.d.ts +0 -79
- package/compiled/ajv/dist/compile/errors.d.ts +0 -13
- package/compiled/ajv/dist/compile/index.d.ts +0 -80
- package/compiled/ajv/dist/compile/ref_error.d.ts +0 -6
- package/compiled/ajv/dist/compile/rules.d.ts +0 -28
- package/compiled/ajv/dist/compile/util.d.ts +0 -40
- package/compiled/ajv/dist/compile/validate/index.d.ts +0 -42
- package/compiled/ajv/dist/compile/validate/subschema.d.ts +0 -47
- package/compiled/ajv/dist/core.d.ts +0 -173
- package/compiled/ajv/dist/runtime/validation_error.d.ts +0 -7
- package/compiled/ajv/dist/types/json-schema.d.ts +0 -124
- package/compiled/ajv/dist/types/jtd-schema.d.ts +0 -169
- package/compiled/ajv-keywords/ajv/dist/compile/resolve.d.ts +0 -12
- package/compiled/ajv-keywords/ajv/dist/types/index.d.ts +0 -183
- package/compiled/ajv-keywords/dist/index.d.ts +0 -4
- package/compiled/ajv-keywords/uri-js/dist/es5/uri.all.d.ts +0 -59
- package/compiled/better-ajv-errors/ajv/dist/ajv.d.ts +0 -16
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/code.d.ts +0 -40
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/index.d.ts +0 -79
- package/compiled/better-ajv-errors/ajv/dist/compile/codegen/scope.d.ts +0 -79
- package/compiled/better-ajv-errors/ajv/dist/compile/errors.d.ts +0 -13
- package/compiled/better-ajv-errors/ajv/dist/compile/index.d.ts +0 -80
- package/compiled/better-ajv-errors/ajv/dist/compile/ref_error.d.ts +0 -6
- package/compiled/better-ajv-errors/ajv/dist/compile/resolve.d.ts +0 -12
- package/compiled/better-ajv-errors/ajv/dist/compile/rules.d.ts +0 -28
- package/compiled/better-ajv-errors/ajv/dist/compile/util.d.ts +0 -40
- package/compiled/better-ajv-errors/ajv/dist/compile/validate/index.d.ts +0 -42
- package/compiled/better-ajv-errors/ajv/dist/compile/validate/subschema.d.ts +0 -47
- package/compiled/better-ajv-errors/ajv/dist/core.d.ts +0 -173
- package/compiled/better-ajv-errors/ajv/dist/runtime/validation_error.d.ts +0 -7
- package/compiled/better-ajv-errors/ajv/dist/types/index.d.ts +0 -183
- package/compiled/better-ajv-errors/ajv/dist/types/json-schema.d.ts +0 -124
- package/compiled/better-ajv-errors/ajv/dist/types/jtd-schema.d.ts +0 -169
- package/compiled/better-ajv-errors/typings.d.ts +0 -24
- package/compiled/better-ajv-errors/uri-js/dist/es5/uri.all.d.ts +0 -59
- 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/index.d.ts +0 -12
- 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/ssg.d.ts +0 -13
- package/dist/types/config/types/test.d.ts +0 -15
- package/dist/types/config/types/unbundle.d.ts +0 -28
- package/dist/types/context.d.ts +0 -47
- package/dist/types/index.d.ts +0 -64
- package/dist/types/initWatcher.d.ts +0 -3
- package/dist/types/loadEnv.d.ts +0 -1
- package/dist/types/loadPlugins.d.ts +0 -44
- package/dist/types/manager.d.ts +0 -75
- package/dist/types/pluginAPI.d.ts +0 -13
- package/dist/types/utils/commander.d.ts +0 -4
- package/dist/types/utils/repeatKeyWarning.d.ts +0 -3
- package/jest.config.js +0 -7
- package/tsconfig.json +0 -11
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export interface URIComponents {
|
|
2
|
-
scheme?: string;
|
|
3
|
-
userinfo?: string;
|
|
4
|
-
host?: string;
|
|
5
|
-
port?: number | string;
|
|
6
|
-
path?: string;
|
|
7
|
-
query?: string;
|
|
8
|
-
fragment?: string;
|
|
9
|
-
reference?: string;
|
|
10
|
-
error?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface URIOptions {
|
|
13
|
-
scheme?: string;
|
|
14
|
-
reference?: string;
|
|
15
|
-
tolerant?: boolean;
|
|
16
|
-
absolutePath?: boolean;
|
|
17
|
-
iri?: boolean;
|
|
18
|
-
unicodeSupport?: boolean;
|
|
19
|
-
domainHost?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface URISchemeHandler<Components extends URIComponents = URIComponents, Options extends URIOptions = URIOptions, ParentComponents extends URIComponents = URIComponents> {
|
|
22
|
-
scheme: string;
|
|
23
|
-
parse(components: ParentComponents, options: Options): Components;
|
|
24
|
-
serialize(components: Components, options: Options): ParentComponents;
|
|
25
|
-
unicodeSupport?: boolean;
|
|
26
|
-
domainHost?: boolean;
|
|
27
|
-
absolutePath?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface URIRegExps {
|
|
30
|
-
NOT_SCHEME: RegExp;
|
|
31
|
-
NOT_USERINFO: RegExp;
|
|
32
|
-
NOT_HOST: RegExp;
|
|
33
|
-
NOT_PATH: RegExp;
|
|
34
|
-
NOT_PATH_NOSCHEME: RegExp;
|
|
35
|
-
NOT_QUERY: RegExp;
|
|
36
|
-
NOT_FRAGMENT: RegExp;
|
|
37
|
-
ESCAPE: RegExp;
|
|
38
|
-
UNRESERVED: RegExp;
|
|
39
|
-
OTHER_CHARS: RegExp;
|
|
40
|
-
PCT_ENCODED: RegExp;
|
|
41
|
-
IPV4ADDRESS: RegExp;
|
|
42
|
-
IPV6ADDRESS: RegExp;
|
|
43
|
-
}
|
|
44
|
-
export declare const SCHEMES: {
|
|
45
|
-
[scheme: string]: URISchemeHandler;
|
|
46
|
-
};
|
|
47
|
-
export declare function pctEncChar(chr: string): string;
|
|
48
|
-
export declare function pctDecChars(str: string): string;
|
|
49
|
-
export declare function parse(uriString: string, options?: URIOptions): URIComponents;
|
|
50
|
-
export declare function removeDotSegments(input: string): string;
|
|
51
|
-
export declare function serialize(components: URIComponents, options?: URIOptions): string;
|
|
52
|
-
export declare function resolveComponents(base: URIComponents, relative: URIComponents, options?: URIOptions, skipNormalization?: boolean): URIComponents;
|
|
53
|
-
export declare function resolve(baseURI: string, relativeURI: string, options?: URIOptions): string;
|
|
54
|
-
export declare function normalize(uri: string, options?: URIOptions): string;
|
|
55
|
-
export declare function normalize(uri: URIComponents, options?: URIOptions): URIComponents;
|
|
56
|
-
export declare function equal(uriA: string, uriB: string, options?: URIOptions): boolean;
|
|
57
|
-
export declare function equal(uriA: URIComponents, uriB: URIComponents, options?: URIOptions): boolean;
|
|
58
|
-
export declare function escapeComponent(str: string, options?: URIOptions): string;
|
|
59
|
-
export declare function unescapeComponent(str: string, options?: URIOptions): string;
|
package/dist/js/modern/cli.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// 这个文件跟 bin/modern-js.js 基本一样
|
|
2
|
-
// 在开发阶段,因为 package.json 的 exports['./bin']['jsnext:source'] 配置
|
|
3
|
-
// 了这个文件,所以需要保留, 后续如果找到更好的方式之后会移除这个文件
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { cli } from ".";
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
version
|
|
9
|
-
} = require("../../package.json"); // XXX: 通过这个方式去掉了 package.json 里面对于 @modern-js/module-tools 的 devDependencies 依赖
|
|
10
|
-
// 然后可以正常的执行 modern build
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const kModuleToolsCliPath = path.resolve(__dirname, '../../../solutions/module-tools/src/index.ts');
|
|
14
|
-
process.env.MODERN_JS_VERSION = version;
|
|
15
|
-
|
|
16
|
-
if (!process.env.NODE_ENV) {
|
|
17
|
-
process.env.NODE_ENV = // eslint-disable-next-line no-nested-ternary
|
|
18
|
-
['build', 'start', 'deploy'].includes(process.argv[2]) ? 'production' : process.argv[2] === 'test' ? 'test' : 'development';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
cli.run(process.argv.slice(2), {
|
|
22
|
-
plugins: {
|
|
23
|
-
'@modern-js/module-tools': {
|
|
24
|
-
cli: kModuleToolsCliPath,
|
|
25
|
-
// 是否需要强制加载这个组件,跳过 loadPlugins 里面 filter 的检测逻辑
|
|
26
|
-
forced: true
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
const sourceDefaults = {
|
|
2
|
-
entries: undefined,
|
|
3
|
-
disableDefaultEntries: false,
|
|
4
|
-
entriesDir: './src',
|
|
5
|
-
configDir: './config',
|
|
6
|
-
apiDir: './api',
|
|
7
|
-
envVars: [],
|
|
8
|
-
globalVars: undefined,
|
|
9
|
-
alias: undefined,
|
|
10
|
-
moduleScopes: undefined,
|
|
11
|
-
include: []
|
|
12
|
-
};
|
|
13
|
-
const outputDefaults = {
|
|
14
|
-
assetPrefix: '/',
|
|
15
|
-
htmlPath: 'html',
|
|
16
|
-
jsPath: 'static/js',
|
|
17
|
-
cssPath: 'static/css',
|
|
18
|
-
mediaPath: 'static/media',
|
|
19
|
-
path: 'dist',
|
|
20
|
-
title: '',
|
|
21
|
-
titleByEntries: undefined,
|
|
22
|
-
meta: {
|
|
23
|
-
charset: {
|
|
24
|
-
charset: 'utf-8'
|
|
25
|
-
},
|
|
26
|
-
viewport: 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
|
|
27
|
-
'http-equiv': {
|
|
28
|
-
'http-equiv': 'x-ua-compatible',
|
|
29
|
-
content: 'ie=edge'
|
|
30
|
-
},
|
|
31
|
-
renderer: 'webkit',
|
|
32
|
-
layoutmode: 'standard',
|
|
33
|
-
imagemode: 'force',
|
|
34
|
-
'wap-font-scale': 'no',
|
|
35
|
-
'format-detection': 'telephone=no'
|
|
36
|
-
},
|
|
37
|
-
metaByEntries: undefined,
|
|
38
|
-
inject: 'head',
|
|
39
|
-
injectByEntries: undefined,
|
|
40
|
-
mountId: 'root',
|
|
41
|
-
favicon: '',
|
|
42
|
-
faviconByEntries: undefined,
|
|
43
|
-
copy: undefined,
|
|
44
|
-
scriptExt: undefined,
|
|
45
|
-
disableHtmlFolder: false,
|
|
46
|
-
disableCssModuleExtension: false,
|
|
47
|
-
disableCssExtract: false,
|
|
48
|
-
enableCssModuleTSDeclaration: false,
|
|
49
|
-
disableMinimize: false,
|
|
50
|
-
enableInlineStyles: false,
|
|
51
|
-
enableInlineScripts: false,
|
|
52
|
-
disableSourceMap: false,
|
|
53
|
-
disableInlineRuntimeChunk: false,
|
|
54
|
-
disableAssetsCache: false,
|
|
55
|
-
enableLatestDecorators: false,
|
|
56
|
-
polyfill: 'entry',
|
|
57
|
-
dataUriLimit: 10000,
|
|
58
|
-
templateParameters: {},
|
|
59
|
-
templateParametersByEntries: undefined,
|
|
60
|
-
cssModuleLocalIdentName: '[name]__[local]--[hash:base64:5]',
|
|
61
|
-
enableModernMode: false,
|
|
62
|
-
federation: undefined,
|
|
63
|
-
disableNodePolyfill: false,
|
|
64
|
-
enableTsLoader: false
|
|
65
|
-
};
|
|
66
|
-
const serverDefaults = {
|
|
67
|
-
routes: undefined,
|
|
68
|
-
publicRoutes: undefined,
|
|
69
|
-
ssr: undefined,
|
|
70
|
-
ssrByEntries: undefined,
|
|
71
|
-
baseUrl: '/',
|
|
72
|
-
port: 8080
|
|
73
|
-
};
|
|
74
|
-
const devDefaults = {
|
|
75
|
-
assetPrefix: false,
|
|
76
|
-
https: false
|
|
77
|
-
};
|
|
78
|
-
const deployDefaults = {
|
|
79
|
-
domain: '',
|
|
80
|
-
domainByEntries: undefined
|
|
81
|
-
};
|
|
82
|
-
const toolsDefaults = {
|
|
83
|
-
webpack: undefined,
|
|
84
|
-
babel: undefined,
|
|
85
|
-
postcss: undefined,
|
|
86
|
-
autoprefixer: undefined,
|
|
87
|
-
lodash: undefined,
|
|
88
|
-
devServer: undefined,
|
|
89
|
-
tsLoader: undefined,
|
|
90
|
-
terser: undefined,
|
|
91
|
-
minifyCss: undefined
|
|
92
|
-
};
|
|
93
|
-
export const defaults = {
|
|
94
|
-
source: sourceDefaults,
|
|
95
|
-
output: outputDefaults,
|
|
96
|
-
server: serverDefaults,
|
|
97
|
-
dev: devDefaults,
|
|
98
|
-
deploy: deployDefaults,
|
|
99
|
-
tools: toolsDefaults,
|
|
100
|
-
plugins: [],
|
|
101
|
-
runtime: {},
|
|
102
|
-
runtimeByEntries: {}
|
|
103
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
|
-
import { loadConfig } from '@modern-js/load-config';
|
|
8
|
-
import Ajv from 'ajv';
|
|
9
|
-
import ajvKeywords from 'ajv-keywords';
|
|
10
|
-
import { signale as logger, createDebugger, getPort, isDev, PLUGIN_SCHEMAS, chalk, getServerConfig } from '@modern-js/utils';
|
|
11
|
-
import { mergeWith } from '@modern-js/utils/lodash';
|
|
12
|
-
import betterAjvErrors from 'better-ajv-errors';
|
|
13
|
-
import { codeFrameColumns } from '@babel/code-frame';
|
|
14
|
-
import { repeatKeyWarning } from "../utils/repeatKeyWarning";
|
|
15
|
-
import { defaults } from "./defaults";
|
|
16
|
-
import { mergeConfig } from "./mergeConfig";
|
|
17
|
-
import { patchSchema } from "./schema";
|
|
18
|
-
const debug = createDebugger('resolve-config');
|
|
19
|
-
export { defaults as defaultsConfig };
|
|
20
|
-
export { mergeConfig };
|
|
21
|
-
export * from "./types";
|
|
22
|
-
export const addServerConfigToDeps = async (dependencies, appDirectory, serverConfigFile) => {
|
|
23
|
-
const serverConfig = await getServerConfig(appDirectory, serverConfigFile);
|
|
24
|
-
|
|
25
|
-
if (serverConfig) {
|
|
26
|
-
dependencies.push(serverConfig);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
export const defineConfig = config => config;
|
|
30
|
-
export const loadUserConfig = async (appDirectory, filePath, packageJsonConfig) => {
|
|
31
|
-
const loaded = await loadConfig(appDirectory, filePath, packageJsonConfig);
|
|
32
|
-
const config = !loaded ? {} : await (typeof loaded.config === 'function' ? loaded.config(0) : loaded.config);
|
|
33
|
-
return {
|
|
34
|
-
config: mergeWith({}, config || {}, (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {}),
|
|
35
|
-
jsConfig: config || {},
|
|
36
|
-
pkgConfig: (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {},
|
|
37
|
-
filePath: loaded === null || loaded === void 0 ? void 0 : loaded.path,
|
|
38
|
-
dependencies: (loaded === null || loaded === void 0 ? void 0 : loaded.dependencies) || []
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const showAdditionalPropertiesError = error => {
|
|
43
|
-
if (error.keyword === 'additionalProperties' && error.params.additionalProperty) {
|
|
44
|
-
const target = [error.instancePath.slice(1), error.params.additionalProperty].filter(Boolean).join('.');
|
|
45
|
-
const name = Object.keys(PLUGIN_SCHEMAS).find(key => PLUGIN_SCHEMAS[key].some(schemaItem => schemaItem.target === target));
|
|
46
|
-
|
|
47
|
-
if (name) {
|
|
48
|
-
logger.warn(`The configuration of ${chalk.bold(target)} is provided by plugin ${chalk.bold(name)}. Please use ${chalk.bold('yarn new')} to enable the corresponding capability.\n`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const resolveConfig = async (loaded, configs, schemas, restartWithExistingPort, argv, onSchemaError = showAdditionalPropertiesError) => {
|
|
54
|
-
var _validate$errors;
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
config: userConfig,
|
|
58
|
-
jsConfig,
|
|
59
|
-
pkgConfig
|
|
60
|
-
} = loaded;
|
|
61
|
-
const ajv = new Ajv({
|
|
62
|
-
$data: true,
|
|
63
|
-
strict: false
|
|
64
|
-
});
|
|
65
|
-
ajvKeywords(ajv);
|
|
66
|
-
const validateSchema = patchSchema(schemas);
|
|
67
|
-
const validate = ajv.compile(validateSchema);
|
|
68
|
-
repeatKeyWarning(validateSchema, jsConfig, pkgConfig); // validate user config.
|
|
69
|
-
|
|
70
|
-
const valid = validate(userConfig);
|
|
71
|
-
|
|
72
|
-
if (!valid && (_validate$errors = validate.errors) !== null && _validate$errors !== void 0 && _validate$errors.length) {
|
|
73
|
-
var _validate$errors2;
|
|
74
|
-
|
|
75
|
-
onSchemaError(validate === null || validate === void 0 ? void 0 : validate.errors[0]);
|
|
76
|
-
const errors = betterAjvErrors(validateSchema, userConfig, (_validate$errors2 = validate.errors) === null || _validate$errors2 === void 0 ? void 0 : _validate$errors2.map(e => _objectSpread(_objectSpread({}, e), {}, {
|
|
77
|
-
dataPath: e.instancePath
|
|
78
|
-
})), {
|
|
79
|
-
format: 'js',
|
|
80
|
-
indent: 2
|
|
81
|
-
});
|
|
82
|
-
logger.log(codeFrameColumns(JSON.stringify(userConfig, null, 2), {
|
|
83
|
-
start: errors === null || errors === void 0 ? void 0 : errors[0].start,
|
|
84
|
-
end: errors === null || errors === void 0 ? void 0 : errors[0].end
|
|
85
|
-
}, {
|
|
86
|
-
highlightCode: true,
|
|
87
|
-
message: errors === null || errors === void 0 ? void 0 : errors[0].error
|
|
88
|
-
}));
|
|
89
|
-
throw new Error(`Validate configuration error`);
|
|
90
|
-
} // validate config from plugins.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
for (const config of configs) {
|
|
94
|
-
if (!validate(config)) {
|
|
95
|
-
logger.error(validate.errors);
|
|
96
|
-
throw new Error(`Validate configuration error.`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const resolved = mergeConfig([defaults, ...configs, userConfig]);
|
|
101
|
-
resolved._raw = loaded.config;
|
|
102
|
-
|
|
103
|
-
if (isDev() && argv[0] === 'dev') {
|
|
104
|
-
if (restartWithExistingPort > 0) {
|
|
105
|
-
// dev server is restarted, should use existing port number
|
|
106
|
-
resolved.server.port = restartWithExistingPort;
|
|
107
|
-
} else {
|
|
108
|
-
// get port for new dev server
|
|
109
|
-
resolved.server.port = await getPort(resolved.server.port);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
debug('resolved %o', resolved);
|
|
114
|
-
return resolved;
|
|
115
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { mergeWith } from '@modern-js/utils/lodash';
|
|
2
|
-
import { isFunction } from '@modern-js/utils';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* merge configuration from modern.config.js and plugins.
|
|
6
|
-
*
|
|
7
|
-
* @param configs - Configuration from modern.config.ts or plugin's config hook.
|
|
8
|
-
* @returns - normalized user config.
|
|
9
|
-
*/
|
|
10
|
-
export const mergeConfig = configs => mergeWith({}, ...configs, (target, source) => {
|
|
11
|
-
if (Array.isArray(target)) {
|
|
12
|
-
if (Array.isArray(source)) {
|
|
13
|
-
return [...target, ...source];
|
|
14
|
-
} else {
|
|
15
|
-
return typeof source !== 'undefined' ? [...target, source] : target;
|
|
16
|
-
}
|
|
17
|
-
} else if (isFunction(source)) {
|
|
18
|
-
return typeof target !== 'undefined' ? [target, source] : [source];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return undefined;
|
|
22
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ENTRY_NAME_PATTERN } from '@modern-js/utils';
|
|
2
|
-
export const deploy = {
|
|
3
|
-
type: 'object',
|
|
4
|
-
properties: {
|
|
5
|
-
domain: {
|
|
6
|
-
type: ['array', 'string']
|
|
7
|
-
},
|
|
8
|
-
domainByEntries: {
|
|
9
|
-
type: 'object',
|
|
10
|
-
patternProperties: {
|
|
11
|
-
[ENTRY_NAME_PATTERN]: {
|
|
12
|
-
type: ['array', 'string']
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { isObject, createDebugger } from '@modern-js/utils';
|
|
2
|
-
import { cloneDeep } from '@modern-js/utils/lodash';
|
|
3
|
-
import { source } from "./source";
|
|
4
|
-
import { output } from "./output";
|
|
5
|
-
import { server } from "./server";
|
|
6
|
-
import { deploy } from "./deploy";
|
|
7
|
-
import { tools } from "./tools";
|
|
8
|
-
const debug = createDebugger('validate-schema');
|
|
9
|
-
const plugins = {
|
|
10
|
-
type: 'array',
|
|
11
|
-
additionalProperties: false
|
|
12
|
-
};
|
|
13
|
-
const dev = {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
assetPrefix: {
|
|
17
|
-
type: ['boolean', 'string']
|
|
18
|
-
},
|
|
19
|
-
https: {
|
|
20
|
-
type: 'boolean'
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
additionalProperties: false
|
|
24
|
-
};
|
|
25
|
-
export const patchSchema = pluginSchemas => {
|
|
26
|
-
const finalSchema = cloneDeep({
|
|
27
|
-
type: 'object',
|
|
28
|
-
additionalProperties: false,
|
|
29
|
-
properties: {
|
|
30
|
-
source,
|
|
31
|
-
output,
|
|
32
|
-
server,
|
|
33
|
-
deploy,
|
|
34
|
-
plugins,
|
|
35
|
-
dev,
|
|
36
|
-
tools
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const findTargetNode = props => {
|
|
41
|
-
let node = finalSchema.properties;
|
|
42
|
-
|
|
43
|
-
for (const prop of props) {
|
|
44
|
-
node = node[prop];
|
|
45
|
-
|
|
46
|
-
if (!node || !isObject(node)) {
|
|
47
|
-
throw new Error(`add schema ${props.join('.')} error`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
node.properties = node.hasOwnProperty('properties') ? node.properties : {};
|
|
51
|
-
node = node.properties;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return node;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const finalPluginSchemas = [];
|
|
58
|
-
pluginSchemas.forEach(item => {
|
|
59
|
-
if (Array.isArray(item)) {
|
|
60
|
-
finalPluginSchemas.push(...item);
|
|
61
|
-
} else {
|
|
62
|
-
finalPluginSchemas.push(item);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
for (const {
|
|
67
|
-
target,
|
|
68
|
-
schema
|
|
69
|
-
} of finalPluginSchemas) {
|
|
70
|
-
if (!target) {
|
|
71
|
-
throw new Error(`should return target property in plugin schema.`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const props = target.split('.');
|
|
75
|
-
const mountProperty = props.pop();
|
|
76
|
-
const targetNode = findTargetNode(props);
|
|
77
|
-
|
|
78
|
-
if (targetNode.hasOwnProperty(mountProperty)) {
|
|
79
|
-
throw new Error(`${target} already exists in current validate schema`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
targetNode[mountProperty] = cloneDeep(schema);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
debug(`final validate schema: %o`, finalSchema);
|
|
86
|
-
return finalSchema;
|
|
87
|
-
};
|
|
88
|
-
export const traverseSchema = schema => {
|
|
89
|
-
const keys = [];
|
|
90
|
-
|
|
91
|
-
const traverse = ({
|
|
92
|
-
properties
|
|
93
|
-
}, old = []) => {
|
|
94
|
-
for (const key of Object.keys(properties)) {
|
|
95
|
-
const current = [...old, key];
|
|
96
|
-
|
|
97
|
-
if (properties[key].type === 'object' && properties[key].properties) {
|
|
98
|
-
traverse(properties[key], current);
|
|
99
|
-
} else {
|
|
100
|
-
keys.push(current.join('.'));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
traverse(schema);
|
|
106
|
-
return keys;
|
|
107
|
-
};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { ENTRY_NAME_PATTERN } from '@modern-js/utils';
|
|
2
|
-
export const output = {
|
|
3
|
-
type: 'object',
|
|
4
|
-
additionalProperties: false,
|
|
5
|
-
properties: {
|
|
6
|
-
assetPrefix: {
|
|
7
|
-
type: 'string'
|
|
8
|
-
},
|
|
9
|
-
path: {
|
|
10
|
-
type: 'string'
|
|
11
|
-
},
|
|
12
|
-
jsPath: {
|
|
13
|
-
type: 'string'
|
|
14
|
-
},
|
|
15
|
-
cssPath: {
|
|
16
|
-
type: 'string'
|
|
17
|
-
},
|
|
18
|
-
htmlPath: {
|
|
19
|
-
type: 'string'
|
|
20
|
-
},
|
|
21
|
-
mediaPath: {
|
|
22
|
-
type: 'string'
|
|
23
|
-
},
|
|
24
|
-
mountId: {
|
|
25
|
-
type: 'string'
|
|
26
|
-
},
|
|
27
|
-
favicon: {
|
|
28
|
-
type: 'string'
|
|
29
|
-
},
|
|
30
|
-
faviconByEntries: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
patternProperties: {
|
|
33
|
-
[ENTRY_NAME_PATTERN]: {
|
|
34
|
-
type: 'string'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
title: {
|
|
39
|
-
type: 'string'
|
|
40
|
-
},
|
|
41
|
-
titleByEntries: {
|
|
42
|
-
type: 'object',
|
|
43
|
-
patternProperties: {
|
|
44
|
-
[ENTRY_NAME_PATTERN]: {
|
|
45
|
-
type: 'string'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
meta: {
|
|
50
|
-
type: 'object'
|
|
51
|
-
},
|
|
52
|
-
metaByEntries: {
|
|
53
|
-
type: 'object',
|
|
54
|
-
patternProperties: {
|
|
55
|
-
[ENTRY_NAME_PATTERN]: {
|
|
56
|
-
type: 'object'
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
inject: {
|
|
61
|
-
enum: [true, 'head', 'body', false]
|
|
62
|
-
},
|
|
63
|
-
injectByEntries: {
|
|
64
|
-
type: 'object',
|
|
65
|
-
patternProperties: {
|
|
66
|
-
[ENTRY_NAME_PATTERN]: {
|
|
67
|
-
enum: [true, 'head', 'body', false]
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
copy: {
|
|
72
|
-
type: 'array'
|
|
73
|
-
},
|
|
74
|
-
scriptExt: {
|
|
75
|
-
type: 'object'
|
|
76
|
-
},
|
|
77
|
-
disableTsChecker: {
|
|
78
|
-
type: 'boolean'
|
|
79
|
-
},
|
|
80
|
-
disableHtmlFolder: {
|
|
81
|
-
type: 'boolean'
|
|
82
|
-
},
|
|
83
|
-
disableCssModuleExtension: {
|
|
84
|
-
type: 'boolean'
|
|
85
|
-
},
|
|
86
|
-
disableCssExtract: {
|
|
87
|
-
type: 'boolean'
|
|
88
|
-
},
|
|
89
|
-
enableCssModuleTSDeclaration: {
|
|
90
|
-
type: 'boolean'
|
|
91
|
-
},
|
|
92
|
-
disableMinimize: {
|
|
93
|
-
type: 'boolean'
|
|
94
|
-
},
|
|
95
|
-
enableInlineStyles: {
|
|
96
|
-
type: 'boolean'
|
|
97
|
-
},
|
|
98
|
-
enableInlineScripts: {
|
|
99
|
-
type: 'boolean'
|
|
100
|
-
},
|
|
101
|
-
disableSourceMap: {
|
|
102
|
-
type: 'boolean'
|
|
103
|
-
},
|
|
104
|
-
disableInlineRuntimeChunk: {
|
|
105
|
-
type: 'boolean'
|
|
106
|
-
},
|
|
107
|
-
disableAssetsCache: {
|
|
108
|
-
type: 'boolean'
|
|
109
|
-
},
|
|
110
|
-
enableLatestDecorators: {
|
|
111
|
-
type: 'boolean'
|
|
112
|
-
},
|
|
113
|
-
enableTsLoader: {
|
|
114
|
-
type: 'boolean'
|
|
115
|
-
},
|
|
116
|
-
dataUriLimit: {
|
|
117
|
-
type: 'number'
|
|
118
|
-
},
|
|
119
|
-
templateParameters: {
|
|
120
|
-
type: 'object'
|
|
121
|
-
},
|
|
122
|
-
templateParametersByEntries: {
|
|
123
|
-
type: 'object',
|
|
124
|
-
patternProperties: {
|
|
125
|
-
[ENTRY_NAME_PATTERN]: {
|
|
126
|
-
type: 'object'
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
polyfill: {
|
|
131
|
-
type: 'string',
|
|
132
|
-
enum: ['usage', 'entry', 'off', 'ua']
|
|
133
|
-
},
|
|
134
|
-
cssModuleLocalIdentName: {
|
|
135
|
-
type: 'string'
|
|
136
|
-
},
|
|
137
|
-
federation: {
|
|
138
|
-
type: 'object'
|
|
139
|
-
},
|
|
140
|
-
disableNodePolyfill: {
|
|
141
|
-
type: 'boolean'
|
|
142
|
-
},
|
|
143
|
-
enableModernMode: {
|
|
144
|
-
type: 'boolean'
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
};
|