@modern-js/core 1.13.1 → 1.14.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/CHANGELOG.md +42 -0
- package/dist/bin.js +12 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +17 -8
- package/dist/config/mergeConfig.js +9 -3
- package/dist/config/schema/index.d.ts +4 -1
- package/dist/config/schema/server.d.ts +3 -0
- package/dist/config/schema/server.js +1 -0
- package/dist/config/types/index.d.ts +4 -11
- package/dist/index.d.ts +1 -1
- package/package.json +6 -8
- package/compiled/ajv/codegen.js +0 -1
- package/compiled/ajv/index.js +0 -9
- package/compiled/ajv/license +0 -22
- package/compiled/ajv/package.json +0 -1
- package/compiled/ajv/types/ajv.d.ts +0 -16
- package/compiled/ajv/types/compile/codegen/code.d.ts +0 -40
- package/compiled/ajv/types/compile/codegen/index.d.ts +0 -79
- package/compiled/ajv/types/compile/codegen/scope.d.ts +0 -79
- package/compiled/ajv/types/compile/errors.d.ts +0 -13
- package/compiled/ajv/types/compile/index.d.ts +0 -80
- package/compiled/ajv/types/compile/ref_error.d.ts +0 -6
- package/compiled/ajv/types/compile/resolve.d.ts +0 -12
- package/compiled/ajv/types/compile/rules.d.ts +0 -28
- package/compiled/ajv/types/compile/util.d.ts +0 -40
- package/compiled/ajv/types/compile/validate/index.d.ts +0 -42
- package/compiled/ajv/types/compile/validate/subschema.d.ts +0 -47
- package/compiled/ajv/types/core.d.ts +0 -173
- package/compiled/ajv/types/runtime/validation_error.d.ts +0 -7
- package/compiled/ajv/types/types/index.d.ts +0 -183
- package/compiled/ajv/types/types/json-schema.d.ts +0 -124
- package/compiled/ajv/types/types/jtd-schema.d.ts +0 -169
- package/compiled/ajv/uri-js/dist/es5/uri.all.d.ts +0 -59
- package/compiled/ajv-keywords/index.d.ts +0 -1
- package/compiled/ajv-keywords/index.js +0 -1
- package/compiled/ajv-keywords/license +0 -21
- package/compiled/ajv-keywords/package.json +0 -1
- package/compiled/better-ajv-errors/index.d.ts +0 -1
- package/compiled/better-ajv-errors/index.js +0 -1
- package/compiled/better-ajv-errors/license +0 -13
- package/compiled/better-ajv-errors/package.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 1.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7b9067f: add babel plugin for web builder
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 22f4dca: chore: move pre-bundled ajv to @modern-js/utils
|
|
12
|
+
|
|
13
|
+
chore: 预打包的 ajv 产物移动至 @modern-js/utils 内
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [79e83ef]
|
|
16
|
+
- Updated dependencies [3c20a5e]
|
|
17
|
+
- Updated dependencies [22f4dca]
|
|
18
|
+
- Updated dependencies [7b9067f]
|
|
19
|
+
- @modern-js/utils@1.9.0
|
|
20
|
+
- @modern-js/node-bundle-require@1.3.8
|
|
21
|
+
|
|
22
|
+
## 1.13.3
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- f4822c0: feat(app-tools): start and inspect command support specify config file
|
|
27
|
+
|
|
28
|
+
feat(app-tools): start 和 inspect 命令支持指定配置文件
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [4f1889d]
|
|
31
|
+
- @modern-js/utils@1.8.1
|
|
32
|
+
|
|
33
|
+
## 1.13.2
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- bfc1264: fix(core): should keep single function value after merge config
|
|
38
|
+
|
|
39
|
+
fix(core): 修复合并配置后,函数类型的配置项变成数组类型的问题
|
|
40
|
+
|
|
41
|
+
- 44e3bb1: feat: support response headers
|
|
42
|
+
feat: 支持设置响应头
|
|
43
|
+
- @modern-js/utils@1.8.0
|
|
44
|
+
|
|
3
45
|
## 1.13.1
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
package/dist/bin.js
CHANGED
|
@@ -23,7 +23,18 @@ const cliParams = (0, utils_1.minimist)(process.argv.slice(2));
|
|
|
23
23
|
const runOptions = {
|
|
24
24
|
version,
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Commands that support specify config files
|
|
28
|
+
* Some commands can't support this feature, such as `new`
|
|
29
|
+
*/
|
|
30
|
+
const SUPPORT_CONFIG_PARAM_COMMANDS = [
|
|
31
|
+
'dev',
|
|
32
|
+
'build',
|
|
33
|
+
'deploy',
|
|
34
|
+
'start',
|
|
35
|
+
'inspect',
|
|
36
|
+
];
|
|
37
|
+
if (SUPPORT_CONFIG_PARAM_COMMANDS.includes(command) && cliParams.config) {
|
|
27
38
|
runOptions.configFile = cliParams.config;
|
|
28
39
|
}
|
|
29
40
|
_1.cli.run(process.argv.slice(2), runOptions);
|
package/dist/config/index.d.ts
CHANGED
package/dist/config/index.js
CHANGED
|
@@ -10,20 +10,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
16
|
-
var
|
|
17
|
-
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
18
27
|
};
|
|
19
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
29
|
exports.resolveConfig = exports.loadUserConfig = exports.assignPkgConfig = exports.defineConfig = exports.addServerConfigToDeps = exports.defaultsConfig = void 0;
|
|
21
30
|
const utils_1 = require("@modern-js/utils");
|
|
22
31
|
const lodash_1 = require("@modern-js/utils/lodash");
|
|
23
32
|
const load_configs_1 = require("../load-configs");
|
|
24
|
-
const ajv_1 = __importDefault(require("../../compiled/ajv"));
|
|
25
|
-
const ajv_keywords_1 = __importDefault(require("../../compiled/ajv-keywords"));
|
|
26
|
-
const better_ajv_errors_1 = __importDefault(require("../../compiled/better-ajv-errors"));
|
|
27
33
|
const repeatKeyWarning_1 = require("../utils/repeatKeyWarning");
|
|
28
34
|
const defaults_1 = require("./defaults");
|
|
29
35
|
Object.defineProperty(exports, "defaultsConfig", { enumerable: true, get: function () { return defaults_1.defaults; } });
|
|
@@ -89,9 +95,12 @@ const showAdditionalPropertiesError = async (error) => {
|
|
|
89
95
|
};
|
|
90
96
|
const resolveConfig = async (loaded, configs, schemas, restartWithExistingPort, argv, onSchemaError = showAdditionalPropertiesError) => {
|
|
91
97
|
var _a, _b;
|
|
98
|
+
const { default: Ajv } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils/ajv')));
|
|
99
|
+
const { default: ajvKeywords } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils/ajv-keywords')));
|
|
100
|
+
const { default: betterAjvErrors } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils/better-ajv-errors')));
|
|
92
101
|
const { config: userConfig, jsConfig, pkgConfig } = loaded;
|
|
93
|
-
const ajv = new
|
|
94
|
-
(
|
|
102
|
+
const ajv = new Ajv({ $data: true, strict: false });
|
|
103
|
+
ajvKeywords(ajv);
|
|
95
104
|
const validateSchema = (0, schema_1.patchSchema)(schemas);
|
|
96
105
|
const validate = ajv.compile(validateSchema);
|
|
97
106
|
(0, repeatKeyWarning_1.repeatKeyWarning)(validateSchema, jsConfig, pkgConfig);
|
|
@@ -99,7 +108,7 @@ const resolveConfig = async (loaded, configs, schemas, restartWithExistingPort,
|
|
|
99
108
|
const valid = validate(userConfig);
|
|
100
109
|
if (!valid && ((_a = validate.errors) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
101
110
|
await onSchemaError(validate === null || validate === void 0 ? void 0 : validate.errors[0]);
|
|
102
|
-
const errors = (
|
|
111
|
+
const errors = betterAjvErrors(validateSchema, userConfig, (_b = validate.errors) === null || _b === void 0 ? void 0 : _b.map(e => ({
|
|
103
112
|
...e,
|
|
104
113
|
dataPath: e.instancePath,
|
|
105
114
|
})), {
|
|
@@ -22,11 +22,17 @@ const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target
|
|
|
22
22
|
return [...target, ...source];
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
return
|
|
25
|
+
return source !== undefined ? [...target, source] : target;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
else if ((0, utils_1.isFunction)(source)) {
|
|
29
|
-
|
|
28
|
+
else if ((0, utils_1.isFunction)(target) || (0, utils_1.isFunction)(source)) {
|
|
29
|
+
if (source === undefined) {
|
|
30
|
+
return target;
|
|
31
|
+
}
|
|
32
|
+
if (target === undefined) {
|
|
33
|
+
return source;
|
|
34
|
+
}
|
|
35
|
+
return [target, source];
|
|
30
36
|
}
|
|
31
37
|
return undefined;
|
|
32
38
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JSONSchemaType } from '
|
|
1
|
+
import type { JSONSchemaType } from '@modern-js/utils/ajv';
|
|
2
2
|
export interface PluginValidateSchema {
|
|
3
3
|
target: string;
|
|
4
4
|
schema: JSONSchemaType<any>;
|
|
@@ -340,6 +340,9 @@ export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | P
|
|
|
340
340
|
disableSpa: {
|
|
341
341
|
type: string;
|
|
342
342
|
};
|
|
343
|
+
resHeaders: {
|
|
344
|
+
type: string;
|
|
345
|
+
};
|
|
343
346
|
};
|
|
344
347
|
additionalProperties: boolean;
|
|
345
348
|
};
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import type { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import type { NextFunction, BffProxyOptions } from '@modern-js/types';
|
|
4
4
|
import type { MetaOptions, ChainIdentifier, WatchOptions } from '@modern-js/utils';
|
|
5
|
-
import type {
|
|
5
|
+
import type { BabelConfig } from '@modern-js/babel-preset-app';
|
|
6
6
|
import type webpack from 'webpack';
|
|
7
7
|
import type { RuleSetRule, Configuration as WebpackConfiguration, WebpackPluginInstance } from 'webpack';
|
|
8
8
|
import type WebpackChain from '@modern-js/utils/webpack-chain';
|
|
9
9
|
import type autoprefixer from 'autoprefixer';
|
|
10
10
|
import type { BasePluginOptions, TerserOptions as RawTerserOptions } from 'terser-webpack-plugin';
|
|
11
11
|
import type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
|
|
12
|
+
import { TransformOptions } from '@babel/core';
|
|
12
13
|
import type { PluginConfig } from '../../loadPlugins';
|
|
13
14
|
import type { TestConfig, JestConfig } from './test';
|
|
14
15
|
import type { SassConfig, SassLoaderOptions } from './sass';
|
|
@@ -103,8 +104,9 @@ export interface OutputConfig {
|
|
|
103
104
|
}
|
|
104
105
|
export interface ServerConfig {
|
|
105
106
|
routes?: Record<string, string | string[] | {
|
|
106
|
-
route
|
|
107
|
+
route?: string | string[];
|
|
107
108
|
disableSpa?: boolean;
|
|
109
|
+
resHeaders?: Record<string, unknown>;
|
|
108
110
|
}>;
|
|
109
111
|
publicRoutes?: {
|
|
110
112
|
[filepath: string]: string;
|
|
@@ -186,15 +188,6 @@ export declare type TsLoaderConfigUtils = {
|
|
|
186
188
|
addExcludes: (excludes: string | RegExp | (string | RegExp)[]) => void;
|
|
187
189
|
};
|
|
188
190
|
export declare type TsLoaderConfig = TsLoaderOptions | ((config: TsLoaderOptions, utils: TsLoaderConfigUtils) => TsLoaderOptions | void);
|
|
189
|
-
export declare type BabelConfigUtils = {
|
|
190
|
-
addPlugins: (plugins: BabelPlugin[]) => void;
|
|
191
|
-
addPresets: (presets: BabelPlugin[]) => void;
|
|
192
|
-
addIncludes: (includes: string | RegExp | (string | RegExp)[]) => void;
|
|
193
|
-
addExcludes: (excludes: string | RegExp | (string | RegExp)[]) => void;
|
|
194
|
-
removePlugins: (plugins: string | string[]) => void;
|
|
195
|
-
removePresets: (presets: string | string[]) => void;
|
|
196
|
-
};
|
|
197
|
-
export declare type BabelConfig = TransformOptions | ((config: TransformOptions, utils: BabelConfigUtils) => TransformOptions | void);
|
|
198
191
|
export declare type AutoprefixerConfig = AutoprefixerOptions | ((config: AutoprefixerOptions) => AutoprefixerOptions | void);
|
|
199
192
|
export declare type TerserConfig = TerserOptions | ((config: TerserOptions) => TerserOptions | void);
|
|
200
193
|
export interface ToolsConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INTERNAL_PLUGINS } from '@modern-js/utils';
|
|
2
|
-
import type { ErrorObject } from '
|
|
2
|
+
import type { ErrorObject } from '@modern-js/utils/ajv';
|
|
3
3
|
import { TransformPlugin } from './loadPlugins';
|
|
4
4
|
import { IAppContext, initAppContext } from './context';
|
|
5
5
|
export * from './config';
|
package/package.json
CHANGED
|
@@ -6,12 +6,11 @@
|
|
|
6
6
|
"repository": "modern-js-dev/modern.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"keywords": [
|
|
9
|
-
"react",
|
|
10
9
|
"framework",
|
|
11
10
|
"modern",
|
|
12
11
|
"modern.js"
|
|
13
12
|
],
|
|
14
|
-
"version": "1.
|
|
13
|
+
"version": "1.14.0",
|
|
15
14
|
"jsnext:source": "./src/index.ts",
|
|
16
15
|
"types": "./dist/index.d.ts",
|
|
17
16
|
"main": "./dist/index.js",
|
|
@@ -39,13 +38,14 @@
|
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
41
|
+
"@modern-js/node-bundle-require": "^1.3.8",
|
|
42
42
|
"@modern-js/plugin": "^1.4.2",
|
|
43
|
-
"@modern-js/utils": "^1.
|
|
44
|
-
"@modern-js/node-bundle-require": "^1.3.7"
|
|
43
|
+
"@modern-js/utils": "^1.9.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@jest/types": "^27.0.6",
|
|
48
|
-
"@modern-js/
|
|
47
|
+
"@modern-js/babel-preset-app": "1.6.0",
|
|
48
|
+
"@modern-js/types": "1.6.2",
|
|
49
49
|
"@scripts/build": "0.0.0",
|
|
50
50
|
"@scripts/jest-config": "0.0.0",
|
|
51
51
|
"@types/babel__code-frame": "^7.0.3",
|
|
@@ -53,14 +53,12 @@
|
|
|
53
53
|
"@types/jest": "^27",
|
|
54
54
|
"@types/less": "^3.0.3",
|
|
55
55
|
"@types/node": "^14",
|
|
56
|
-
"@types/react": "^17",
|
|
57
|
-
"@types/react-dom": "^17",
|
|
58
56
|
"autoprefixer": "^10.3.1",
|
|
59
57
|
"btsm": "2.2.2",
|
|
58
|
+
"electron-builder": "22.7.0",
|
|
60
59
|
"jest": "^27",
|
|
61
60
|
"postcss": "^8.4.14",
|
|
62
61
|
"sass": "^1.45.0",
|
|
63
|
-
"electron-builder": "22.7.0",
|
|
64
62
|
"terser-webpack-plugin": "^5.1.4",
|
|
65
63
|
"typescript": "^4",
|
|
66
64
|
"webpack": "^5.71.0"
|
package/compiled/ajv/codegen.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./').codegen;
|