@modern-js/core 1.0.0-alpha.3
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 +10 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/bin/modern-js.js +18 -0
- package/dist/js/modern/config/defaults.js +102 -0
- package/dist/js/modern/config/index.js +104 -0
- package/dist/js/modern/config/mergeConfig.js +20 -0
- package/dist/js/modern/config/schema/deploy.js +34 -0
- package/dist/js/modern/config/schema/index.js +104 -0
- package/dist/js/modern/config/schema/output.js +147 -0
- package/dist/js/modern/config/schema/server.js +167 -0
- package/dist/js/modern/config/schema/source.js +59 -0
- package/dist/js/modern/config/schema/tools.js +33 -0
- package/dist/js/modern/context.js +25 -0
- package/dist/js/modern/index.js +137 -0
- package/dist/js/modern/initWatcher.js +51 -0
- package/dist/js/modern/loadEnv.js +12 -0
- package/dist/js/modern/loadPlugins.js +66 -0
- package/dist/js/modern/utils/commander.js +19 -0
- package/dist/js/modern/utils/repeatKeyWarning.js +18 -0
- package/dist/js/node/config/defaults.js +109 -0
- package/dist/js/node/config/index.js +142 -0
- package/dist/js/node/config/mergeConfig.js +32 -0
- package/dist/js/node/config/schema/deploy.js +43 -0
- package/dist/js/node/config/schema/index.js +126 -0
- package/dist/js/node/config/schema/output.js +156 -0
- package/dist/js/node/config/schema/server.js +176 -0
- package/dist/js/node/config/schema/source.js +68 -0
- package/dist/js/node/config/schema/tools.js +40 -0
- package/dist/js/node/context.js +52 -0
- package/dist/js/node/index.js +212 -0
- package/dist/js/node/initWatcher.js +72 -0
- package/dist/js/node/loadEnv.js +28 -0
- package/dist/js/node/loadPlugins.js +76 -0
- package/dist/js/node/utils/commander.js +35 -0
- package/dist/js/node/utils/repeatKeyWarning.js +31 -0
- package/dist/types/config/defaults.d.ts +27 -0
- package/dist/types/config/index.d.ts +125 -0
- package/dist/types/config/mergeConfig.d.ts +29 -0
- package/dist/types/config/schema/deploy.d.ts +33 -0
- package/dist/types/config/schema/index.d.ts +474 -0
- package/dist/types/config/schema/output.d.ts +146 -0
- package/dist/types/config/schema/server.d.ts +179 -0
- package/dist/types/config/schema/source.d.ts +58 -0
- package/dist/types/config/schema/tools.d.ts +33 -0
- package/dist/types/context.d.ts +20 -0
- package/dist/types/index.d.ts +86 -0
- package/dist/types/initWatcher.d.ts +4 -0
- package/dist/types/loadEnv.d.ts +1 -0
- package/dist/types/loadPlugins.d.ts +16 -0
- package/dist/types/utils/commander.d.ts +7 -0
- package/dist/types/utils/repeatKeyWarning.d.ts +3 -0
- package/modern.config.js +13 -0
- package/package.json +73 -0
- package/src/config/defaults.ts +104 -0
- package/src/config/index.ts +296 -0
- package/src/config/mergeConfig.ts +68 -0
- package/src/config/schema/deploy.ts +23 -0
- package/src/config/schema/index.ts +111 -0
- package/src/config/schema/output.ts +66 -0
- package/src/config/schema/server.ts +105 -0
- package/src/config/schema/source.ts +34 -0
- package/src/config/schema/tools.ts +15 -0
- package/src/context.ts +46 -0
- package/src/index.ts +240 -0
- package/src/initWatcher.ts +81 -0
- package/src/loadEnv.ts +21 -0
- package/src/loadPlugins.ts +81 -0
- package/src/types.d.ts +0 -0
- package/src/utils/commander.ts +22 -0
- package/src/utils/repeatKeyWarning.ts +29 -0
- package/tests/fixtures/load-plugin/not-found/package.json +3 -0
- package/tests/fixtures/load-plugin/not-found/test-plugin-a.js +1 -0
- package/tests/fixtures/load-plugin/user-plugins/package.json +3 -0
- package/tests/fixtures/load-plugin/user-plugins/test-plugin-a.js +1 -0
- package/tests/fixtures/load-plugin/user-plugins/test-plugin-b.js +3 -0
- package/tests/loadEnv.test.ts +100 -0
- package/tests/loadPlugin.test.ts +29 -0
- package/tests/mergeConfig.test.ts +78 -0
- package/tests/repeatKeyWarning.test.ts +68 -0
- package/tests/schema.test.ts +109 -0
- package/tests/tsconfig.json +13 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "defaultsConfig", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _defaults.defaults;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.resolveConfig = exports.loadUserConfig = exports.defineConfig = void 0;
|
|
13
|
+
|
|
14
|
+
var _loadConfig = require("@modern-js/load-config");
|
|
15
|
+
|
|
16
|
+
var _ajv = _interopRequireDefault(require("ajv"));
|
|
17
|
+
|
|
18
|
+
var _ajvKeywords = _interopRequireDefault(require("ajv-keywords"));
|
|
19
|
+
|
|
20
|
+
var _signale = _interopRequireDefault(require("signale"));
|
|
21
|
+
|
|
22
|
+
var _utils = require("@modern-js/utils");
|
|
23
|
+
|
|
24
|
+
var _lodash = _interopRequireDefault(require("lodash.mergewith"));
|
|
25
|
+
|
|
26
|
+
var _betterAjvErrors = _interopRequireDefault(require("better-ajv-errors"));
|
|
27
|
+
|
|
28
|
+
var _codeFrame = require("@babel/code-frame");
|
|
29
|
+
|
|
30
|
+
var _repeatKeyWarning = require("../utils/repeatKeyWarning");
|
|
31
|
+
|
|
32
|
+
var _defaults = require("./defaults");
|
|
33
|
+
|
|
34
|
+
var _mergeConfig = require("./mergeConfig");
|
|
35
|
+
|
|
36
|
+
var _schema = require("./schema");
|
|
37
|
+
|
|
38
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
|
+
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
45
|
+
|
|
46
|
+
const debug = (0, _utils.createDebugger)('resolve-config');
|
|
47
|
+
|
|
48
|
+
const defineConfig = config => config;
|
|
49
|
+
|
|
50
|
+
exports.defineConfig = defineConfig;
|
|
51
|
+
|
|
52
|
+
const loadUserConfig = async (appDirectory, filePath) => {
|
|
53
|
+
const loaded = (0, _loadConfig.loadConfig)(appDirectory, filePath);
|
|
54
|
+
const config = !loaded ? {} : await (typeof loaded.config === 'function' ? loaded.config(0) : loaded.config);
|
|
55
|
+
return {
|
|
56
|
+
config: (0, _lodash.default)({}, config || {}, (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {}),
|
|
57
|
+
jsConfig: config || {},
|
|
58
|
+
pkgConfig: (loaded === null || loaded === void 0 ? void 0 : loaded.pkgConfig) || {},
|
|
59
|
+
filePath: loaded === null || loaded === void 0 ? void 0 : loaded.path,
|
|
60
|
+
dependencies: (loaded === null || loaded === void 0 ? void 0 : loaded.dependencies) || []
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.loadUserConfig = loadUserConfig;
|
|
65
|
+
|
|
66
|
+
const showAdditionalPropertiesError = error => {
|
|
67
|
+
if (error.keyword === 'additionalProperties' && error.instancePath && error.params.additionalProperty) {
|
|
68
|
+
const target = `${error.instancePath.substr(1)}.${error.params.additionalProperty}`;
|
|
69
|
+
const name = Object.keys(_utils.PLUGIN_SCHEMAS).find(key => _utils.PLUGIN_SCHEMAS[key].some(schemaItem => schemaItem.target === target));
|
|
70
|
+
|
|
71
|
+
if (name) {
|
|
72
|
+
_signale.default.warn(`The configuration of ${_utils.chalk.bold(target)} is provided by plugin ${_utils.chalk.bold(name)}. Please use ${_utils.chalk.bold('yarn new')} to enable the corresponding capability.\n`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/* eslint-disable max-statements, max-params */
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const resolveConfig = async (loaded, configs, schemas, isRestart, argv) => {
|
|
80
|
+
var _validate$errors;
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
config: userConfig,
|
|
84
|
+
jsConfig,
|
|
85
|
+
pkgConfig
|
|
86
|
+
} = loaded;
|
|
87
|
+
const ajv = new _ajv.default({
|
|
88
|
+
$data: true,
|
|
89
|
+
strict: false
|
|
90
|
+
});
|
|
91
|
+
(0, _ajvKeywords.default)(ajv);
|
|
92
|
+
const validateSchema = (0, _schema.patchSchema)(schemas);
|
|
93
|
+
const validate = ajv.compile(validateSchema);
|
|
94
|
+
(0, _repeatKeyWarning.repeatKeyWarning)(validateSchema, jsConfig, pkgConfig); // validate user config.
|
|
95
|
+
|
|
96
|
+
const valid = validate(userConfig);
|
|
97
|
+
|
|
98
|
+
if (!valid && (_validate$errors = validate.errors) !== null && _validate$errors !== void 0 && _validate$errors.length) {
|
|
99
|
+
var _validate$errors2;
|
|
100
|
+
|
|
101
|
+
showAdditionalPropertiesError(validate === null || validate === void 0 ? void 0 : validate.errors[0]);
|
|
102
|
+
const errors = (0, _betterAjvErrors.default)(validateSchema, userConfig, (_validate$errors2 = validate.errors) === null || _validate$errors2 === void 0 ? void 0 : _validate$errors2.map(e => _objectSpread(_objectSpread({}, e), {}, {
|
|
103
|
+
dataPath: e.instancePath
|
|
104
|
+
})), {
|
|
105
|
+
format: 'js',
|
|
106
|
+
indent: 2
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
_signale.default.log((0, _codeFrame.codeFrameColumns)(JSON.stringify(userConfig, null, 2), {
|
|
110
|
+
start: errors === null || errors === void 0 ? void 0 : errors[0].start,
|
|
111
|
+
end: errors === null || errors === void 0 ? void 0 : errors[0].end
|
|
112
|
+
}, {
|
|
113
|
+
highlightCode: true,
|
|
114
|
+
message: errors === null || errors === void 0 ? void 0 : errors[0].error
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
throw new Error(`Validate configuration error`);
|
|
118
|
+
} // validate config from plugins.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
for (const config of configs) {
|
|
122
|
+
if (!validate(config)) {
|
|
123
|
+
_signale.default.error(validate.errors);
|
|
124
|
+
|
|
125
|
+
throw new Error(`Validate configuration error.`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const resolved = (0, _mergeConfig.mergeConfig)([_defaults.defaults, ...configs, userConfig]);
|
|
130
|
+
resolved._raw = loaded.config;
|
|
131
|
+
|
|
132
|
+
if ((0, _utils.isDev)() && argv[0] === 'dev' && !isRestart) {
|
|
133
|
+
resolved.server.port = await (0, _utils.getPort)(resolved.server.port);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
debug('resolved %o', resolved);
|
|
137
|
+
return resolved;
|
|
138
|
+
};
|
|
139
|
+
/* eslint-enable max-statements, max-params */
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
exports.resolveConfig = resolveConfig;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mergeConfig = void 0;
|
|
7
|
+
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.mergewith"));
|
|
9
|
+
|
|
10
|
+
var _utils = require("@modern-js/utils");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* merge configuration from modern.config.js and plugins.
|
|
16
|
+
*
|
|
17
|
+
* @param configs - Configuration from modern.config.ts or plugin's config hook.
|
|
18
|
+
* @returns - normalized user config.
|
|
19
|
+
*/
|
|
20
|
+
const mergeConfig = configs => (0, _lodash.default)({}, ...configs, (target, source) => {
|
|
21
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
22
|
+
return [...target, ...source];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if ((0, _utils.isFunction)(source)) {
|
|
26
|
+
return Array.isArray(target) ? [...target, source] : [target, source].filter(Boolean);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return undefined;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
exports.mergeConfig = mergeConfig;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deploy = void 0;
|
|
7
|
+
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
const deploy = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
microFrontend: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
dependencies: {
|
|
16
|
+
enableHtmlEntry: {
|
|
17
|
+
properties: {
|
|
18
|
+
enableLegacy: {
|
|
19
|
+
enum: [false]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
properties: {
|
|
25
|
+
enableHtmlEntry: {
|
|
26
|
+
type: 'boolean'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
domain: {
|
|
31
|
+
type: ['array', 'string']
|
|
32
|
+
},
|
|
33
|
+
domainByEntries: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
patternProperties: {
|
|
36
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
37
|
+
type: ['array', 'string']
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.deploy = deploy;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.traverseSchema = exports.patchSchema = void 0;
|
|
7
|
+
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
|
11
|
+
|
|
12
|
+
var _source = require("./source");
|
|
13
|
+
|
|
14
|
+
var _output = require("./output");
|
|
15
|
+
|
|
16
|
+
var _server = require("./server");
|
|
17
|
+
|
|
18
|
+
var _deploy = require("./deploy");
|
|
19
|
+
|
|
20
|
+
var _tools = require("./tools");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
const debug = (0, _utils.createDebugger)('validate-schema');
|
|
25
|
+
const plugins = {
|
|
26
|
+
type: 'array',
|
|
27
|
+
additionalProperties: false
|
|
28
|
+
};
|
|
29
|
+
const dev = {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
assetPrefix: {
|
|
33
|
+
type: ['boolean', 'string']
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
additionalProperties: false
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const patchSchema = pluginSchemas => {
|
|
40
|
+
const finalSchema = (0, _lodash.default)({
|
|
41
|
+
type: 'object',
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
properties: {
|
|
44
|
+
source: _source.source,
|
|
45
|
+
output: _output.output,
|
|
46
|
+
server: _server.server,
|
|
47
|
+
deploy: _deploy.deploy,
|
|
48
|
+
plugins,
|
|
49
|
+
dev,
|
|
50
|
+
tools: _tools.tools
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const findTargetNode = props => {
|
|
55
|
+
let node = finalSchema.properties;
|
|
56
|
+
|
|
57
|
+
for (const prop of props) {
|
|
58
|
+
node = node[prop];
|
|
59
|
+
|
|
60
|
+
if (!node || !(0, _utils.isObject)(node)) {
|
|
61
|
+
throw new Error(`add schema ${props.join('.')} error`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
node.properties = node.hasOwnProperty('properties') ? node.properties : {};
|
|
65
|
+
node = node.properties;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return node;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const finalPluginSchemas = [];
|
|
72
|
+
pluginSchemas.forEach(item => {
|
|
73
|
+
if (Array.isArray(item)) {
|
|
74
|
+
finalPluginSchemas.push(...item);
|
|
75
|
+
} else {
|
|
76
|
+
finalPluginSchemas.push(item);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
for (const {
|
|
81
|
+
target,
|
|
82
|
+
schema
|
|
83
|
+
} of finalPluginSchemas) {
|
|
84
|
+
if (!target) {
|
|
85
|
+
throw new Error(`should return target property in plugin schema.`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const props = target.split('.');
|
|
89
|
+
const mountProperty = props.pop();
|
|
90
|
+
const targetNode = findTargetNode(props);
|
|
91
|
+
|
|
92
|
+
if (targetNode.hasOwnProperty(mountProperty)) {
|
|
93
|
+
throw new Error(`${target} already exists in current validate schema`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
targetNode[mountProperty] = (0, _lodash.default)(schema);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
debug(`final validate schema: %o`, finalSchema);
|
|
100
|
+
return finalSchema;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
exports.patchSchema = patchSchema;
|
|
104
|
+
|
|
105
|
+
const traverseSchema = schema => {
|
|
106
|
+
const keys = [];
|
|
107
|
+
|
|
108
|
+
const traverse = ({
|
|
109
|
+
properties
|
|
110
|
+
}, old = []) => {
|
|
111
|
+
for (const key of Object.keys(properties)) {
|
|
112
|
+
const current = [...old, key];
|
|
113
|
+
|
|
114
|
+
if (properties[key].type === 'object' && properties[key].properties) {
|
|
115
|
+
traverse(properties[key], current);
|
|
116
|
+
} else {
|
|
117
|
+
keys.push(current.join('.'));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
traverse(schema);
|
|
123
|
+
return keys;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
exports.traverseSchema = traverseSchema;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.output = void 0;
|
|
7
|
+
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
const output = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
additionalProperties: false,
|
|
13
|
+
properties: {
|
|
14
|
+
assetPrefix: {
|
|
15
|
+
type: 'string'
|
|
16
|
+
},
|
|
17
|
+
path: {
|
|
18
|
+
type: 'string'
|
|
19
|
+
},
|
|
20
|
+
jsPath: {
|
|
21
|
+
type: 'string'
|
|
22
|
+
},
|
|
23
|
+
cssPath: {
|
|
24
|
+
type: 'string'
|
|
25
|
+
},
|
|
26
|
+
htmlPath: {
|
|
27
|
+
type: 'string'
|
|
28
|
+
},
|
|
29
|
+
mediaPath: {
|
|
30
|
+
type: 'string'
|
|
31
|
+
},
|
|
32
|
+
mountId: {
|
|
33
|
+
type: 'string'
|
|
34
|
+
},
|
|
35
|
+
favicon: {
|
|
36
|
+
type: 'string'
|
|
37
|
+
},
|
|
38
|
+
faviconByEntries: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
patternProperties: {
|
|
41
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
42
|
+
type: 'string'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
type: 'string'
|
|
48
|
+
},
|
|
49
|
+
titleByEntries: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
patternProperties: {
|
|
52
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
53
|
+
type: 'string'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
meta: {
|
|
58
|
+
type: 'object'
|
|
59
|
+
},
|
|
60
|
+
metaByEntries: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
patternProperties: {
|
|
63
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
64
|
+
type: 'object'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
inject: {
|
|
69
|
+
enum: [true, 'head', 'body', false]
|
|
70
|
+
},
|
|
71
|
+
injectByEntries: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
patternProperties: {
|
|
74
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
75
|
+
enum: [true, 'head', 'body', false]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
copy: {
|
|
80
|
+
type: 'array'
|
|
81
|
+
},
|
|
82
|
+
scriptExt: {
|
|
83
|
+
type: 'object'
|
|
84
|
+
},
|
|
85
|
+
disableHtmlFolder: {
|
|
86
|
+
type: 'boolean'
|
|
87
|
+
},
|
|
88
|
+
disableCssModuleExtension: {
|
|
89
|
+
type: 'boolean'
|
|
90
|
+
},
|
|
91
|
+
disableCssExtract: {
|
|
92
|
+
type: 'boolean'
|
|
93
|
+
},
|
|
94
|
+
enableCssModuleTSDeclaration: {
|
|
95
|
+
type: 'boolean'
|
|
96
|
+
},
|
|
97
|
+
disableMinimize: {
|
|
98
|
+
type: 'boolean'
|
|
99
|
+
},
|
|
100
|
+
enableInlineStyles: {
|
|
101
|
+
type: 'boolean'
|
|
102
|
+
},
|
|
103
|
+
enableInlineScripts: {
|
|
104
|
+
type: 'boolean'
|
|
105
|
+
},
|
|
106
|
+
disableSourceMap: {
|
|
107
|
+
type: 'boolean'
|
|
108
|
+
},
|
|
109
|
+
disableInlineRuntimeChunk: {
|
|
110
|
+
type: 'boolean'
|
|
111
|
+
},
|
|
112
|
+
disableAssetsCache: {
|
|
113
|
+
type: 'boolean'
|
|
114
|
+
},
|
|
115
|
+
enableLatestDecorators: {
|
|
116
|
+
type: 'boolean'
|
|
117
|
+
},
|
|
118
|
+
enableUsageBuiltIns: {
|
|
119
|
+
type: 'boolean'
|
|
120
|
+
},
|
|
121
|
+
enableTsLoader: {
|
|
122
|
+
type: 'boolean'
|
|
123
|
+
},
|
|
124
|
+
dataUriLimit: {
|
|
125
|
+
type: 'number'
|
|
126
|
+
},
|
|
127
|
+
templateParameters: {
|
|
128
|
+
type: 'object'
|
|
129
|
+
},
|
|
130
|
+
templateParametersByEntries: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
patternProperties: {
|
|
133
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
134
|
+
type: 'object'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
polyfill: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
enum: ['usage', 'entry', 'off', 'ua']
|
|
141
|
+
},
|
|
142
|
+
cssModuleLocalIdentName: {
|
|
143
|
+
type: 'string'
|
|
144
|
+
},
|
|
145
|
+
federation: {
|
|
146
|
+
type: 'object'
|
|
147
|
+
},
|
|
148
|
+
disableNodePolyfill: {
|
|
149
|
+
type: 'boolean'
|
|
150
|
+
},
|
|
151
|
+
enableModernMode: {
|
|
152
|
+
type: 'boolean'
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
exports.output = output;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.server = void 0;
|
|
7
|
+
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
const SERVER_ROUTE_OBJECT = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
path: {
|
|
14
|
+
type: 'string'
|
|
15
|
+
},
|
|
16
|
+
headers: {
|
|
17
|
+
type: 'object'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
additionalProperties: false
|
|
21
|
+
};
|
|
22
|
+
const server = {
|
|
23
|
+
type: 'object',
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
properties: {
|
|
26
|
+
port: {
|
|
27
|
+
type: 'number'
|
|
28
|
+
},
|
|
29
|
+
ssr: {
|
|
30
|
+
if: {
|
|
31
|
+
type: 'object'
|
|
32
|
+
},
|
|
33
|
+
then: {
|
|
34
|
+
properties: {
|
|
35
|
+
disableLoadable: {
|
|
36
|
+
type: 'boolean'
|
|
37
|
+
},
|
|
38
|
+
disableHelmet: {
|
|
39
|
+
type: 'boolean'
|
|
40
|
+
},
|
|
41
|
+
disableRedirect: {
|
|
42
|
+
type: 'boolean'
|
|
43
|
+
},
|
|
44
|
+
enableAsyncData: {
|
|
45
|
+
type: 'boolean'
|
|
46
|
+
},
|
|
47
|
+
enableProductWarning: {
|
|
48
|
+
type: 'boolean'
|
|
49
|
+
},
|
|
50
|
+
timeout: {
|
|
51
|
+
type: 'number'
|
|
52
|
+
},
|
|
53
|
+
asyncDataTimeout: {
|
|
54
|
+
type: 'number'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
else: {
|
|
59
|
+
type: 'boolean'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
ssrByEntries: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
patternProperties: {
|
|
65
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
66
|
+
if: {
|
|
67
|
+
type: 'object'
|
|
68
|
+
},
|
|
69
|
+
then: {
|
|
70
|
+
properties: {
|
|
71
|
+
disableLoadable: {
|
|
72
|
+
type: 'boolean'
|
|
73
|
+
},
|
|
74
|
+
disableHelmet: {
|
|
75
|
+
type: 'boolean'
|
|
76
|
+
},
|
|
77
|
+
disableRedirect: {
|
|
78
|
+
type: 'boolean'
|
|
79
|
+
},
|
|
80
|
+
enableProductWarning: {
|
|
81
|
+
type: 'boolean'
|
|
82
|
+
},
|
|
83
|
+
enableAsyncData: {
|
|
84
|
+
type: 'boolean'
|
|
85
|
+
},
|
|
86
|
+
timeout: {
|
|
87
|
+
type: 'number'
|
|
88
|
+
},
|
|
89
|
+
asyncDataTimeout: {
|
|
90
|
+
type: 'number'
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
additionalProperties: false
|
|
94
|
+
},
|
|
95
|
+
else: {
|
|
96
|
+
type: 'boolean'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
routes: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
patternProperties: {
|
|
104
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
105
|
+
if: {
|
|
106
|
+
type: 'object'
|
|
107
|
+
},
|
|
108
|
+
then: {
|
|
109
|
+
properties: {
|
|
110
|
+
route: {
|
|
111
|
+
oneOf: [{
|
|
112
|
+
type: 'string'
|
|
113
|
+
}, {
|
|
114
|
+
type: 'array',
|
|
115
|
+
items: {
|
|
116
|
+
oneOf: [{
|
|
117
|
+
type: 'string'
|
|
118
|
+
}, SERVER_ROUTE_OBJECT]
|
|
119
|
+
}
|
|
120
|
+
}, SERVER_ROUTE_OBJECT]
|
|
121
|
+
},
|
|
122
|
+
disableSpa: {
|
|
123
|
+
type: 'boolean'
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
additionalProperties: false
|
|
127
|
+
},
|
|
128
|
+
else: {
|
|
129
|
+
oneOf: [{
|
|
130
|
+
type: 'string'
|
|
131
|
+
}, {
|
|
132
|
+
type: 'array',
|
|
133
|
+
items: {
|
|
134
|
+
type: 'string'
|
|
135
|
+
}
|
|
136
|
+
}]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
publicRoutes: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
patternProperties: {
|
|
144
|
+
[_utils.ENTRY_NAME_PATTERN]: {
|
|
145
|
+
type: ['string']
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
baseUrl: {
|
|
150
|
+
oneOf: [{
|
|
151
|
+
type: 'string'
|
|
152
|
+
}, {
|
|
153
|
+
type: 'array',
|
|
154
|
+
items: [{
|
|
155
|
+
type: 'string'
|
|
156
|
+
}]
|
|
157
|
+
}]
|
|
158
|
+
},
|
|
159
|
+
middleware: {
|
|
160
|
+
instanceof: ['Array', 'Function']
|
|
161
|
+
},
|
|
162
|
+
renderHook: {
|
|
163
|
+
instanceof: 'Function'
|
|
164
|
+
},
|
|
165
|
+
logger: {
|
|
166
|
+
type: 'object'
|
|
167
|
+
},
|
|
168
|
+
measure: {
|
|
169
|
+
type: 'object'
|
|
170
|
+
},
|
|
171
|
+
proxy: {
|
|
172
|
+
type: 'object'
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
exports.server = server;
|