@modern-js/core 2.26.0 → 2.28.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/bin.d.ts +1 -1
  3. package/dist/bin.js +5 -3
  4. package/dist/config/createDefaultConfig.d.ts +1 -1
  5. package/dist/config/createDefaultConfig.js +12 -6
  6. package/dist/config/createLoadedConfig.d.ts +1 -1
  7. package/dist/config/createLoadedConfig.js +81 -73
  8. package/dist/config/createResolvedConfig.d.ts +1 -1
  9. package/dist/config/createResolvedConfig.js +60 -72
  10. package/dist/config/index.d.ts +1 -1
  11. package/dist/config/index.js +7 -18
  12. package/dist/config/loadConfig.d.ts +5 -5
  13. package/dist/config/loadConfig.js +115 -112
  14. package/dist/context.d.ts +21 -14
  15. package/dist/context.js +74 -60
  16. package/dist/createCli.d.ts +13 -13
  17. package/dist/createCli.js +134 -113
  18. package/dist/index.d.ts +16 -16
  19. package/dist/index.js +59 -35
  20. package/dist/loadEnv.d.ts +1 -1
  21. package/dist/loadEnv.js +23 -17
  22. package/dist/loadPlugins.d.ts +4 -4
  23. package/dist/loadPlugins.js +55 -54
  24. package/dist/manager.d.ts +62 -62
  25. package/dist/manager.js +40 -23
  26. package/dist/nodeApi.d.ts +1 -1
  27. package/dist/nodeApi.js +25 -9
  28. package/dist/runBin.d.ts +2 -2
  29. package/dist/runBin.js +57 -53
  30. package/dist/schema/patchSchema.d.ts +15 -15
  31. package/dist/schema/patchSchema.js +56 -53
  32. package/dist/schema/testing.d.ts +11 -11
  33. package/dist/schema/testing.js +26 -8
  34. package/dist/schema/traverseSchema.d.ts +1 -1
  35. package/dist/schema/traverseSchema.js +25 -17
  36. package/dist/types/config/index.d.ts +37 -37
  37. package/dist/types/config/index.js +3 -1
  38. package/dist/types/config/testing.d.ts +11 -11
  39. package/dist/types/config/testing.js +3 -1
  40. package/dist/types/context.d.ts +27 -27
  41. package/dist/types/context.js +3 -1
  42. package/dist/types/coreOptions.d.ts +22 -22
  43. package/dist/types/coreOptions.js +3 -1
  44. package/dist/types/hooks.d.ts +41 -41
  45. package/dist/types/hooks.js +3 -1
  46. package/dist/types/index.d.ts +3 -3
  47. package/dist/types/index.js +10 -21
  48. package/dist/types/plugin.d.ts +10 -10
  49. package/dist/types/plugin.js +3 -1
  50. package/dist/types/pluginAPI.d.ts +10 -10
  51. package/dist/types/pluginAPI.js +3 -1
  52. package/dist/utils/checkIsDuplicationPlugin.d.ts +1 -1
  53. package/dist/utils/checkIsDuplicationPlugin.js +24 -21
  54. package/dist/utils/commander.d.ts +1 -1
  55. package/dist/utils/commander.js +31 -17
  56. package/dist/utils/createFileWatcher.d.ts +1 -1
  57. package/dist/utils/createFileWatcher.js +85 -106
  58. package/dist/utils/index.d.ts +1 -1
  59. package/dist/utils/index.js +10 -21
  60. package/dist/utils/initAppDir.d.ts +1 -1
  61. package/dist/utils/initAppDir.js +22 -17
  62. package/dist/utils/mergeConfig.d.ts +1 -1
  63. package/dist/utils/mergeConfig.js +37 -27
  64. package/dist/utils/repeatKeyWarning.d.ts +1 -1
  65. package/dist/utils/repeatKeyWarning.js +29 -16
  66. package/package.json +11 -10
@@ -1,2 +1,2 @@
1
1
  import { patchSchema } from './patchSchema';
