@modern-js/core 0.0.0-windows-202110385642 → 0.0.1-20221226
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 +1164 -6
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +5 -0
- package/dist/config/createDefaultConfig.d.ts +2 -0
- package/dist/config/createDefaultConfig.js +9 -0
- package/dist/config/createLoadedConfig.d.ts +6 -0
- package/dist/config/createLoadedConfig.js +35 -0
- package/dist/config/createResolvedConfig.d.ts +3 -0
- package/dist/config/createResolvedConfig.js +92 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +19 -0
- package/dist/context.d.ts +35 -0
- package/dist/context.js +61 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +150 -0
- package/dist/load-configs/index.d.ts +34 -0
- package/dist/load-configs/index.js +124 -0
- package/dist/{types/loadEnv.d.ts → loadEnv.d.ts} +1 -1
- package/dist/loadEnv.js +21 -0
- package/dist/loadPlugins.d.ts +18 -0
- package/dist/loadPlugins.js +65 -0
- package/dist/manager.d.ts +87 -0
- package/dist/manager.js +24 -0
- package/dist/runBin.d.ts +5 -0
- package/dist/runBin.js +51 -0
- package/dist/schema/patchSchema.d.ts +19 -0
- package/dist/schema/patchSchema.js +57 -0
- package/dist/schema/source.d.ts +9 -0
- package/dist/schema/source.js +10 -0
- package/dist/schema/testing.d.ts +13 -0
- package/dist/schema/testing.js +11 -0
- package/dist/schema/traverseSchema.d.ts +2 -0
- package/dist/schema/traverseSchema.js +20 -0
- package/dist/types/config/index.d.ts +49 -125
- package/dist/types/config/index.js +2 -0
- package/dist/types/config/testing.d.ts +15 -0
- package/dist/types/config/testing.js +2 -0
- package/dist/types/context.d.ts +28 -14
- package/dist/types/context.js +2 -0
- package/dist/types/hooks.d.ts +44 -0
- package/dist/types/hooks.js +2 -0
- package/dist/types/index.d.ts +9 -87
- package/dist/types/index.js +21 -0
- package/dist/types/plugin.d.ts +26 -0
- package/dist/types/plugin.js +2 -0
- package/dist/types/pluginAPI.d.ts +18 -0
- package/dist/types/pluginAPI.js +2 -0
- package/dist/utils/commander.d.ts +4 -0
- package/dist/utils/commander.js +20 -0
- package/dist/utils/mergeConfig.d.ts +2 -0
- package/dist/utils/mergeConfig.js +32 -0
- package/dist/utils/repeatKeyWarning.d.ts +3 -0
- package/dist/utils/repeatKeyWarning.js +22 -0
- package/package.json +52 -48
- package/bin/modern-js.js +0 -18
- package/dist/js/modern/config/defaults.js +0 -100
- package/dist/js/modern/config/index.js +0 -104
- package/dist/js/modern/config/mergeConfig.js +0 -20
- package/dist/js/modern/config/schema/deploy.js +0 -20
- 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 -33
- package/dist/js/modern/context.js +0 -25
- package/dist/js/modern/index.js +0 -142
- package/dist/js/modern/initWatcher.js +0 -46
- package/dist/js/modern/loadEnv.js +0 -12
- package/dist/js/modern/loadPlugins.js +0 -66
- package/dist/js/modern/utils/commander.js +0 -19
- package/dist/js/modern/utils/repeatKeyWarning.js +0 -18
- package/dist/js/node/config/defaults.js +0 -107
- package/dist/js/node/config/index.js +0 -142
- package/dist/js/node/config/mergeConfig.js +0 -32
- package/dist/js/node/config/schema/deploy.js +0 -29
- package/dist/js/node/config/schema/index.js +0 -129
- 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 -40
- package/dist/js/node/context.js +0 -52
- package/dist/js/node/index.js +0 -247
- package/dist/js/node/initWatcher.js +0 -67
- package/dist/js/node/loadEnv.js +0 -28
- package/dist/js/node/loadPlugins.js +0 -76
- package/dist/js/node/utils/commander.js +0 -35
- package/dist/js/node/utils/repeatKeyWarning.js +0 -31
- package/dist/types/config/defaults.d.ts +0 -25
- package/dist/types/config/mergeConfig.d.ts +0 -29
- package/dist/types/config/schema/deploy.d.ts +0 -19
- 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 -33
- package/dist/types/initWatcher.d.ts +0 -3
- package/dist/types/loadPlugins.d.ts +0 -16
- package/dist/types/utils/commander.d.ts +0 -7
- package/dist/types/utils/repeatKeyWarning.d.ts +0 -3
- package/modern.config.js +0 -13
- package/src/config/defaults.ts +0 -101
- package/src/config/index.ts +0 -296
- package/src/config/mergeConfig.ts +0 -68
- package/src/config/schema/deploy.ts +0 -17
- package/src/config/schema/index.ts +0 -116
- package/src/config/schema/output.ts +0 -66
- package/src/config/schema/server.ts +0 -106
- package/src/config/schema/source.ts +0 -34
- package/src/config/schema/tools.ts +0 -15
- package/src/context.ts +0 -46
- package/src/index.ts +0 -247
- package/src/initWatcher.ts +0 -77
- package/src/loadEnv.ts +0 -21
- package/src/loadPlugins.ts +0 -81
- package/src/types.d.ts +0 -0
- package/src/utils/commander.ts +0 -22
- package/src/utils/repeatKeyWarning.ts +0 -29
- package/tests/.eslintrc.js +0 -6
- package/tests/fixtures/load-plugin/not-found/package.json +0 -3
- package/tests/fixtures/load-plugin/not-found/test-plugin-a.js +0 -1
- package/tests/fixtures/load-plugin/user-plugins/package.json +0 -3
- package/tests/fixtures/load-plugin/user-plugins/test-plugin-a.js +0 -1
- package/tests/fixtures/load-plugin/user-plugins/test-plugin-b.js +0 -3
- package/tests/loadEnv.test.ts +0 -100
- package/tests/loadPlugin.test.ts +0 -29
- package/tests/mergeConfig.test.ts +0 -78
- package/tests/repeatKeyWarning.test.ts +0 -68
- package/tests/schema.test.ts +0 -109
- package/tests/tsconfig.json +0 -13
- package/tsconfig.json +0 -14
|
@@ -1,125 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
disableAssetsCache?: boolean;
|
|
51
|
-
enableLatestDecorators?: boolean;
|
|
52
|
-
polyfill?: 'off' | 'usage' | 'entry' | 'ua';
|
|
53
|
-
dataUriLimit?: number;
|
|
54
|
-
templateParameters?: Record<string, unknown>;
|
|
55
|
-
templateParametersByEntries?: Record<string, Record<string, unknown> | undefined>;
|
|
56
|
-
cssModuleLocalIdentName?: string;
|
|
57
|
-
enableModernMode?: boolean;
|
|
58
|
-
federation?: boolean;
|
|
59
|
-
disableNodePolyfill?: boolean;
|
|
60
|
-
enableTsLoader?: boolean;
|
|
61
|
-
}
|
|
62
|
-
export interface ServerConfig {
|
|
63
|
-
routes?: Record<string, string | {
|
|
64
|
-
route: string | string[];
|
|
65
|
-
disableSpa?: boolean;
|
|
66
|
-
}>;
|
|
67
|
-
publicRoutes?: {
|
|
68
|
-
[filepath: string]: string;
|
|
69
|
-
};
|
|
70
|
-
ssr?: boolean | Record<string, unknown>;
|
|
71
|
-
ssrByEntries?: Record<string, boolean | Record<string, unknown>>;
|
|
72
|
-
baseUrl?: string | Array<string>;
|
|
73
|
-
port?: number;
|
|
74
|
-
logger?: Record<string, string>;
|
|
75
|
-
measure?: Record<string, string>;
|
|
76
|
-
enableMicroFrontendDebug?: boolean;
|
|
77
|
-
}
|
|
78
|
-
export interface DevConfig {
|
|
79
|
-
assetPrefix?: string | boolean;
|
|
80
|
-
https?: boolean;
|
|
81
|
-
}
|
|
82
|
-
export interface DeployConfig {
|
|
83
|
-
microFrontend?: boolean | Record<string, unknown>;
|
|
84
|
-
domain?: string | Array<string>;
|
|
85
|
-
domainByEntries?: Record<string, string | Array<string>>;
|
|
86
|
-
}
|
|
87
|
-
declare type ConfigFunction = Record<string, unknown> | ((config: Record<string, unknown>) => Record<string, unknown> | void);
|
|
88
|
-
export interface ToolsConfig {
|
|
89
|
-
webpack?: ConfigFunction;
|
|
90
|
-
babel?: ConfigFunction;
|
|
91
|
-
autoprefixer?: ConfigFunction;
|
|
92
|
-
postcss?: ConfigFunction;
|
|
93
|
-
lodash?: ConfigFunction;
|
|
94
|
-
devServer?: Record<string, unknown>;
|
|
95
|
-
tsLoader?: ConfigFunction;
|
|
96
|
-
terser?: ConfigFunction;
|
|
97
|
-
minifyCss?: ConfigFunction;
|
|
98
|
-
esbuild?: Record<string, unknown>;
|
|
99
|
-
}
|
|
100
|
-
export declare type RuntimeConfig = Record<string, any>;
|
|
101
|
-
export interface RuntimeByEntriesConfig {
|
|
102
|
-
[name: string]: RuntimeConfig;
|
|
103
|
-
}
|
|
104
|
-
export interface UserConfig {
|
|
105
|
-
source?: SourceConfig;
|
|
106
|
-
output?: OutputConfig;
|
|
107
|
-
server?: ServerConfig;
|
|
108
|
-
dev?: DevConfig;
|
|
109
|
-
deploy?: DeployConfig;
|
|
110
|
-
tools?: ToolsConfig;
|
|
111
|
-
plugins?: PluginConfig;
|
|
112
|
-
runtime?: RuntimeConfig;
|
|
113
|
-
runtimeByEntries?: RuntimeByEntriesConfig;
|
|
114
|
-
}
|
|
115
|
-
export declare type ConfigParam = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
|
|
116
|
-
export interface LoadedConfig {
|
|
117
|
-
config: UserConfig;
|
|
118
|
-
filePath: string | false;
|
|
119
|
-
dependencies: string[];
|
|
120
|
-
pkgConfig: UserConfig;
|
|
121
|
-
jsConfig: UserConfig;
|
|
122
|
-
}
|
|
123
|
-
export declare const defineConfig: (config: ConfigParam) => ConfigParam;
|
|
124
|
-
export declare const loadUserConfig: (appDirectory: string, filePath?: string | undefined) => Promise<LoadedConfig>;
|
|
125
|
-
export declare const resolveConfig: (loaded: LoadedConfig, configs: UserConfig[], schemas: PluginValidateSchema[], isRestart: boolean, argv: string[]) => Promise<NormalizedConfig>;
|
|
1
|
+
import { PluginConfig } from '../plugin';
|
|
2
|
+
import type { BaseTestingNormalizedConfig, BaseTestingUserConfig } from './testing';
|
|
3
|
+
export type { Jest as JestConfig, BaseTestingUserConfig as TestConfig, } from './testing';
|
|
4
|
+
declare type DropUndefined<T> = T extends undefined ? never : T;
|
|
5
|
+
export declare type UserConfig<Extends extends {
|
|
6
|
+
hooks?: ExtendHooks;
|
|
7
|
+
userConfig?: ExtendUserConfig;
|
|
8
|
+
normalizedConfig?: ExtendNormalizedConfig;
|
|
9
|
+
} = {}, ExtendHooks extends Record<string, any> = {}, ExtendUserConfig extends {
|
|
10
|
+
testing?: Record<string, any>;
|
|
11
|
+
[property: string]: any;
|
|
12
|
+
} = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = {
|
|
13
|
+
testing?: BaseTestingUserConfig<DropUndefined<Extends['userConfig']>['testing']>;
|
|
14
|
+
plugins?: PluginConfig<any>;
|
|
15
|
+
/**
|
|
16
|
+
* auto load plugin that exist in the package.json
|
|
17
|
+
*
|
|
18
|
+
* **default: `false`**
|
|
19
|
+
*/
|
|
20
|
+
autoLoadPlugins?: boolean;
|
|
21
|
+
} & Omit<Extends['userConfig'], 'plugins' | 'testing'>;
|
|
22
|
+
export declare type NormalizedConfig<Extends extends {
|
|
23
|
+
hooks?: ExtendHooks;
|
|
24
|
+
userConfig?: ExtendUserConfig;
|
|
25
|
+
normalizedConfig?: ExtendNormalizedConfig;
|
|
26
|
+
} = {}, ExtendHooks extends Record<string, any> = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends {
|
|
27
|
+
testing?: Record<string, any>;
|
|
28
|
+
[property: string]: any;
|
|
29
|
+
} = {}> = {
|
|
30
|
+
plugins: PluginConfig<any>;
|
|
31
|
+
testing: BaseTestingNormalizedConfig<DropUndefined<Extends['normalizedConfig']>['testing']>;
|
|
32
|
+
/**
|
|
33
|
+
* auto load plugin that exist in the package.json
|
|
34
|
+
*
|
|
35
|
+
* **default: `false`**
|
|
36
|
+
*/
|
|
37
|
+
autoLoadPlugins: boolean;
|
|
38
|
+
} & Omit<Extends['normalizedConfig'], 'plugins' | 'testing'>;
|
|
39
|
+
export declare type LoadedConfig<Extends extends {
|
|
40
|
+
hooks?: ExtendHooks;
|
|
41
|
+
userConfig?: ExtendUserConfig;
|
|
42
|
+
} = {}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}> = {
|
|
43
|
+
config: UserConfig<Extends>;
|
|
44
|
+
filePath: string | false;
|
|
45
|
+
dependencies: string[];
|
|
46
|
+
pkgConfig: UserConfig<Extends>;
|
|
47
|
+
jsConfig: UserConfig<Extends>;
|
|
48
|
+
};
|
|
49
|
+
export declare type ConfigParams = UserConfig | Promise<UserConfig> | ((env: any) => UserConfig | Promise<UserConfig>);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JestConfigTypes, Merge } from '@modern-js/types';
|
|
2
|
+
export declare type Jest = JestConfigTypes.InitialOptions;
|
|
3
|
+
export declare type BaseTestingUserConfig<ExtendTestingUserConfig = {}> = Merge<{
|
|
4
|
+
/**
|
|
5
|
+
* Decide which transformer will be used to compile file
|
|
6
|
+
* Default: babel-jest
|
|
7
|
+
*/
|
|
8
|
+
transformer?: 'babel-jest' | 'ts-jest';
|
|
9
|
+
/**
|
|
10
|
+
* Original jest config
|
|
11
|
+
* Doc: https://jestjs.io/docs/configuration
|
|
12
|
+
*/
|
|
13
|
+
jest?: Jest | ((jestConfig: Jest) => Jest);
|
|
14
|
+
}, ExtendTestingUserConfig>;
|
|
15
|
+
export declare type BaseTestingNormalizedConfig<ExtendTestingNormailzedConfig = {}> = BaseTestingUserConfig<ExtendTestingNormailzedConfig>;
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { Entrypoint, InternalPlugins, ServerRoute, HtmlTemplates } from '@modern-js/types';
|
|
2
|
+
import { BuilderInstance } from '@modern-js/builder-shared';
|
|
3
|
+
export declare type ToolsType = 'app-tools' | 'module-tools' | 'doc-tools' | 'monorepo-tools';
|
|
4
|
+
export interface IAppContext {
|
|
5
|
+
metaName: string;
|
|
6
|
+
appDirectory: string;
|
|
7
|
+
configFile: string | false;
|
|
8
|
+
serverConfigFile: string;
|
|
9
|
+
serverInternalPlugins: InternalPlugins;
|
|
10
|
+
ip?: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
distDirectory: string;
|
|
13
|
+
toolsType?: ToolsType;
|
|
14
|
+
packageName: string;
|
|
15
|
+
srcDirectory: string;
|
|
16
|
+
sharedDirectory: string;
|
|
17
|
+
nodeModulesDirectory: string;
|
|
18
|
+
internalDirectory: string;
|
|
19
|
+
plugins: any[];
|
|
20
|
+
entrypoints: Entrypoint[];
|
|
21
|
+
checkedEntries: string[];
|
|
22
|
+
serverRoutes: ServerRoute[];
|
|
23
|
+
htmlTemplates: HtmlTemplates;
|
|
24
|
+
apiOnly: boolean;
|
|
25
|
+
internalDirAlias: string;
|
|
26
|
+
internalSrcAlias: string;
|
|
27
|
+
builder?: BuilderInstance;
|
|
28
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ParallelWorkflow, AsyncWaterfall, AsyncWorkflow, ToRunners, ToThreads } from '@modern-js/plugin';
|
|
2
|
+
import type { Command } from '@modern-js/utils';
|
|
3
|
+
import type { UserConfig, NormalizedConfig } from './config';
|
|
4
|
+
export declare type BaseHooks<Extends extends {
|
|
5
|
+
hooks?: ExtendHooks;
|
|
6
|
+
userConfig?: ExtendUserConfig;
|
|
7
|
+
normalizedConfig?: ExtendNormalizedConfig;
|
|
8
|
+
}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = {
|
|
9
|
+
config: ParallelWorkflow<void, UserConfig<Extends>>;
|
|
10
|
+
resolvedConfig: AsyncWaterfall<{
|
|
11
|
+
resolved: NormalizedConfig<Extends>;
|
|
12
|
+
}>;
|
|
13
|
+
validateSchema: ParallelWorkflow<void>;
|
|
14
|
+
prepare: AsyncWorkflow<void, void>;
|
|
15
|
+
commands: AsyncWorkflow<{
|
|
16
|
+
program: Command;
|
|
17
|
+
}, void>;
|
|
18
|
+
beforeExit: AsyncWorkflow<void, void>;
|
|
19
|
+
addRuntimeExports: AsyncWaterfall<void>;
|
|
20
|
+
};
|
|
21
|
+
export declare type CliHooksRunner<Extends extends {
|
|
22
|
+
hooks?: ExtendHooks;
|
|
23
|
+
userConfig?: ExtendUserConfig;
|
|
24
|
+
normalizedConfig?: ExtendNormalizedConfig;
|
|
25
|
+
} = {}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = ToRunners<BaseHooks<Extends> & Extends['hooks']>;
|
|
26
|
+
export declare type CliHookCallbacks = ToThreads<BaseHooks<{}>>;
|
|
27
|
+
export interface DevToolData<DevOptions = any> {
|
|
28
|
+
name: string;
|
|
29
|
+
subCommands?: string[];
|
|
30
|
+
menuItem?: {
|
|
31
|
+
name: string;
|
|
32
|
+
value: string;
|
|
33
|
+
};
|
|
34
|
+
disableRunBuild?: boolean;
|
|
35
|
+
action: (options: DevOptions, context: {
|
|
36
|
+
isTsProject?: boolean;
|
|
37
|
+
}) => void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface RegisterBuildPlatformResult {
|
|
40
|
+
platform: string | string[];
|
|
41
|
+
build: (currentPlatform: string, context: {
|
|
42
|
+
isTsProject: boolean;
|
|
43
|
+
}) => void | Promise<void>;
|
|
44
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,88 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export * from '@modern-js/plugin/node';
|
|
11
|
-
export declare type HooksRunner = Progresses2Runners<{
|
|
12
|
-
config: ParallelWorkflow<void>;
|
|
13
|
-
validateSchema: ParallelWorkflow<void>;
|
|
14
|
-
prepare: AsyncWorkflow<void, void>;
|
|
15
|
-
commands: AsyncWorkflow<{
|
|
16
|
-
program: Command;
|
|
17
|
-
}, void>;
|
|
18
|
-
watchFiles: ParallelWorkflow<void>;
|
|
19
|
-
fileChange: AsyncWorkflow<{
|
|
20
|
-
filename: string;
|
|
21
|
-
}, void>;
|
|
22
|
-
beforeExit: AsyncWorkflow<void, void>;
|
|
23
|
-
}>;
|
|
24
|
-
export declare const manager: import("@modern-js/plugin").AsyncManager<Hooks, {
|
|
25
|
-
config: ParallelWorkflow<void, unknown>;
|
|
26
|
-
validateSchema: ParallelWorkflow<void, unknown>;
|
|
27
|
-
prepare: AsyncWorkflow<void, void>;
|
|
28
|
-
commands: AsyncWorkflow<{
|
|
29
|
-
program: Command;
|
|
30
|
-
}, void>;
|
|
31
|
-
watchFiles: ParallelWorkflow<void, unknown>;
|
|
32
|
-
fileChange: AsyncWorkflow<{
|
|
33
|
-
filename: string;
|
|
34
|
-
}, void>;
|
|
35
|
-
beforeExit: AsyncWorkflow<void, void>;
|
|
36
|
-
}>;
|
|
37
|
-
export declare const createPlugin: (initializer: import("@modern-js/plugin").AsyncInitializer<Partial<import("@modern-js/plugin").Progresses2Threads<{
|
|
38
|
-
config: ParallelWorkflow<void, unknown>;
|
|
39
|
-
validateSchema: ParallelWorkflow<void, unknown>;
|
|
40
|
-
prepare: AsyncWorkflow<void, void>;
|
|
41
|
-
commands: AsyncWorkflow<{
|
|
42
|
-
program: Command;
|
|
43
|
-
}, void>;
|
|
44
|
-
watchFiles: ParallelWorkflow<void, unknown>;
|
|
45
|
-
fileChange: AsyncWorkflow<{
|
|
46
|
-
filename: string;
|
|
47
|
-
}, void>;
|
|
48
|
-
beforeExit: AsyncWorkflow<void, void>;
|
|
49
|
-
} & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, options?: import("@modern-js/plugin").PluginOptions | undefined) => import("@modern-js/plugin").AsyncPlugin<Partial<import("@modern-js/plugin").Progresses2Threads<{
|
|
50
|
-
config: ParallelWorkflow<void, unknown>;
|
|
51
|
-
validateSchema: ParallelWorkflow<void, unknown>;
|
|
52
|
-
prepare: AsyncWorkflow<void, void>;
|
|
53
|
-
commands: AsyncWorkflow<{
|
|
54
|
-
program: Command;
|
|
55
|
-
}, void>;
|
|
56
|
-
watchFiles: ParallelWorkflow<void, unknown>;
|
|
57
|
-
fileChange: AsyncWorkflow<{
|
|
58
|
-
filename: string;
|
|
59
|
-
}, void>;
|
|
60
|
-
beforeExit: AsyncWorkflow<void, void>;
|
|
61
|
-
} & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, registerHook: (newShape: Partial<Hooks>) => void, mountHook: () => Progresses2Runners<{
|
|
62
|
-
config: ParallelWorkflow<void, unknown>;
|
|
63
|
-
validateSchema: ParallelWorkflow<void, unknown>;
|
|
64
|
-
prepare: AsyncWorkflow<void, void>;
|
|
65
|
-
commands: AsyncWorkflow<{
|
|
66
|
-
program: Command;
|
|
67
|
-
}, void>;
|
|
68
|
-
watchFiles: ParallelWorkflow<void, unknown>;
|
|
69
|
-
fileChange: AsyncWorkflow<{
|
|
70
|
-
filename: string;
|
|
71
|
-
}, void>;
|
|
72
|
-
beforeExit: AsyncWorkflow<void, void>;
|
|
73
|
-
} & import("@modern-js/plugin").ClearDraftProgress<Hooks>>;
|
|
74
|
-
export declare const usePlugins: (plugins: string[]) => void;
|
|
75
|
-
export { defineConfig, AppContext, useAppContext, useConfigContext, useResolvedConfigContext };
|
|
76
|
-
export type { NormalizedConfig, IAppContext, UserConfig, ToolsConfig };
|
|
77
|
-
export interface CoreOption {
|
|
78
|
-
dryRun?: boolean;
|
|
1
|
+
import type { JSONSchemaType } from '@modern-js/utils/ajv/json-schema';
|
|
2
|
+
export * from './plugin';
|
|
3
|
+
export * from './config';
|
|
4
|
+
export * from './pluginAPI';
|
|
5
|
+
export * from './hooks';
|
|
6
|
+
export * from './context';
|
|
7
|
+
export interface PluginValidateSchema {
|
|
8
|
+
target: string;
|
|
9
|
+
schema: JSONSchemaType<any>;
|
|
79
10
|
}
|
|
80
|
-
export declare const cli: {
|
|
81
|
-
init: (argv?: string[]) => Promise<{
|
|
82
|
-
loadedConfig: import("./config").LoadedConfig;
|
|
83
|
-
appContext: IAppContext;
|
|
84
|
-
resolved: NormalizedConfig;
|
|
85
|
-
}>;
|
|
86
|
-
run: (argv: string[]) => Promise<void>;
|
|
87
|
-
restart: () => Promise<void>;
|
|
88
|
-
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./plugin"), exports);
|
|
18
|
+
__exportStar(require("./config"), exports);
|
|
19
|
+
__exportStar(require("./pluginAPI"), exports);
|
|
20
|
+
__exportStar(require("./hooks"), exports);
|
|
21
|
+
__exportStar(require("./context"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AsyncSetup, PluginOptions } from '@modern-js/plugin';
|
|
2
|
+
import { BaseHooks } from './hooks';
|
|
3
|
+
import { BasePluginAPI } from './pluginAPI';
|
|
4
|
+
export type { InternalPlugins } from '@modern-js/types';
|
|
5
|
+
/** Plugin options of a cli plugin. */
|
|
6
|
+
export declare type CliPlugin<Extends extends {
|
|
7
|
+
hooks?: ExtendHooks;
|
|
8
|
+
userConfig?: ExtendUserConfig;
|
|
9
|
+
normalizedConfig?: ExtendNormalizedConfig;
|
|
10
|
+
} = {}, ExtendHooks extends Record<string, any> = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = PluginOptions<BaseHooks<Extends>, AsyncSetup<BaseHooks<Extends> & Extends['hooks'], BasePluginAPI<Extends>>, Extends['hooks']>;
|
|
11
|
+
export declare type PluginItem = string | [string, any];
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
* Using NewPluginConfig instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare type OldPluginConfig = Array<PluginItem>;
|
|
17
|
+
export declare type NewPluginConfig<PluginTypes extends {
|
|
18
|
+
hooks?: Record<string, any>;
|
|
19
|
+
userConfig?: Record<string, any>;
|
|
20
|
+
normalizedConfig?: Record<string, any>;
|
|
21
|
+
}> = CliPlugin<PluginTypes>[];
|
|
22
|
+
export declare type PluginConfig<PluginTypes extends {
|
|
23
|
+
hooks?: Record<string, any>;
|
|
24
|
+
userConfig?: Record<string, any>;
|
|
25
|
+
normalizedConfig?: Record<string, any>;
|
|
26
|
+
} = {}> = OldPluginConfig | NewPluginConfig<PluginTypes>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommonAPI } from '@modern-js/plugin';
|
|
2
|
+
import type { setAppContext, useAppContext, useResolvedConfigContext, useConfigContext } from '../context';
|
|
3
|
+
import { BaseHooks } from './hooks';
|
|
4
|
+
export declare type BasePluginAPI<Extends extends {
|
|
5
|
+
hooks?: ExtendHooks;
|
|
6
|
+
userConfig?: ExtendUserConfig;
|
|
7
|
+
normalizedConfig?: ExtendNormalizedConfig;
|
|
8
|
+
}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = {
|
|
9
|
+
setAppContext: typeof setAppContext;
|
|
10
|
+
useAppContext: typeof useAppContext;
|
|
11
|
+
useConfigContext: typeof useConfigContext<Extends>;
|
|
12
|
+
useResolvedConfigContext: typeof useResolvedConfigContext<Extends>;
|
|
13
|
+
};
|
|
14
|
+
/** all apis for cli plugin */
|
|
15
|
+
export declare type PluginAPI<Extends extends {
|
|
16
|
+
hooks?: ExtendHooks;
|
|
17
|
+
userConfig?: ExtendUserConfig;
|
|
18
|
+
} = {}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}> = BasePluginAPI<Extends> & CommonAPI<BaseHooks<Extends> & Extends['hooks']>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.program = exports.initCommandsMap = void 0;
|
|
4
|
+
const utils_1 = require("@modern-js/utils");
|
|
5
|
+
Object.defineProperty(exports, "program", { enumerable: true, get: function () { return utils_1.program; } });
|
|
6
|
+
function initCommandsMap() {
|
|
7
|
+
if (!utils_1.program.hasOwnProperty('commandsMap')) {
|
|
8
|
+
Object.defineProperty(utils_1.program, 'commandsMap', {
|
|
9
|
+
get() {
|
|
10
|
+
const map = new Map();
|
|
11
|
+
for (const command of utils_1.program.commands) {
|
|
12
|
+
map.set(command._name, command);
|
|
13
|
+
}
|
|
14
|
+
return map;
|
|
15
|
+
},
|
|
16
|
+
configurable: false,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.initCommandsMap = initCommandsMap;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { UserConfig, NormalizedConfig } from '../types';
|
|
2
|
+
export declare const mergeConfig: <ExtendConfig extends Record<string, any>>(configs: (UserConfig<ExtendConfig, {}, {}, {}> | NormalizedConfig<ExtendConfig, {}, {}, {}>)[]) => NormalizedConfig<ExtendConfig, {}, {}, {}>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeConfig = void 0;
|
|
4
|
+
const lodash_1 = require("@modern-js/utils/lodash");
|
|
5
|
+
const mergeConfig = (configs) => (0, lodash_1.mergeWith)({}, ...configs, (target, source, key) => {
|
|
6
|
+
// Do not use the following merge logic for source.designSystem and tools.tailwind(css)
|
|
7
|
+
if (key === 'designSystem' ||
|
|
8
|
+
(key === 'tailwind' && typeof source === 'object') ||
|
|
9
|
+
(key === 'tailwindcss' && typeof source === 'object') ||
|
|
10
|
+
key === 'devServer') {
|
|
11
|
+
return (0, lodash_1.mergeWith)({}, target !== null && target !== void 0 ? target : {}, source !== null && source !== void 0 ? source : {});
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(target)) {
|
|
14
|
+
if (Array.isArray(source)) {
|
|
15
|
+
return [...target, ...source];
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return source !== undefined ? [...target, source] : target;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else if ((0, lodash_1.isFunction)(target) || (0, lodash_1.isFunction)(source)) {
|
|
22
|
+
if (source === undefined) {
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
if (target === undefined) {
|
|
26
|
+
return source;
|
|
27
|
+
}
|
|
28
|
+
return [target, source];
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
});
|
|
32
|
+
exports.mergeConfig = mergeConfig;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repeatKeyWarning = exports.deepGet = void 0;
|
|
4
|
+
const traverseSchema_1 = require("../schema/traverseSchema");
|
|
5
|
+
const deepGet = (obj, key) => {
|
|
6
|
+
for (const p of key.split('.')) {
|
|
7
|
+
// eslint-disable-next-line no-param-reassign
|
|
8
|
+
obj = obj ? obj[p] : undefined;
|
|
9
|
+
}
|
|
10
|
+
return obj;
|
|
11
|
+
};
|
|
12
|
+
exports.deepGet = deepGet;
|
|
13
|
+
const repeatKeyWarning = (schema, jsConfig, pkgConfig) => {
|
|
14
|
+
const keys = (0, traverseSchema_1.traverseSchema)(schema);
|
|
15
|
+
for (const key of keys) {
|
|
16
|
+
if ((0, exports.deepGet)(jsConfig, key) !== undefined &&
|
|
17
|
+
(0, exports.deepGet)(pkgConfig, key) !== undefined) {
|
|
18
|
+
throw new Error(`The same configuration ${key} exists in modern.config.js and package.json.\n Please remove it from package.json.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.repeatKeyWarning = repeatKeyWarning;
|