@modern-js/core 1.12.4 → 1.13.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 +46 -0
- package/dist/config/index.js +2 -2
- package/dist/config/mergeConfig.js +9 -3
- package/dist/config/schema/index.d.ts +6 -0
- package/dist/config/schema/server.d.ts +3 -0
- package/dist/config/schema/server.js +1 -0
- package/dist/config/schema/source.d.ts +3 -0
- package/dist/config/schema/source.js +1 -0
- package/dist/config/types/index.d.ts +3 -1
- package/dist/config/types/ssg.d.ts +3 -1
- package/dist/index.d.ts +3 -5
- package/dist/load-configs/index.d.ts +34 -0
- package/dist/load-configs/index.js +124 -0
- package/dist/manager.d.ts +9 -9
- package/dist/types/cli.d.ts +73 -0
- package/dist/types/cli.js +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +17 -0
- package/package.json +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 1.13.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bfc1264: fix(core): should keep single function value after merge config
|
|
8
|
+
|
|
9
|
+
fix(core): 修复合并配置后,函数类型的配置项变成数组类型的问题
|
|
10
|
+
|
|
11
|
+
- 44e3bb1: feat: support response headers
|
|
12
|
+
feat: 支持设置响应头
|
|
13
|
+
- @modern-js/utils@1.8.0
|
|
14
|
+
|
|
15
|
+
## 1.13.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 9d60891: feat(webpack): support source.preEntry config
|
|
20
|
+
|
|
21
|
+
feat(webpack): 新增 source.preEntry 配置项
|
|
22
|
+
|
|
23
|
+
- 5876e63: fix: the SSG callback is called once for each baseUrl, when a user configures multiple baseUrl.
|
|
24
|
+
fix: 当用户配置了多个 baseUrl 时,将会为每个 baseUrl 调用一次 SSG 回调函数。
|
|
25
|
+
- Updated dependencies [4fc801f]
|
|
26
|
+
- Updated dependencies [c8614b8]
|
|
27
|
+
- @modern-js/utils@1.8.0
|
|
28
|
+
|
|
29
|
+
## 1.13.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- 33cebd2: chore(core): move Hooks types define to `@modern-js/core`
|
|
34
|
+
|
|
35
|
+
chore(core): 移动 Hooks 类型定义到 `@modern-js/core` 包
|
|
36
|
+
|
|
37
|
+
- 33cebd2: chore(plugin-i18n): merge `@modern-js/i18n-cli-language-detector` to `@modern-js/plugin-i18n`
|
|
38
|
+
|
|
39
|
+
chore(plugin-i18n): 合并 `@modern-js/i18n-cli-language-detector` 包到 `@modern-js/plugin-i18n` 包作为子路径
|
|
40
|
+
|
|
41
|
+
- 33cebd2: chore(core): merge `@modern-js/load-config` package to `@modern-js/core` utils
|
|
42
|
+
|
|
43
|
+
chore(core): 合并 `@modern-js/load-config` 包到 `@modern-js/core` 包作为 utils 函数
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- @modern-js/utils@1.7.12
|
|
48
|
+
|
|
3
49
|
## 1.12.4
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
package/dist/config/index.js
CHANGED
|
@@ -18,9 +18,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.resolveConfig = exports.loadUserConfig = exports.assignPkgConfig = exports.defineConfig = exports.addServerConfigToDeps = exports.defaultsConfig = void 0;
|
|
21
|
-
const load_config_1 = require("@modern-js/load-config");
|
|
22
21
|
const utils_1 = require("@modern-js/utils");
|
|
23
22
|
const lodash_1 = require("@modern-js/utils/lodash");
|
|
23
|
+
const load_configs_1 = require("../load-configs");
|
|
24
24
|
const ajv_1 = __importDefault(require("../../compiled/ajv"));
|
|
25
25
|
const ajv_keywords_1 = __importDefault(require("../../compiled/ajv-keywords"));
|
|
26
26
|
const better_ajv_errors_1 = __importDefault(require("../../compiled/better-ajv-errors"));
|
|
@@ -56,7 +56,7 @@ const assignPkgConfig = (userConfig = {}, pkgConfig = {}) => (0, lodash_1.mergeW
|
|
|
56
56
|
});
|
|
57
57
|
exports.assignPkgConfig = assignPkgConfig;
|
|
58
58
|
const loadUserConfig = async (appDirectory, filePath, packageJsonConfig) => {
|
|
59
|
-
const loaded = await (0,
|
|
59
|
+
const loaded = await (0, load_configs_1.loadConfig)(appDirectory, filePath, packageJsonConfig);
|
|
60
60
|
const config = !loaded
|
|
61
61
|
? {}
|
|
62
62
|
: await (typeof loaded.config === 'function'
|
|
@@ -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
|
});
|
|
@@ -39,6 +39,9 @@ export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | P
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
+
preEntry: {
|
|
43
|
+
type: string[];
|
|
44
|
+
};
|
|
42
45
|
alias: {
|
|
43
46
|
typeof: string[];
|
|
44
47
|
};
|
|
@@ -337,6 +340,9 @@ export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | P
|
|
|
337
340
|
disableSpa: {
|
|
338
341
|
type: string;
|
|
339
342
|
};
|
|
343
|
+
resHeaders: {
|
|
344
|
+
type: string;
|
|
345
|
+
};
|
|
340
346
|
};
|
|
341
347
|
additionalProperties: boolean;
|
|
342
348
|
};
|
|
@@ -29,6 +29,7 @@ export interface SourceConfig {
|
|
|
29
29
|
enableFileSystemRoutes?: boolean;
|
|
30
30
|
disableMount?: boolean;
|
|
31
31
|
}>;
|
|
32
|
+
preEntry?: string | string[];
|
|
32
33
|
disableDefaultEntries?: boolean;
|
|
33
34
|
entriesDir?: string;
|
|
34
35
|
configDir?: string;
|
|
@@ -102,8 +103,9 @@ export interface OutputConfig {
|
|
|
102
103
|
}
|
|
103
104
|
export interface ServerConfig {
|
|
104
105
|
routes?: Record<string, string | string[] | {
|
|
105
|
-
route
|
|
106
|
+
route?: string | string[];
|
|
106
107
|
disableSpa?: boolean;
|
|
108
|
+
resHeaders?: Record<string, unknown>;
|
|
107
109
|
}>;
|
|
108
110
|
publicRoutes?: {
|
|
109
111
|
[filepath: string]: string;
|
|
@@ -10,4 +10,6 @@ export declare type SSGSingleEntryOptions = boolean | {
|
|
|
10
10
|
routes?: SSGRouteOptions[];
|
|
11
11
|
};
|
|
12
12
|
export declare type SSGMultiEntryOptions = Record<string, SSGSingleEntryOptions>;
|
|
13
|
-
export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string
|
|
13
|
+
export declare type SSGConfig = boolean | SSGSingleEntryOptions | SSGMultiEntryOptions | ((entryName: string, payload: {
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
}) => SSGSingleEntryOptions);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { INTERNAL_PLUGINS } from '@modern-js/utils';
|
|
2
|
-
import type { Hooks } from '@modern-js/types';
|
|
3
2
|
import type { ErrorObject } from '../compiled/ajv';
|
|
4
3
|
import { TransformPlugin } from './loadPlugins';
|
|
5
4
|
import { IAppContext, initAppContext } from './context';
|
|
6
|
-
import type { NormalizedConfig } from './config/mergeConfig';
|
|
7
|
-
export type { Hooks };
|
|
8
5
|
export * from './config';
|
|
6
|
+
export type { Hooks, ImportSpecifier, ImportStatement, RuntimePlugin, } from './types';
|
|
9
7
|
export * from '@modern-js/plugin';
|
|
10
8
|
export { manager, mountHook, usePlugins, createPlugin, registerHook, } from './manager';
|
|
11
9
|
export type { CliHooks, CliPlugin, CliHookCallbacks } from './manager';
|
|
12
10
|
export { AppContext, ConfigContext, ResolvedConfigContext, useAppContext, useConfigContext, useResolvedConfigContext, } from './pluginAPI';
|
|
13
11
|
export type { PluginAPI } from './pluginAPI';
|
|
14
|
-
export type {
|
|
12
|
+
export type { IAppContext };
|
|
15
13
|
declare const initAppDir: (cwd?: string) => Promise<string>;
|
|
16
14
|
export interface CoreOptions {
|
|
17
15
|
version?: string;
|
|
@@ -52,7 +50,7 @@ export declare const cli: {
|
|
|
52
50
|
init: (argv?: string[], options?: CoreOptions) => Promise<{
|
|
53
51
|
loadedConfig: import("./config").LoadedConfig;
|
|
54
52
|
appContext: IAppContext;
|
|
55
|
-
resolved: NormalizedConfig;
|
|
53
|
+
resolved: import("./config").NormalizedConfig;
|
|
56
54
|
}>;
|
|
57
55
|
run: (argv: string[], options?: CoreOptions) => Promise<void>;
|
|
58
56
|
restart: () => Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export declare const CONFIG_FILE_NAME = "modern.config";
|
|
3
|
+
export declare const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
|
4
|
+
/**
|
|
5
|
+
* Get user config from package.json.
|
|
6
|
+
* @param appDirectory - App root directory.
|
|
7
|
+
* @returns modernConfig or undefined
|
|
8
|
+
*/
|
|
9
|
+
export declare const getPackageConfig: <T>(appDirectory: string, packageJsonConfig?: string) => T | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Get the file dependencies by module.children, ignore file path in node_modules and this monorepo packages default.
|
|
12
|
+
* @param filePath - Absolute file path.
|
|
13
|
+
* @returns File dependencies array.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getDependencies: (filePath: string) => string[];
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param targetDir target dir
|
|
19
|
+
* @param overtime Unit of second
|
|
20
|
+
*/
|
|
21
|
+
export declare const clearFilesOverTime: (targetDir: string, overtime: number) => Promise<void>;
|
|
22
|
+
export declare const getConfigFilePath: (appDirectory: string, filePath?: string) => string | false;
|
|
23
|
+
/**
|
|
24
|
+
* Parse and load user config file, support extensions like .ts, mjs, js, ejs.
|
|
25
|
+
* @param appDirectory - App root directory, from which start search user config file.
|
|
26
|
+
* @param filePath - Specific absolute config file path.
|
|
27
|
+
* @returns Object contain config file path, user config object and dependency files used by config file.
|
|
28
|
+
*/
|
|
29
|
+
export declare const loadConfig: <T>(appDirectory: string, filePath?: string, packageJsonConfig?: string) => Promise<{
|
|
30
|
+
path: string | false;
|
|
31
|
+
config?: T | undefined;
|
|
32
|
+
dependencies?: string[] | undefined;
|
|
33
|
+
pkgConfig?: T | undefined;
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = exports.getConfigFilePath = exports.clearFilesOverTime = exports.getDependencies = exports.getPackageConfig = exports.PACKAGE_JSON_CONFIG_NAME = exports.CONFIG_FILE_NAME = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const utils_1 = require("@modern-js/utils");
|
|
9
|
+
const node_bundle_require_1 = require("@modern-js/node-bundle-require");
|
|
10
|
+
const debug = (0, utils_1.createDebugger)('load-config');
|
|
11
|
+
exports.CONFIG_FILE_NAME = 'modern.config';
|
|
12
|
+
exports.PACKAGE_JSON_CONFIG_NAME = 'modernConfig';
|
|
13
|
+
/**
|
|
14
|
+
* Get user config from package.json.
|
|
15
|
+
* @param appDirectory - App root directory.
|
|
16
|
+
* @returns modernConfig or undefined
|
|
17
|
+
*/
|
|
18
|
+
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
19
|
+
const json = JSON.parse(utils_1.fs.readFileSync(path_1.default.resolve(appDirectory, './package.json'), 'utf8'));
|
|
20
|
+
return json[packageJsonConfig !== null && packageJsonConfig !== void 0 ? packageJsonConfig : exports.PACKAGE_JSON_CONFIG_NAME];
|
|
21
|
+
};
|
|
22
|
+
exports.getPackageConfig = getPackageConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Get the file dependencies by module.children, ignore file path in node_modules and this monorepo packages default.
|
|
25
|
+
* @param filePath - Absolute file path.
|
|
26
|
+
* @returns File dependencies array.
|
|
27
|
+
*/
|
|
28
|
+
const getDependencies = (filePath) => {
|
|
29
|
+
const mod = require.cache[filePath];
|
|
30
|
+
if (!mod) {
|
|
31
|
+
debug(`${filePath} has not been required yet`);
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const deps = [];
|
|
35
|
+
if (!/\/node_modules\/|\/modern-js\/packages\//.test(mod.id)) {
|
|
36
|
+
deps.push(mod.id);
|
|
37
|
+
for (const child of mod.children) {
|
|
38
|
+
deps.push(...(0, exports.getDependencies)(child.id));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return deps;
|
|
42
|
+
};
|
|
43
|
+
exports.getDependencies = getDependencies;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @param targetDir target dir
|
|
47
|
+
* @param overtime Unit of second
|
|
48
|
+
*/
|
|
49
|
+
const clearFilesOverTime = async (targetDir, overtime) => {
|
|
50
|
+
// when stats is true, globby return Stats[]
|
|
51
|
+
const files = (await (0, utils_1.globby)(`${targetDir}/**/*`, {
|
|
52
|
+
stats: true,
|
|
53
|
+
absolute: true,
|
|
54
|
+
}));
|
|
55
|
+
const currentTime = Date.now();
|
|
56
|
+
if (files.length > 0) {
|
|
57
|
+
for (const file of files) {
|
|
58
|
+
if (currentTime - file.stats.birthtimeMs >= overtime * 1000) {
|
|
59
|
+
utils_1.fs.unlinkSync(file.path);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.clearFilesOverTime = clearFilesOverTime;
|
|
65
|
+
const bundleRequireWithCatch = async (configFile, { appDirectory }) => {
|
|
66
|
+
try {
|
|
67
|
+
const mod = await (0, node_bundle_require_1.bundleRequire)(configFile, {
|
|
68
|
+
autoClear: false,
|
|
69
|
+
getOutputFile: async (filePath) => {
|
|
70
|
+
const defaultOutputFileName = path_1.default.basename(await (0, node_bundle_require_1.defaultGetOutputFile)(filePath));
|
|
71
|
+
const outputPath = path_1.default.join(appDirectory, utils_1.CONFIG_CACHE_DIR);
|
|
72
|
+
// 10 min
|
|
73
|
+
const timeLimit = 10 * 60;
|
|
74
|
+
await (0, exports.clearFilesOverTime)(outputPath, timeLimit);
|
|
75
|
+
return path_1.default.join(outputPath, defaultOutputFileName);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
return mod;
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
if (e instanceof Error) {
|
|
82
|
+
e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
|
|
83
|
+
}
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const getConfigFilePath = (appDirectory, filePath) => {
|
|
88
|
+
if (filePath) {
|
|
89
|
+
if (path_1.default.isAbsolute(filePath)) {
|
|
90
|
+
return filePath;
|
|
91
|
+
}
|
|
92
|
+
return path_1.default.resolve(appDirectory, filePath);
|
|
93
|
+
}
|
|
94
|
+
return (0, utils_1.findExists)(utils_1.CONFIG_FILE_EXTENSIONS.map(extension => path_1.default.resolve(appDirectory, `${exports.CONFIG_FILE_NAME}${extension}`)));
|
|
95
|
+
};
|
|
96
|
+
exports.getConfigFilePath = getConfigFilePath;
|
|
97
|
+
/**
|
|
98
|
+
* Parse and load user config file, support extensions like .ts, mjs, js, ejs.
|
|
99
|
+
* @param appDirectory - App root directory, from which start search user config file.
|
|
100
|
+
* @param filePath - Specific absolute config file path.
|
|
101
|
+
* @returns Object contain config file path, user config object and dependency files used by config file.
|
|
102
|
+
*/
|
|
103
|
+
const loadConfig = async (appDirectory, filePath, packageJsonConfig) => {
|
|
104
|
+
const configFile = (0, exports.getConfigFilePath)(appDirectory, filePath);
|
|
105
|
+
const pkgConfig = (0, exports.getPackageConfig)(appDirectory, packageJsonConfig);
|
|
106
|
+
let config;
|
|
107
|
+
const dependencies = pkgConfig
|
|
108
|
+
? [path_1.default.resolve(appDirectory, './package.json')]
|
|
109
|
+
: [];
|
|
110
|
+
if (configFile) {
|
|
111
|
+
delete require.cache[configFile];
|
|
112
|
+
const mod = await bundleRequireWithCatch(configFile, { appDirectory });
|
|
113
|
+
config = mod.default || mod;
|
|
114
|
+
// TODO: get deps.
|
|
115
|
+
// dependencies = dependencies.concat(getDependencies(configFile));
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
path: configFile,
|
|
119
|
+
config,
|
|
120
|
+
pkgConfig,
|
|
121
|
+
dependencies,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
exports.loadConfig = loadConfig;
|
package/dist/manager.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToThreads, ToRunners, AsyncSetup, PluginOptions, AsyncWorkflow, AsyncWaterfall, ParallelWorkflow } from '@modern-js/plugin';
|
|
2
|
-
import type { Hooks } from '
|
|
2
|
+
import type { Hooks } from './types';
|
|
3
3
|
import type { Command } from './utils/commander';
|
|
4
4
|
import type { NormalizedConfig } from './config/mergeConfig';
|
|
5
5
|
import type { UserConfig } from './config';
|
|
@@ -45,26 +45,26 @@ export declare type CliHooks = typeof baseHooks & Hooks;
|
|
|
45
45
|
/** All hook callbacks of cli plugin. */
|
|
46
46
|
export declare type CliHookCallbacks = ToThreads<CliHooks>;
|
|
47
47
|
export declare const manager: import("@modern-js/plugin").AsyncManager<CliHooks, {
|
|
48
|
-
setAppContext: (value: import("@modern-js/types").IAppContext) => void;
|
|
49
|
-
useAppContext: () => import("@modern-js/types").IAppContext;
|
|
48
|
+
setAppContext: (value: import("@modern-js/types/cli").IAppContext) => void;
|
|
49
|
+
useAppContext: () => import("@modern-js/types/cli").IAppContext;
|
|
50
50
|
useConfigContext: () => UserConfig;
|
|
51
51
|
useResolvedConfigContext: () => NormalizedConfig;
|
|
52
52
|
}>;
|
|
53
53
|
/** Plugin options of a cli plugin. */
|
|
54
54
|
export declare type CliPlugin = PluginOptions<CliHooks, AsyncSetup<CliHooks, typeof pluginAPI>>;
|
|
55
55
|
export declare const createPlugin: (setup?: AsyncSetup<CliHooks, {
|
|
56
|
-
setAppContext: (value: import("@modern-js/types").IAppContext) => void;
|
|
57
|
-
useAppContext: () => import("@modern-js/types").IAppContext;
|
|
56
|
+
setAppContext: (value: import("@modern-js/types/cli").IAppContext) => void;
|
|
57
|
+
useAppContext: () => import("@modern-js/types/cli").IAppContext;
|
|
58
58
|
useConfigContext: () => UserConfig;
|
|
59
59
|
useResolvedConfigContext: () => NormalizedConfig;
|
|
60
60
|
}> | undefined, options?: PluginOptions<CliHooks, AsyncSetup<CliHooks, {
|
|
61
|
-
setAppContext: (value: import("@modern-js/types").IAppContext) => void;
|
|
62
|
-
useAppContext: () => import("@modern-js/types").IAppContext;
|
|
61
|
+
setAppContext: (value: import("@modern-js/types/cli").IAppContext) => void;
|
|
62
|
+
useAppContext: () => import("@modern-js/types/cli").IAppContext;
|
|
63
63
|
useConfigContext: () => UserConfig;
|
|
64
64
|
useResolvedConfigContext: () => NormalizedConfig;
|
|
65
65
|
}>> | undefined) => import("@modern-js/plugin").AsyncPlugin<CliHooks, {
|
|
66
|
-
setAppContext: (value: import("@modern-js/types").IAppContext) => void;
|
|
67
|
-
useAppContext: () => import("@modern-js/types").IAppContext;
|
|
66
|
+
setAppContext: (value: import("@modern-js/types/cli").IAppContext) => void;
|
|
67
|
+
useAppContext: () => import("@modern-js/types/cli").IAppContext;
|
|
68
68
|
useConfigContext: () => UserConfig;
|
|
69
69
|
useResolvedConfigContext: () => NormalizedConfig;
|
|
70
70
|
}>, registerHook: (newHooks: Partial<CliHooks>) => void, mountHook: () => ToRunners<CliHooks>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AsyncWaterfall, AsyncWorkflow } from '@modern-js/plugin';
|
|
2
|
+
import { Entrypoint, HtmlPartials, Route, ServerRoute } from '@modern-js/types';
|
|
3
|
+
import { Compiler, Configuration, MultiCompiler } from 'webpack';
|
|
4
|
+
export interface ImportSpecifier {
|
|
5
|
+
local?: string;
|
|
6
|
+
imported?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ImportStatement {
|
|
9
|
+
specifiers: ImportSpecifier[];
|
|
10
|
+
value: string;
|
|
11
|
+
initialize?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RuntimePlugin {
|
|
14
|
+
name: string;
|
|
15
|
+
options: string;
|
|
16
|
+
args?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Hooks {
|
|
19
|
+
beforeDev: AsyncWorkflow<void, unknown>;
|
|
20
|
+
afterDev: AsyncWorkflow<void, unknown>;
|
|
21
|
+
beforeCreateCompiler: AsyncWorkflow<{
|
|
22
|
+
webpackConfigs: Configuration[];
|
|
23
|
+
}, unknown>;
|
|
24
|
+
afterCreateCompiler: AsyncWorkflow<{
|
|
25
|
+
compiler: Compiler | MultiCompiler | undefined;
|
|
26
|
+
}, unknown>;
|
|
27
|
+
beforePrintInstructions: AsyncWaterfall<{
|
|
28
|
+
instructions: string;
|
|
29
|
+
}>;
|
|
30
|
+
beforeBuild: AsyncWorkflow<{
|
|
31
|
+
webpackConfigs: Configuration[];
|
|
32
|
+
}, unknown>;
|
|
33
|
+
afterBuild: AsyncWorkflow<void, unknown>;
|
|
34
|
+
afterMonorepoDeploy: AsyncWorkflow<{
|
|
35
|
+
operator: any;
|
|
36
|
+
deployProjectNames: string[];
|
|
37
|
+
}, void>;
|
|
38
|
+
beforeDeploy: AsyncWorkflow<Record<string, any>, unknown>;
|
|
39
|
+
afterDeploy: AsyncWorkflow<Record<string, any>, unknown>;
|
|
40
|
+
modifyEntryExport: AsyncWaterfall<{
|
|
41
|
+
entrypoint: Entrypoint;
|
|
42
|
+
exportStatement: string;
|
|
43
|
+
}>;
|
|
44
|
+
modifyEntryImports: AsyncWaterfall<{
|
|
45
|
+
imports: ImportStatement[];
|
|
46
|
+
entrypoint: Entrypoint;
|
|
47
|
+
}>;
|
|
48
|
+
modifyEntryRuntimePlugins: AsyncWaterfall<{
|
|
49
|
+
entrypoint: Entrypoint;
|
|
50
|
+
plugins: RuntimePlugin[];
|
|
51
|
+
}>;
|
|
52
|
+
modifyEntryRenderFunction: AsyncWaterfall<{
|
|
53
|
+
entrypoint: Entrypoint;
|
|
54
|
+
code: string;
|
|
55
|
+
}>;
|
|
56
|
+
modifyFileSystemRoutes: AsyncWaterfall<{
|
|
57
|
+
entrypoint: Entrypoint;
|
|
58
|
+
routes: Route[];
|
|
59
|
+
}>;
|
|
60
|
+
modifyServerRoutes: AsyncWaterfall<{
|
|
61
|
+
routes: ServerRoute[];
|
|
62
|
+
}>;
|
|
63
|
+
htmlPartials: AsyncWaterfall<{
|
|
64
|
+
entrypoint: Entrypoint;
|
|
65
|
+
partials: HtmlPartials;
|
|
66
|
+
}>;
|
|
67
|
+
addRuntimeExports: AsyncWaterfall<void>;
|
|
68
|
+
beforeGenerateRoutes: AsyncWaterfall<{
|
|
69
|
+
entrypoint: Entrypoint;
|
|
70
|
+
code: string;
|
|
71
|
+
}>;
|
|
72
|
+
addDefineTypes: AsyncWaterfall<void>;
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cli';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cli"), exports);
|
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.13.2",
|
|
15
14
|
"jsnext:source": "./src/index.ts",
|
|
16
15
|
"types": "./dist/index.d.ts",
|
|
17
16
|
"main": "./dist/index.js",
|
|
@@ -39,13 +38,13 @@
|
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
|
-
"@modern-js/
|
|
43
|
-
"@modern-js/
|
|
44
|
-
"@modern-js/
|
|
41
|
+
"@modern-js/plugin": "^1.4.2",
|
|
42
|
+
"@modern-js/utils": "^1.8.0",
|
|
43
|
+
"@modern-js/node-bundle-require": "^1.3.7"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@jest/types": "^27.0.6",
|
|
48
|
-
"@modern-js/types": "1.
|
|
47
|
+
"@modern-js/types": "1.6.1",
|
|
49
48
|
"@scripts/build": "0.0.0",
|
|
50
49
|
"@scripts/jest-config": "0.0.0",
|
|
51
50
|
"@types/babel__code-frame": "^7.0.3",
|
|
@@ -53,8 +52,6 @@
|
|
|
53
52
|
"@types/jest": "^27",
|
|
54
53
|
"@types/less": "^3.0.3",
|
|
55
54
|
"@types/node": "^14",
|
|
56
|
-
"@types/react": "^17",
|
|
57
|
-
"@types/react-dom": "^17",
|
|
58
55
|
"autoprefixer": "^10.3.1",
|
|
59
56
|
"btsm": "2.2.2",
|
|
60
57
|
"jest": "^27",
|