@modern-js/core 0.0.0-windows-20211056953 → 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.
Files changed (130) hide show
  1. package/CHANGELOG.md +1164 -6
  2. package/dist/bin.d.ts +2 -0
  3. package/dist/bin.js +5 -0
  4. package/dist/config/createDefaultConfig.d.ts +2 -0
  5. package/dist/config/createDefaultConfig.js +9 -0
  6. package/dist/config/createLoadedConfig.d.ts +6 -0
  7. package/dist/config/createLoadedConfig.js +35 -0
  8. package/dist/config/createResolvedConfig.d.ts +3 -0
  9. package/dist/config/createResolvedConfig.js +92 -0
  10. package/dist/config/index.d.ts +3 -0
  11. package/dist/config/index.js +19 -0
  12. package/dist/context.d.ts +35 -0
  13. package/dist/context.js +61 -0
  14. package/dist/index.d.ts +73 -0
  15. package/dist/index.js +150 -0
  16. package/dist/load-configs/index.d.ts +34 -0
  17. package/dist/load-configs/index.js +124 -0
  18. package/dist/{types/loadEnv.d.ts → loadEnv.d.ts} +1 -1
  19. package/dist/loadEnv.js +21 -0
  20. package/dist/loadPlugins.d.ts +18 -0
  21. package/dist/loadPlugins.js +65 -0
  22. package/dist/manager.d.ts +87 -0
  23. package/dist/manager.js +24 -0
  24. package/dist/runBin.d.ts +5 -0
  25. package/dist/runBin.js +51 -0
  26. package/dist/schema/patchSchema.d.ts +19 -0
  27. package/dist/schema/patchSchema.js +57 -0
  28. package/dist/schema/source.d.ts +9 -0
  29. package/dist/schema/source.js +10 -0
  30. package/dist/schema/testing.d.ts +13 -0
  31. package/dist/schema/testing.js +11 -0
  32. package/dist/schema/traverseSchema.d.ts +2 -0
  33. package/dist/schema/traverseSchema.js +20 -0
  34. package/dist/types/config/index.d.ts +49 -125
  35. package/dist/types/config/index.js +2 -0
  36. package/dist/types/config/testing.d.ts +15 -0
  37. package/dist/types/config/testing.js +2 -0
  38. package/dist/types/context.d.ts +28 -14
  39. package/dist/types/context.js +2 -0
  40. package/dist/types/hooks.d.ts +44 -0
  41. package/dist/types/hooks.js +2 -0
  42. package/dist/types/index.d.ts +9 -87
  43. package/dist/types/index.js +21 -0
  44. package/dist/types/plugin.d.ts +26 -0
  45. package/dist/types/plugin.js +2 -0
  46. package/dist/types/pluginAPI.d.ts +18 -0
  47. package/dist/types/pluginAPI.js +2 -0
  48. package/dist/utils/commander.d.ts +4 -0
  49. package/dist/utils/commander.js +20 -0
  50. package/dist/utils/mergeConfig.d.ts +2 -0
  51. package/dist/utils/mergeConfig.js +32 -0
  52. package/dist/utils/repeatKeyWarning.d.ts +3 -0
  53. package/dist/utils/repeatKeyWarning.js +22 -0
  54. package/package.json +52 -48
  55. package/bin/modern-js.js +0 -18
  56. package/dist/js/modern/config/defaults.js +0 -100
  57. package/dist/js/modern/config/index.js +0 -104
  58. package/dist/js/modern/config/mergeConfig.js +0 -20
  59. package/dist/js/modern/config/schema/deploy.js +0 -20
  60. package/dist/js/modern/config/schema/index.js +0 -107
  61. package/dist/js/modern/config/schema/output.js +0 -147
  62. package/dist/js/modern/config/schema/server.js +0 -170
  63. package/dist/js/modern/config/schema/source.js +0 -59
  64. package/dist/js/modern/config/schema/tools.js +0 -33
  65. package/dist/js/modern/context.js +0 -25
  66. package/dist/js/modern/index.js +0 -142
  67. package/dist/js/modern/initWatcher.js +0 -46
  68. package/dist/js/modern/loadEnv.js +0 -12
  69. package/dist/js/modern/loadPlugins.js +0 -66
  70. package/dist/js/modern/utils/commander.js +0 -19
  71. package/dist/js/modern/utils/repeatKeyWarning.js +0 -18
  72. package/dist/js/node/config/defaults.js +0 -107
  73. package/dist/js/node/config/index.js +0 -142
  74. package/dist/js/node/config/mergeConfig.js +0 -32
  75. package/dist/js/node/config/schema/deploy.js +0 -29
  76. package/dist/js/node/config/schema/index.js +0 -129
  77. package/dist/js/node/config/schema/output.js +0 -156
  78. package/dist/js/node/config/schema/server.js +0 -179
  79. package/dist/js/node/config/schema/source.js +0 -68
  80. package/dist/js/node/config/schema/tools.js +0 -40
  81. package/dist/js/node/context.js +0 -52
  82. package/dist/js/node/index.js +0 -247
  83. package/dist/js/node/initWatcher.js +0 -67
  84. package/dist/js/node/loadEnv.js +0 -28
  85. package/dist/js/node/loadPlugins.js +0 -76
  86. package/dist/js/node/utils/commander.js +0 -35
  87. package/dist/js/node/utils/repeatKeyWarning.js +0 -31
  88. package/dist/types/config/defaults.d.ts +0 -25
  89. package/dist/types/config/mergeConfig.d.ts +0 -29
  90. package/dist/types/config/schema/deploy.d.ts +0 -19
  91. package/dist/types/config/schema/index.d.ts +0 -466
  92. package/dist/types/config/schema/output.d.ts +0 -146
  93. package/dist/types/config/schema/server.d.ts +0 -182
  94. package/dist/types/config/schema/source.d.ts +0 -58
  95. package/dist/types/config/schema/tools.d.ts +0 -33
  96. package/dist/types/initWatcher.d.ts +0 -3
  97. package/dist/types/loadPlugins.d.ts +0 -16
  98. package/dist/types/utils/commander.d.ts +0 -7
  99. package/dist/types/utils/repeatKeyWarning.d.ts +0 -3
  100. package/modern.config.js +0 -13
  101. package/src/config/defaults.ts +0 -101
  102. package/src/config/index.ts +0 -296
  103. package/src/config/mergeConfig.ts +0 -68
  104. package/src/config/schema/deploy.ts +0 -17
  105. package/src/config/schema/index.ts +0 -116
  106. package/src/config/schema/output.ts +0 -66
  107. package/src/config/schema/server.ts +0 -106
  108. package/src/config/schema/source.ts +0 -34
  109. package/src/config/schema/tools.ts +0 -15
  110. package/src/context.ts +0 -46
  111. package/src/index.ts +0 -247
  112. package/src/initWatcher.ts +0 -77
  113. package/src/loadEnv.ts +0 -21
  114. package/src/loadPlugins.ts +0 -81
  115. package/src/types.d.ts +0 -0
  116. package/src/utils/commander.ts +0 -22
  117. package/src/utils/repeatKeyWarning.ts +0 -29
  118. package/tests/.eslintrc.js +0 -6
  119. package/tests/fixtures/load-plugin/not-found/package.json +0 -3
  120. package/tests/fixtures/load-plugin/not-found/test-plugin-a.js +0 -1
  121. package/tests/fixtures/load-plugin/user-plugins/package.json +0 -3
  122. package/tests/fixtures/load-plugin/user-plugins/test-plugin-a.js +0 -1
  123. package/tests/fixtures/load-plugin/user-plugins/test-plugin-b.js +0 -3
  124. package/tests/loadEnv.test.ts +0 -100
  125. package/tests/loadPlugin.test.ts +0 -29
  126. package/tests/mergeConfig.test.ts +0 -78
  127. package/tests/repeatKeyWarning.test.ts +0 -68
  128. package/tests/schema.test.ts +0 -109
  129. package/tests/tsconfig.json +0 -13
  130. package/tsconfig.json +0 -14