2
- export declare const traverseSchema: (schema: ReturnType<typeof patchSchema>) => string[];
2
+ export declare const traverseSchema: (schema: ReturnType<typeof patchSchema>) => string[];
@@ -1,20 +1,28 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.traverseSchema = void 0;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "traverseSchema", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return traverseSchema;
9
+ }
10
+ });
4
11
  const traverseSchema = (schema) => {
5
- const keys = [];
6
- const traverse = ({ properties }, old = []) => {
7
- for (const key of Object.keys(properties)) {
8
- const current = [...old, key];
9
- if (properties[key].type === 'object' && properties[key].properties) {
10
- traverse(properties[key], current);
11
- }
12
- else {
13
- keys.push(current.join('.'));
14
- }
15
- }
16
- };
17
- traverse(schema);
18
- return keys;
12
+ const keys = [];
13
+ const traverse = ({ properties }, old = []) => {
14
+ for (const key of Object.keys(properties)) {
15
+ const current = [
16
+ ...old,
17
+ key
18
+ ];
19
+ if (properties[key].type === "object" && properties[key].properties) {
20
+ traverse(properties[key], current);
21
+ } else {
22
+ keys.push(current.join("."));
23
+ }
24
+ }
25
+ };
26
+ traverse(schema);
27
+ return keys;
19
28
  };
20
- exports.traverseSchema = traverseSchema;
@@ -1,53 +1,53 @@
1
1
  import { PluginConfig } from '../plugin';
2
2
  import type { BaseTestingNormalizedConfig, BaseTestingUserConfig } from './testing';
3
- export type { Jest as JestConfig, BaseTestingUserConfig as TestConfig, } from './testing';
3
+ export type { Jest as JestConfig, BaseTestingUserConfig as TestConfig } from './testing';
4
4
  type DropUndefined<T> = T extends undefined ? never : T;
5
5
  export type UserConfig<Extends extends {
6
- hooks?: ExtendHooks;
7
- userConfig?: ExtendUserConfig;
8
- normalizedConfig?: ExtendNormalizedConfig;
6
+ hooks?: ExtendHooks;
7
+ userConfig?: ExtendUserConfig;
8
+ normalizedConfig?: ExtendNormalizedConfig;
9
9
  } = {}, ExtendHooks extends Record<string, any> = {}, ExtendUserConfig extends {
10
- testing?: Record<string, any>;
11
- [property: string]: any;
10
+ testing?: Record<string, any>;
11
+ [property: string]: any;
12
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;
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
21
  } & Omit<Extends['userConfig'], 'plugins' | 'testing'>;
22
22
  export type NormalizedConfig<Extends extends {
23
- hooks?: ExtendHooks;
24
- userConfig?: ExtendUserConfig;
25
- normalizedConfig?: ExtendNormalizedConfig;
23
+ hooks?: ExtendHooks;
24
+ userConfig?: ExtendUserConfig;
25
+ normalizedConfig?: ExtendNormalizedConfig;
26
26
  } = {}, ExtendHooks extends Record<string, any> = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends {
27
- testing?: Record<string, any>;
28
- [property: string]: any;
27
+ testing?: Record<string, any>;
28
+ [property: string]: any;
29
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;
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
38
  } & Omit<Extends['normalizedConfig'], 'plugins' | 'testing'>;
39
39
  export type LoadedConfig<Extends extends {
40
- hooks?: ExtendHooks;
41
- userConfig?: ExtendUserConfig;
40
+ hooks?: ExtendHooks;
41
+ userConfig?: ExtendUserConfig;
42
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>;
43
+ config: UserConfig<Extends>;
44
+ filePath: string | false;
45
+ dependencies: string[];
46
+ pkgConfig: UserConfig<Extends>;
47
+ jsConfig: UserConfig<Extends>;
48
48
  };
49
49
  export type ConfigParams = {
50
- env: string;
51
- command: string;
50
+ env: string;
51
+ command: string;
52
52
  };
53
- export type UserConfigExport<Config = UserConfig> = Config | ((env: ConfigParams) => Config | Promise<Config>);
53
+ export type UserConfigExport<Config = UserConfig> = Config | ((env: ConfigParams) => Config | Promise<Config>);
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -1,15 +1,15 @@
1
1
  import type { JestConfigTypes, Merge } from '@modern-js/types';
2
2
  export type Jest = JestConfigTypes.InitialOptions;
3
3
  export 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);
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
14
  }, ExtendTestingUserConfig>;
15
- export type BaseTestingNormalizedConfig<ExtendTestingNormalizedConfig = {}> = BaseTestingUserConfig<ExtendTestingNormalizedConfig>;
15
+ export type BaseTestingNormalizedConfig<ExtendTestingNormalizedConfig = {}> = BaseTestingUserConfig<ExtendTestingNormalizedConfig>;
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -2,30 +2,30 @@ import { Entrypoint, InternalPlugins, ServerRoute, HtmlTemplates } from '@modern
2
2
  import { BuilderInstance } from '@modern-js/builder-shared';
3
3
  export type ToolsType = 'app-tools' | 'module-tools' | 'doc-tools' | 'monorepo-tools';
