@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
package/package.json
CHANGED
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.9.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
|
-
"main": "./dist/
|
|
18
|
-
"module": "./dist/
|
|
19
|
-
"jsnext:modern": "./dist/
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"jsnext:modern": "./dist/index.js",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
22
|
"node": {
|
|
23
23
|
"jsnext:source": "./src/index.ts",
|
|
24
|
-
"import": "./dist/
|
|
25
|
-
"require": "./dist/
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
-
"default": "./dist/
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
28
|
},
|
|
29
29
|
"./bin": {
|
|
30
30
|
"jsnext:source": "./src/cli.ts",
|
|
@@ -34,28 +34,19 @@
|
|
|
34
34
|
"typesVersions": {
|
|
35
35
|
"*": {
|
|
36
36
|
"config": [
|
|
37
|
-
"./dist/
|
|
37
|
+
"./dist/config/index.d.ts"
|
|
38
38
|
]
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"bin": "./bin/modern-js.js",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@babel/code-frame": "^7.14.5",
|
|
44
|
-
"@babel/runtime": "^7",
|
|
45
43
|
"@modern-js/load-config": "^1.3.1",
|
|
46
44
|
"@modern-js/plugin": "^1.3.3",
|
|
47
|
-
"@modern-js/utils": "^1.
|
|
48
|
-
"address": "^1.1.2",
|
|
49
|
-
"ajv": "^8.6.2",
|
|
50
|
-
"ajv-keywords": "^5.0.0",
|
|
51
|
-
"better-ajv-errors": "1.2.0",
|
|
52
|
-
"dotenv": "^10.0.0",
|
|
53
|
-
"dotenv-expand": "^5.1.0",
|
|
54
|
-
"v8-compile-cache": "^2.3.0"
|
|
45
|
+
"@modern-js/utils": "^1.6.0"
|
|
55
46
|
},
|
|
56
47
|
"devDependencies": {
|
|
57
48
|
"@jest/types": "^27.0.6",
|
|
58
|
-
"@modern-js/types": "
|
|
49
|
+
"@modern-js/types": "1.5.1",
|
|
59
50
|
"@scripts/build": "0.0.0",
|
|
60
51
|
"@scripts/jest-config": "0.0.0",
|
|
61
52
|
"@types/babel__code-frame": "^7.0.3",
|
|
@@ -76,19 +67,14 @@
|
|
|
76
67
|
"webpack-chain": "^6.5.1"
|
|
77
68
|
},
|
|
78
69
|
"sideEffects": false,
|
|
79
|
-
"modernConfig": {
|
|
80
|
-
"output": {
|
|
81
|
-
"packageMode": "node-js"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
70
|
"publishConfig": {
|
|
85
71
|
"registry": "https://registry.npmjs.org/",
|
|
86
72
|
"access": "public"
|
|
87
73
|
},
|
|
88
74
|
"scripts": {
|
|
89
75
|
"new": "modern new",
|
|
90
|
-
"build": "
|
|
91
|
-
"dev": "
|
|
76
|
+
"build": "tsc",
|
|
77
|
+
"dev": "tsc --watch",
|
|
92
78
|
"test": "jest"
|
|
93
79
|
},
|
|
94
80
|
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "@modern-js/tsconfig/base",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"declaration":
|
|
5
|
-
"
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"outDir": "./dist",
|
|
6
6
|
"baseUrl": "./",
|
|
7
7
|
"isolatedModules": true,
|
|
8
|
-
"esModuleInterop": true
|
|
9
|
-
"paths": {}
|
|
8
|
+
"esModuleInterop": true
|
|
10
9
|
},
|
|
11
10
|
"include": ["src"]
|
|
12
11
|
}
|
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
|
-
};
|