@@ -1,125 +1,49 @@
1
- import { MetaOptions } from '@modern-js/utils';
2
- import { PluginConfig } from '../loadPlugins';
3
- import { defaults } from './defaults';
4
- import { NormalizedConfig } from './mergeConfig';
5
- import { PluginValidateSchema } from './schema';
6
- export { defaults as defaultsConfig };
7
- export interface SourceConfig {
8
- entries?: Record<string, string | {
9
- entry: string;
10
- enableFileSystemRoutes?: boolean;
11
- disableMount?: boolean;
12
- }>;
13
- disableDefaultEntries?: boolean;
14
- entriesDir?: string;
15
- configDir?: string;
16
- apiDir?: string;
17
- envVars?: Array<string>;
18
- globalVars?: Record<string, string>;
19
- alias?: Record<string, string> | ((aliases: Record<string, string>) => Record<string, unknown>);
20
- moduleScopes?: Array<string | RegExp> | ((scopes: Array<string | RegExp>) => Array<string | RegExp>);
21
- include?: Array<string | RegExp>;
22
- }
23
- export interface OutputConfig {
24
- assetPrefix?: string;
25
- htmlPath?: string;
26
- jsPath?: string;
27
- cssPath?: string;
28
- mediaPath?: string;
29
- path?: string;
30
- title?: string;
31
- titleByEntries?: Record<string, string>;
32
- meta?: MetaOptions;
33
- metaByEntries?: Record<string, MetaOptions>;
34
- inject?: 'body' | 'head' | boolean;
35
- injectByEntries?: Record<string, 'body' | 'head' | boolean>;
36
- mountId?: string;
37
- favicon?: string;
38
- faviconByEntries?: Record<string, string | undefined>;
39
- copy?: Record<string, unknown>;
40
- scriptExt?: Record<string, unknown>;
41
- disableHtmlFolder?: boolean;
42
- disableCssModuleExtension?: boolean;
43
- disableCssExtract?: boolean;
44
- enableCssModuleTSDeclaration?: boolean;
45
- disableMinimize?: boolean;
46
- enableInlineStyles?: boolean;
47
- enableInlineScripts?: boolean;
48
- disableSourceMap?: boolean;
49
- disableInlineRuntimeChunk?: boolean;
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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,14 +1,28 @@
1
- import type { IAppContext } from '@modern-js/types';
2
- import { UserConfig } from './config';
3
- import { NormalizedConfig } from './config/mergeConfig';
4
- export type { IAppContext };
5
- export declare const AppContext: import("@modern-js/plugin").Context<IAppContext>;
6
- export declare const ConfigContext: import("@modern-js/plugin").Context<UserConfig>;
7
- export declare const ResolvedConfigContext: import("@modern-js/plugin").Context<NormalizedConfig>;
8
- export declare const useAppContext: () => IAppContext;
9
- export declare const useConfigContext: () => UserConfig;
10
- export declare const useResolvedConfigContext: () => NormalizedConfig;
11
- export declare const initAppContext: (appDirectory: string, plugins: Array<{
12
- cli: any;
13
- server: any;
14
- }>, configFile: string | false) => IAppContext;
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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,88 +1,10 @@
1
- import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners } from '@modern-js/plugin';
2
- import type { Hooks } from '@modern-js/types';
3
- import { Command } from './utils/commander';
4
- import { defineConfig, UserConfig, ToolsConfig } from './config';
5
- import { AppContext, IAppContext, useAppContext, useConfigContext, useResolvedConfigContext } from './context';
6
- import { NormalizedConfig } from './config/mergeConfig';
7
- export type { Hooks };
8
- export { defaultsConfig } from './config';
9
- export * from '@modern-js/plugin';
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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { program, Command } from '@modern-js/utils';
2
+ export declare function initCommandsMap(): void;
3
+ export type { Command };
4
+ export { program };
@@ -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,3 @@
1
+ import { UserConfig } from '../types';
2
+ export declare const deepGet: (obj: any, key: string) => any;
3
+ export declare const repeatKeyWarning: <E extends Record<string, any>>(schema: any, jsConfig: UserConfig<E, {}, {}, {}>, pkgConfig: UserConfig<E, {}, {}, {}>) => void;
@@ -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;