4
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
- apiDirectory: string;
17
- lambdaDirectory: string;
18
- sharedDirectory: string;
19
- nodeModulesDirectory: string;
20
- internalDirectory: string;
21
- plugins: any[];
22
- entrypoints: Entrypoint[];
23
- checkedEntries: string[];
24
- serverRoutes: ServerRoute[];
25
- htmlTemplates: HtmlTemplates;
26
- apiOnly: boolean;
27
- internalDirAlias: string;
28
- internalSrcAlias: string;
29
- builder?: BuilderInstance;
30
- bundlerType?: 'webpack' | 'rspack' | 'esbuild';
31
- }
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
+ apiDirectory: string;
17
+ lambdaDirectory: string;
18
+ sharedDirectory: string;
19
+ nodeModulesDirectory: string;
20
+ internalDirectory: string;
21
+ plugins: any[];
22
+ entrypoints: Entrypoint[];
23
+ checkedEntries: string[];
24
+ serverRoutes: ServerRoute[];
25
+ htmlTemplates: HtmlTemplates;
26
+ apiOnly: boolean;
27
+ internalDirAlias: string;
28
+ internalSrcAlias: string;
29
+ builder?: BuilderInstance;
30
+ bundlerType?: 'webpack' | 'rspack' | 'esbuild';
31
+ }
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -2,25 +2,25 @@ import type { ErrorObject } from '@modern-js/utils/compiled/ajv';
2
2
  import type { InternalPlugins } from './plugin';
3
3
  import type { UserConfig } from './config';
4
4
  export interface CoreOptions {
5
- cwd?: string;
6
- version?: string;
7
- configFile?: string;
8
- serverConfigFile?: string;
9
- packageJsonConfig?: string;
10
- internalPlugins?: {
11
- cli?: InternalPlugins;
12
- server?: InternalPlugins;
13
- autoLoad?: InternalPlugins;
14
- };
15
- onSchemaError?: (error: ErrorObject) => void;
16
- options?: {
17
- metaName?: string;
18
- srcDir?: string;
19
- distDir?: string;
20
- sharedDir?: string;
21
- };
22
- /** force the modern-js core auto register plugin exist in the package.json */
23
- forceAutoLoadPlugins?: boolean;
24
- /** config for Node API */
25
- loadedConfig?: UserConfig;
26
- }
5
+ cwd?: string;
6
+ version?: string;
7
+ configFile?: string;
8
+ serverConfigFile?: string;
9
+ packageJsonConfig?: string;
10
+ internalPlugins?: {
11
+ cli?: InternalPlugins;
12
+ server?: InternalPlugins;
13
+ autoLoad?: InternalPlugins;
14
+ };
15
+ onSchemaError?: (error: ErrorObject) => void;
16
+ options?: {
17
+ metaName?: string;
18
+ srcDir?: string;
19
+ distDir?: string;
20
+ sharedDir?: string;
21
+ };
22
+ /** force the modern-js core auto register plugin exist in the package.json */
23
+ forceAutoLoadPlugins?: boolean;
24
+ /** config for Node API */
25
+ loadedConfig?: UserConfig;
26
+ }
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -2,53 +2,53 @@ import { Workflow, ParallelWorkflow, AsyncWaterfall, AsyncWorkflow, ToRunners, T
2
2
  import type { Command } from '@modern-js/utils';
3
3
  import type { UserConfig, NormalizedConfig } from './config';
4
4
  export type BaseHooks<Extends extends {
5
- hooks?: ExtendHooks;
6
- userConfig?: ExtendUserConfig;
7
- normalizedConfig?: ExtendNormalizedConfig;
5
+ hooks?: ExtendHooks;
6
+ userConfig?: ExtendUserConfig;
7
+ normalizedConfig?: ExtendNormalizedConfig;
8
8
  }, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = {
9
- beforeConfig: AsyncWorkflow<void, void>;
10
- config: ParallelWorkflow<void, UserConfig<Extends>>;
11
- resolvedConfig: AsyncWaterfall<{
12
- resolved: NormalizedConfig<Extends>;
13
- }>;
14
- validateSchema: ParallelWorkflow<void>;
15
- prepare: AsyncWorkflow<void, void>;
16
- afterPrepare: AsyncWorkflow<void, void>;
17
- watchFiles: ParallelWorkflow<void, string[] | {
18
- files: string[];
19
- isPrivate: boolean;
20
- }>;
21
- fileChange: AsyncWorkflow<{
22
- filename: string;
23
- eventType: 'add' | 'change' | 'unlink';
24
- isPrivate: boolean;
25
- }, void>;
26
- commands: AsyncWorkflow<{
27
- program: Command;
28
- }, void>;
29
- beforeExit: Workflow<void, void>;
30
- addRuntimeExports: AsyncWaterfall<void>;
9
+ beforeConfig: AsyncWorkflow<void, void>;
10
+ config: ParallelWorkflow<void, UserConfig<Extends>>;
11
+ resolvedConfig: AsyncWaterfall<{
12
+ resolved: NormalizedConfig<Extends>;
13
+ }>;
14
+ validateSchema: ParallelWorkflow<void>;
15
+ prepare: AsyncWorkflow<void, void>;
16
+ afterPrepare: AsyncWorkflow<void, void>;
17
+ watchFiles: ParallelWorkflow<void, string[] | {
18
+ files: string[];
19
+ isPrivate: boolean;
20
+ }>;
21
+ fileChange: AsyncWorkflow<{
22
+ filename: string;
23
+ eventType: 'add' | 'change' | 'unlink';
24
+ isPrivate: boolean;
25
+ }, void>;
26
+ commands: AsyncWorkflow<{
27
+ program: Command;
28
+ }, void>;
29
+ beforeExit: Workflow<void, void>;
30
+ addRuntimeExports: AsyncWaterfall<void>;
31
31
  };
32
32
  export type CliHooksRunner<Extends extends {
33
- hooks?: ExtendHooks;
34
- userConfig?: ExtendUserConfig;
35
- normalizedConfig?: ExtendNormalizedConfig;
33
+ hooks?: ExtendHooks;
34
+ userConfig?: ExtendUserConfig;
35
+ normalizedConfig?: ExtendNormalizedConfig;
36
36
  } = {}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}, ExtendNormalizedConfig extends Record<string, any> = {}> = ToRunners<BaseHooks<Extends> & Extends['hooks']>;
37
37
  export type CliHookCallbacks = ToThreads<BaseHooks<{}>>;
38
38
  export interface DevToolData<DevOptions = any> {
39
+ name: string;
40
+ subCommands?: string[];
41
+ menuItem?: {
39
42
  name: string;
40
- subCommands?: string[];
41
- menuItem?: {
42
- name: string;
43
- value: string;
44
- };
45
- action: (options: DevOptions, context: {
46
- isTsProject?: boolean;
47
- }) => void | Promise<void>;
43
+ value: string;
44
+ };
45
+ action: (options: DevOptions, context: {
46
+ isTsProject?: boolean;
47
+ }) => void | Promise<void>;
48
48
  }
49
49
  export interface RegisterBuildPlatformResult {
50
- platform: string | string[];
51
- build: (currentPlatform: string, context: {
52
- isTsProject: boolean;
53
- }) => void | Promise<void>;
54
- }
50
+ platform: string | string[];
51
+ build: (currentPlatform: string, context: {
52
+ isTsProject: boolean;
53
+ }) => void | Promise<void>;
54
+ }
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -6,6 +6,6 @@ export * from './hooks';
6
6
  export * from './context';
7
7
  export * from './coreOptions';
8
8
  export interface PluginValidateSchema {
9
- target: string;
10
- schema: JSONSchemaType<any>;
11
- }
9
+ target: string;
10
+ schema: JSONSchemaType<any>;
11
+ }
@@ -1,22 +1,11 @@
1
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);
22
- __exportStar(require("./coreOptions"), exports);
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./plugin"), exports);
7
+ _export_star._(require("./config"), exports);
8
+ _export_star._(require("./pluginAPI"), exports);
9
+ _export_star._(require("./hooks"), exports);
10
+ _export_star._(require("./context"), exports);
11
+ _export_star._(require("./coreOptions"), exports);
@@ -4,9 +4,9 @@ import { BasePluginAPI } from './pluginAPI';
4
4
  export type { InternalPlugins } from '@modern-js/types';
5
5
  /** Plugin options of a cli plugin. */
6
6
  export type CliPlugin<Extends extends {
7
- hooks?: ExtendHooks;
8
- userConfig?: ExtendUserConfig;
9
- normalizedConfig?: ExtendNormalizedConfig;
7
+ hooks?: ExtendHooks;
8
+ userConfig?: ExtendUserConfig;
9
+ normalizedConfig?: ExtendNormalizedConfig;
10
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
11
  export type PluginItem = string | [string, any];
12
12
  /**
@@ -15,12 +15,12 @@ export type PluginItem = string | [string, any];
15
15
  */
16
16
  export type OldPluginConfig = Array<PluginItem>;
17
17
  export type NewPluginConfig<PluginTypes extends {
18
- hooks?: Record<string, any>;
19
- userConfig?: Record<string, any>;
20
- normalizedConfig?: Record<string, any>;
18
+ hooks?: Record<string, any>;
19
+ userConfig?: Record<string, any>;
20
+ normalizedConfig?: Record<string, any>;
21
21
  }> = CliPlugin<PluginTypes>[];
22
22
  export type PluginConfig<PluginTypes extends {
23
- hooks?: Record<string, any>;
24
- userConfig?: Record<string, any>;
25
- normalizedConfig?: Record<string, any>;
26
- } = {}> = OldPluginConfig | NewPluginConfig<PluginTypes>;
23
+ hooks?: Record<string, any>;
24
+ userConfig?: Record<string, any>;
25
+ normalizedConfig?: Record<string, any>;
26
+ } = {}> = OldPluginConfig | NewPluginConfig<PluginTypes>;
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -2,17 +2,17 @@ import { CommonAPI } from '@modern-js/plugin';
2
2
  import type { setAppContext, useAppContext, useResolvedConfigContext, useConfigContext } from '../context';
3
3
  import { BaseHooks } from './hooks';
4
4
  export type BasePluginAPI<Extends extends {
5
- hooks?: ExtendHooks;
6
- userConfig?: ExtendUserConfig;
7
- normalizedConfig?: ExtendNormalizedConfig;
5
+ hooks?: ExtendHooks;
6
+ userConfig?: ExtendUserConfig;
7
+ normalizedConfig?: ExtendNormalizedConfig;
8
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>;
9
+ setAppContext: typeof setAppContext;
10
+ useAppContext: typeof useAppContext;
11
+ useConfigContext: typeof useConfigContext<Extends>;
12
+ useResolvedConfigContext: typeof useResolvedConfigContext<Extends>;
13
13
  };
14
14
  /** all apis for cli plugin */
15
15
  export 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']>;
16
+ hooks?: ExtendHooks;
17
+ userConfig?: ExtendUserConfig;
18
+ } = {}, ExtendHooks extends {} = {}, ExtendUserConfig extends Record<string, any> = {}> = BasePluginAPI<Extends> & CommonAPI<BaseHooks<Extends> & Extends['hooks']>;
@@ -1,2 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -1 +1 @@
1
- export declare function checkIsDuplicationPlugin(plugins: (string | undefined)[], autoLoadPlugin?: boolean): void;
1
+ export declare function checkIsDuplicationPlugin(plugins: (string | undefined)[], autoLoadPlugin?: boolean): void;
@@ -1,25 +1,28 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkIsDuplicationPlugin = void 0;
4
- const utils_1 = require("@modern-js/utils");
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "checkIsDuplicationPlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return checkIsDuplicationPlugin;
9
+ }
10
+ });
11
+ const _utils = require("@modern-js/utils");
5
12
  function checkIsDuplicationPlugin(plugins, autoLoadPlugin = false) {
6
- const set = new Set();
7
- const duplicationPlugins = [];
8
- plugins
9
- .filter(plugin => typeof plugin === 'string')
10
- .forEach(plugin => {
11
- if (set.has(plugin)) {
12
- duplicationPlugins.push(plugin);
13
- }
14
- else {
15
- set.add(plugin);
16
- }
17
- });
18
- if (duplicationPlugins.length > 0) {
19
- utils_1.logger.warn(`Duplicate registration plugins: ${duplicationPlugins.join(',')}.`);
20
- if (autoLoadPlugin) {
21
- utils_1.logger.warn('This is probably because you enabled `autoLoadPlugin` configuration and also registered these plugins manually');
22
- }
13
+ const set = /* @__PURE__ */ new Set();
14
+ const duplicationPlugins = [];
15
+ plugins.filter((plugin) => typeof plugin === "string").forEach((plugin) => {
16
+ if (set.has(plugin)) {
17
+ duplicationPlugins.push(plugin);
18
+ } else {
19
+ set.add(plugin);
23
20
  }
21
+ });
22
+ if (duplicationPlugins.length > 0) {
23
+ _utils.logger.warn(`Duplicate registration plugins: ${duplicationPlugins.join(",")}.`);
24
+ if (autoLoadPlugin) {
25
+ _utils.logger.warn("This is probably because you enabled `autoLoadPlugin` configuration and also registered these plugins manually");
26
+ }
27
+ }
24
28
  }
25
- exports.checkIsDuplicationPlugin = checkIsDuplicationPlugin;
@@ -1,4 +1,4 @@
1
1
  import { program, Command } from '@modern-js/utils';
2
2
  export declare function initCommandsMap(): void;
3
3
  export type { Command };
4
- export { program };
4
+ export { program };