@modern-js/app-tools 2.63.0 → 2.63.1-alpha.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 (135) hide show
  1. package/bin/modern.js +1 -1
  2. package/dist/cjs/commands/build.js +19 -13
  3. package/dist/cjs/commands/deploy.js +5 -5
  4. package/dist/cjs/commands/dev.js +11 -11
  5. package/dist/cjs/commands/index.js +6 -6
  6. package/dist/cjs/commands/inspect.js +1 -1
  7. package/dist/cjs/commands/serve.js +4 -4
  8. package/dist/cjs/{new/compat → compat}/hooks.js +15 -8
  9. package/dist/cjs/{new/compat → compat}/index.js +4 -1
  10. package/dist/cjs/{new/compat → compat}/utils.js +10 -1
  11. package/dist/cjs/index.js +154 -5
  12. package/dist/cjs/plugins/analyze/getBundleEntry.js +2 -2
  13. package/dist/cjs/plugins/analyze/getFileSystemEntry.js +9 -9
  14. package/dist/cjs/plugins/analyze/getHtmlTemplate.js +51 -25
  15. package/dist/cjs/plugins/analyze/index.js +128 -130
  16. package/dist/cjs/plugins/deploy/index.js +12 -14
  17. package/dist/cjs/plugins/initialize/index.js +1 -1
  18. package/dist/cjs/plugins/serverBuild.js +30 -32
  19. package/dist/cjs/{new/run.js → run/index.js} +6 -6
  20. package/dist/cjs/{new → utils}/getConfigFile.js +1 -1
  21. package/dist/cjs/{new/context.js → utils/initAppContext.js} +3 -4
  22. package/dist/cjs/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  23. package/dist/cjs/utils/loadPlugins.js +35 -4
  24. package/dist/cjs/utils/printInstructions.js +2 -2
  25. package/dist/cjs/utils/restart.js +4 -3
  26. package/dist/esm/commands/build.js +18 -12
  27. package/dist/esm/commands/deploy.js +6 -6
  28. package/dist/esm/commands/dev.js +10 -10
  29. package/dist/esm/commands/index.js +8 -8
  30. package/dist/esm/commands/inspect.js +1 -1
  31. package/dist/esm/commands/serve.js +5 -5
  32. package/dist/esm/{new/compat → compat}/hooks.js +41 -41
  33. package/dist/esm/{new/compat → compat}/index.js +4 -1
  34. package/dist/esm/{new/compat → compat}/utils.js +10 -1
  35. package/dist/esm/index.js +245 -2
  36. package/dist/esm/plugins/analyze/getBundleEntry.js +3 -3
  37. package/dist/esm/plugins/analyze/getFileSystemEntry.js +12 -12
  38. package/dist/esm/plugins/analyze/getHtmlTemplate.js +101 -28
  39. package/dist/esm/plugins/analyze/index.js +328 -331
  40. package/dist/esm/plugins/deploy/index.js +84 -88
  41. package/dist/esm/plugins/initialize/index.js +1 -1
  42. package/dist/esm/plugins/serverBuild.js +52 -56
  43. package/dist/esm/{new/run.js → run/index.js} +6 -6
  44. package/dist/esm/{new → utils}/getConfigFile.js +1 -1
  45. package/dist/esm/{new/context.js → utils/initAppContext.js} +0 -1
  46. package/dist/esm/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  47. package/dist/esm/utils/loadPlugins.js +95 -7
  48. package/dist/esm/utils/printInstructions.js +3 -3
  49. package/dist/esm/utils/restart.js +5 -4
  50. package/dist/esm-node/commands/build.js +19 -13
  51. package/dist/esm-node/commands/deploy.js +5 -5
  52. package/dist/esm-node/commands/dev.js +11 -11
  53. package/dist/esm-node/commands/index.js +6 -6
  54. package/dist/esm-node/commands/inspect.js +1 -1
  55. package/dist/esm-node/commands/serve.js +4 -4
  56. package/dist/esm-node/{new/compat → compat}/hooks.js +15 -8
  57. package/dist/esm-node/{new/compat → compat}/index.js +4 -1
  58. package/dist/esm-node/{new/compat → compat}/utils.js +10 -1
  59. package/dist/esm-node/index.js +140 -2
  60. package/dist/esm-node/plugins/analyze/getBundleEntry.js +2 -2
  61. package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +9 -9
  62. package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +49 -24
  63. package/dist/esm-node/plugins/analyze/index.js +128 -130
  64. package/dist/esm-node/plugins/deploy/index.js +12 -14
  65. package/dist/esm-node/plugins/initialize/index.js +1 -1
  66. package/dist/esm-node/plugins/serverBuild.js +30 -32
  67. package/dist/esm-node/{new/run.js → run/index.js} +6 -6
  68. package/dist/esm-node/{new → utils}/getConfigFile.js +1 -1
  69. package/dist/esm-node/{new/context.js → utils/initAppContext.js} +0 -1
  70. package/dist/esm-node/{new/utils/index.js → utils/isAutoLoadPlugins.js} +2 -2
  71. package/dist/esm-node/utils/loadPlugins.js +34 -4
  72. package/dist/esm-node/utils/printInstructions.js +2 -2
  73. package/dist/esm-node/utils/restart.js +4 -3
  74. package/dist/types/builder/generator/adapterCopy.d.ts +2 -1
  75. package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +3 -2
  76. package/dist/types/builder/generator/createCopyPattern.d.ts +4 -3
  77. package/dist/types/builder/generator/getBuilderEnvironments.d.ts +2 -2
  78. package/dist/types/builder/index.d.ts +1 -1
  79. package/dist/types/builder/shared/createCopyInfo.d.ts +3 -2
  80. package/dist/types/builder/shared/types.d.ts +3 -2
  81. package/dist/types/commands/build.d.ts +2 -2
  82. package/dist/types/commands/deploy.d.ts +2 -2
  83. package/dist/types/commands/dev.d.ts +2 -2
  84. package/dist/types/commands/index.d.ts +6 -6
  85. package/dist/types/commands/inspect.d.ts +2 -2
  86. package/dist/types/commands/serve.d.ts +2 -2
  87. package/dist/types/{new/compat → compat}/hooks.d.ts +2 -2
  88. package/dist/types/compat/index.d.ts +2 -0
  89. package/dist/types/config/initialize/index.d.ts +3 -2
  90. package/dist/types/config/initialize/inits.d.ts +4 -3
  91. package/dist/types/index.d.ts +5 -3
  92. package/dist/types/plugins/analyze/getBundleEntry.d.ts +3 -3
  93. package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +3 -3
  94. package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +26 -5
  95. package/dist/types/plugins/analyze/getServerRoutes.d.ts +2 -2
  96. package/dist/types/plugins/analyze/index.d.ts +2 -3
  97. package/dist/types/plugins/deploy/index.d.ts +2 -3
  98. package/dist/types/plugins/deploy/platforms/platform.d.ts +3 -3
  99. package/dist/types/plugins/deploy/utils.d.ts +2 -2
  100. package/dist/types/plugins/serverBuild.d.ts +2 -2
  101. package/dist/types/types/index.d.ts +2 -0
  102. package/dist/types/types/new.d.ts +46 -34
  103. package/dist/types/utils/generateWatchFiles.d.ts +2 -2
  104. package/dist/types/{new/context.d.ts → utils/initAppContext.d.ts} +0 -1
  105. package/dist/types/utils/isAutoLoadPlugins.d.ts +1 -0
  106. package/dist/types/utils/loadPlugins.d.ts +13 -3
  107. package/dist/types/utils/printInstructions.d.ts +3 -3
  108. package/dist/types/utils/restart.d.ts +2 -3
  109. package/dist/types/utils/routes.d.ts +2 -1
  110. package/package.json +14 -15
  111. package/dist/cjs/hooks.js +0 -60
  112. package/dist/cjs/new/index.js +0 -79
  113. package/dist/cjs/new/loadPlugins.js +0 -57
  114. package/dist/cjs/old.js +0 -179
  115. package/dist/esm/hooks.js +0 -36
  116. package/dist/esm/new/index.js +0 -55
  117. package/dist/esm/new/loadPlugins.js +0 -94
  118. package/dist/esm/old.js +0 -258
  119. package/dist/esm-node/hooks.js +0 -36
  120. package/dist/esm-node/new/index.js +0 -52
  121. package/dist/esm-node/new/loadPlugins.js +0 -33
  122. package/dist/esm-node/old.js +0 -140
  123. package/dist/types/hooks.d.ts +0 -2
  124. package/dist/types/new/compat/index.d.ts +0 -2
  125. package/dist/types/new/index.d.ts +0 -6
  126. package/dist/types/new/loadPlugins.d.ts +0 -9
  127. package/dist/types/new/utils/index.d.ts +0 -1
  128. package/dist/types/old.d.ts +0 -13
  129. /package/dist/cjs/{new/constants.js → constants.js} +0 -0
  130. /package/dist/esm/{new/constants.js → constants.js} +0 -0
  131. /package/dist/esm-node/{new/constants.js → constants.js} +0 -0
  132. /package/dist/types/{new/compat → compat}/utils.d.ts +0 -0
  133. /package/dist/types/{new/constants.d.ts → constants.d.ts} +0 -0
  134. /package/dist/types/{new/run.d.ts → run/index.d.ts} +0 -0
  135. /package/dist/types/{new → utils}/getConfigFile.d.ts +0 -0
@@ -1,10 +1,10 @@
1
- import type { PluginAPI } from '@modern-js/core';
1
+ import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
2
  import { type Command } from '@modern-js/utils';
3
3
  import type { AppTools } from '../types';
4
- export declare const devCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
5
- export declare const buildCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
6
- export declare const serverCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => void;
7
- export declare const deployCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => void;
4
+ export declare const devCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => Promise<void>;
5
+ export declare const buildCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => Promise<void>;
6
+ export declare const serverCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => void;
7
+ export declare const deployCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => void;
8
8
  export declare const newCommand: (program: Command, locale: string) => void;
9
- export declare const inspectCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => void;
9
+ export declare const inspectCommand: (program: Command, api: CLIPluginAPI<AppTools<'shared'>>) => void;
10
10
  export declare const upgradeCommand: (program: Command) => void;
@@ -1,4 +1,4 @@
1
- import type { PluginAPI } from '@modern-js/core';
1
+ import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
2
  import type { AppTools } from '../types';
3
3
  import type { InspectOptions } from '../utils/types';
4
- export declare const inspect: (api: PluginAPI<AppTools<'shared'>>, options: InspectOptions) => Promise<import("@rsbuild/core").InspectConfigResult<"rspack">>;
4
+ export declare const inspect: (api: CLIPluginAPI<AppTools<'shared'>>, options: InspectOptions) => Promise<import("@rsbuild/core").InspectConfigResult<"rspack">>;
@@ -1,3 +1,3 @@
1
- import type { PluginAPI } from '@modern-js/core';
1
+ import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
2
  import type { AppTools } from '../types';
3
- export declare const start: (api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
3
+ export declare const start: (api: CLIPluginAPI<AppTools<'shared'>>) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import type { InternalContext } from '@modern-js/plugin-v2';
2
- import type { AppTools } from '../../types';
2
+ import type { AppTools } from '../types';
3
3
  /**
4
4
  * old plugin useHookRunners function result
5
5
  */
6
- export declare function getHookRunners(context: InternalContext<AppTools>): Record<string, any>;
6
+ export declare function getHookRunners(context: InternalContext<AppTools<'shared'>>): Record<string, any>;
7
7
  export declare function handleSetupResult(setupResult: Record<string, (...args: any) => any>, api: Record<string, any>): void;
@@ -0,0 +1,2 @@
1
+ import type { AppTools, CliPluginFuture } from '../types';
2
+ export declare const compatPlugin: () => CliPluginFuture<AppTools<'shared'>>;
@@ -1,2 +1,3 @@
1
- import type { AppNormalizedConfig, IAppContext } from '../../types';
2
- export declare function initialNormalizedConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): AppNormalizedConfig<'shared'>;
1
+ import type { AppNormalizedConfig } from '../../types';
2
+ import type { AppToolsContext } from '../../types/new';
3
+ export declare function initialNormalizedConfig(config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>, bundler: 'webpack' | 'rspack'): AppNormalizedConfig<'shared'>;
@@ -1,4 +1,5 @@
1
- import type { AppNormalizedConfig, IAppContext } from '../../types';
2
- export declare function initHtmlConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext): AppNormalizedConfig<'shared'>['html'];
3
- export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): void;
1
+ import type { AppNormalizedConfig } from '../../types';
2
+ import type { AppToolsContext } from '../../types/new';
3
+ export declare function initHtmlConfig(config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>): AppNormalizedConfig<'shared'>['html'];
4
+ export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>, bundler: 'webpack' | 'rspack'): void;
4
5
  export declare function createBuilderModuleScope(config: AppNormalizedConfig<'webpack'>): (string | RegExp)[] | undefined;
@@ -1,10 +1,12 @@
1
- import { appTools } from './new/index';
2
- export { appTools };
3
- export { initAppContext } from './new/index';
1
+ import type { AppTools, AppToolsOptions, CliPluginFuture } from './types';
2
+ import { initAppContext } from './utils/initAppContext';
3
+ export * from './defineConfig';
4
+ export declare const appTools: (options?: AppToolsOptions) => CliPluginFuture<AppTools<'shared'>>;
4
5
  export { defineConfig, defineLegacyConfig } from './defineConfig';
5
6
  export { mergeConfig } from '@modern-js/core';
6
7
  export type { RuntimeUserConfig } from './types/config';
7
8
  export { dev } from './commands/dev';
8
9
  export type { DevOptions } from './utils/types';
9
10
  export * from './types';
11
+ export { initAppContext };
10
12
  export default appTools;
@@ -1,4 +1,4 @@
1
- import type { CliHooksRunner } from '@modern-js/core';
2
1
  import type { Entrypoint } from '@modern-js/types';
3
- import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
4
- export declare const getBundleEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
+ export declare const getBundleEntry: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
@@ -1,5 +1,5 @@
1
- import type { CliHooksRunner } from '@modern-js/core';
2
1
  import type { Entrypoint } from '@modern-js/types';
3
- import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
4
  export type { Entrypoint };
5
- export declare const getFileSystemEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
5
+ export declare const getFileSystemEntry: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
@@ -1,6 +1,27 @@
1
- import type { Entrypoint, HtmlTemplates } from '@modern-js/types';
2
- import type { AppNormalizedConfig, AppTools, IAppContext, PluginAPI } from '../../types';
3
- export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>, { appContext, config, }: {
4
- appContext: IAppContext;
1
+ import type { Entrypoint, HtmlPartials, HtmlTemplates } from '@modern-js/types';
2
+ import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext, AppToolsHooks } from '../../types/new';
4
+ export declare const getModifyHtmlPartials: (partials: Record<keyof HtmlPartials, string[]>) => {
5
+ top: {
6
+ append: (...script: string[]) => void;
7
+ prepend: (...script: string[]) => void;
8
+ current: string[];
9
+ };
10
+ head: {
11
+ append: (...script: string[]) => void;
12
+ prepend: (...script: string[]) => void;
13
+ current: string[];
14
+ };
15
+ body: {
16
+ append: (...script: string[]) => void;
17
+ prepend: (...script: string[]) => void;
18
+ current: string[];
19
+ };
20
+ };
21
+ export declare const getHtmlTemplate: (entrypoints: Entrypoint[], hooks: AppToolsHooks<'shared'>, { appContext, config, }: {
22
+ appContext: AppToolsContext<'shared'>;
5
23
  config: AppNormalizedConfig<'shared'>;
6
- }) => Promise<HtmlTemplates>;
24
+ }) => Promise<{
25
+ partialsByEntrypoint: Record<string, HtmlPartials>;
26
+ htmlTemplates: HtmlTemplates;
27
+ }>;
@@ -1,7 +1,7 @@
1
- import type { IAppContext } from '@modern-js/core';
2
1
  import type { Entrypoint, ServerRoute } from '@modern-js/types';
3
2
  import type { AppNormalizedConfig } from '../../types';
3
+ import type { AppToolsContext } from '../../types/new';
4
4
  export declare const getServerRoutes: (entrypoints: Entrypoint[], { appContext, config, }: {
5
- appContext: IAppContext;
5
+ appContext: AppToolsContext<'shared'>;
6
6
  config: AppNormalizedConfig<'shared'>;
7
7
  }) => ServerRoute[];
@@ -1,6 +1,5 @@
1
- import type { CliPlugin } from '@modern-js/core';
2
- import type { AppTools } from '../../types';
1
+ import type { AppTools, CliPluginFuture } from '../../types';
3
2
  declare const _default: ({ bundler, }: {
4
3
  bundler: 'webpack' | 'rspack';
5
- }) => CliPlugin<AppTools<'shared'>>;
4
+ }) => CliPluginFuture<AppTools<'shared'>>;
6
5
  export default _default;
@@ -1,4 +1,3 @@
1
- import type { CliPlugin } from '@modern-js/core';
2
- import type { AppTools } from '../../types';
3
- declare const _default: () => CliPlugin<AppTools>;
1
+ import type { AppTools, CliPluginFuture } from '../../types';
2
+ declare const _default: () => CliPluginFuture<AppTools<'shared'>>;
4
3
  export default _default;
@@ -1,6 +1,6 @@
1
- import type { IAppContext, NormalizedConfig } from '@modern-js/core';
2
- import type { AppTools } from '../../../types';
3
- export type CreatePreset = (appContext: IAppContext, config: NormalizedConfig<AppTools>, needModernServer?: boolean) => DeployPreset;
1
+ import type { AppToolsNormalizedConfig } from '../../../types';
2
+ import type { AppToolsContext } from '../../../types/new';
3
+ export type CreatePreset = (appContext: AppToolsContext<'shared'>, config: AppToolsNormalizedConfig, needModernServer?: boolean) => DeployPreset;
4
4
  type DeployPreset = {
5
5
  prepare?: () => Promise<void>;
6
6
  writeOutput?: () => Promise<void>;
@@ -1,11 +1,11 @@
1
- import type { IAppContext } from '@modern-js/core';
1
+ import type { AppToolsContext } from '../../types/new';
2
2
  export type ServerAppContext = {
3
3
  sharedDirectory: string;
4
4
  apiDirectory: string;
5
5
  lambdaDirectory: string;
6
6
  metaName: string;
7
7
  };
8
- export declare const serverAppContenxtTemplate: (appContext: IAppContext) => {
8
+ export declare const serverAppContenxtTemplate: (appContext: AppToolsContext<'shared'>) => {
9
9
  sharedDirectory: string;
10
10
  apiDirectory: string;
11
11
  lambdaDirectory: string;
@@ -1,3 +1,3 @@
1
- import type { AppTools, CliPlugin } from '../types';
2
- declare const _default: () => CliPlugin<AppTools>;
1
+ import type { AppTools, CliPluginFuture } from '../types';
2
+ declare const _default: () => CliPluginFuture<AppTools<'shared'>>;
3
3
  export default _default;
@@ -5,6 +5,7 @@ import type { AppToolsHooks } from './hooks';
5
5
  import type { AppToolsLegacyNormalizedConfig, AppToolsLegacyUserConfig } from './legacyConfig';
6
6
  import type { AppToolsExtendAPI, AppToolsExtendContext, AppToolsExtendHooks } from './new';
7
7
  import type { Bundler } from './utils';
8
+ export type { CLIPluginExtends };
8
9
  export * from './hooks';
9
10
  export * from './config';
10
11
  export * from './legacyConfig';
@@ -33,3 +34,4 @@ export type AppToolsOptions = {
33
34
  * */
34
35
  bundler?: 'rspack' | 'webpack' | 'experimental-rspack';
35
36
  };
37
+ export type { AppToolsExtendAPI, AppToolsExtendContext, AppToolsExtendHooks, AppToolsContext, AppToolsHooks as AppToolsFeatureHooks, } from './new';
@@ -1,8 +1,9 @@
1
1
  import type { DevToolData, RegisterBuildPlatformResult } from '@modern-js/core';
2
- import type { AppContext, InternalContext, PluginHook, PluginHookTap, TransformFunction } from '@modern-js/plugin-v2';
3
- import type { Entrypoint, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
2
+ import type { AppContext, AsyncHook, CollectAsyncHook, InternalContext, PluginHook, PluginHookTap, TransformFunction } from '@modern-js/plugin-v2';
3
+ import type { Hooks } from '@modern-js/plugin-v2/cli';
4
+ import type { Entrypoint, HtmlPartials, HtmlTemplates, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
4
5
  import type { AppTools } from '.';
5
- import type { getHookRunners } from '../new/compat/hooks';
6
+ import type { getHookRunners } from '../compat/hooks';
6
7
  import type { AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
7
8
  import type { RuntimePlugin } from './hooks';
8
9
  import type { Bundler } from './utils';
@@ -40,22 +41,9 @@ export type BeforeGenerateRoutesFn = TransformFunction<{
40
41
  export type BeforePrintInstructionsFn = TransformFunction<{
41
42
  instructions: string;
42
43
  }>;
43
- export type RegisterDevFn = (params: {
44
- name: string;
45
- entry: string;
46
- type: string;
47
- config: any;
48
- }) => Promise<DevToolData> | DevToolData;
49
- export type RegisterBuildPlatformFn = (params: {
50
- name: string;
51
- entry: string;
52
- type: string;
53
- config: any;
54
- }) => Promise<RegisterBuildPlatformResult> | RegisterBuildPlatformResult;
55
- export type AddRuntimeExportsFn = (params: {
56
- entrypoint: Entrypoint;
57
- exports: string[];
58
- }) => Promise<void> | void;
44
+ export type RegisterDevFn = () => Promise<DevToolData> | DevToolData;
45
+ export type RegisterBuildPlatformFn = () => Promise<RegisterBuildPlatformResult> | RegisterBuildPlatformResult;
46
+ export type AddRuntimeExportsFn = () => Promise<void> | void;
59
47
  export interface AppToolsExtendAPI<B extends Bundler = 'webpack'> {
60
48
  onBeforeConfig: PluginHookTap<BeforeConfigFn>;
61
49
  onAfterPrepare: PluginHookTap<AfterPrepareFn>;
@@ -102,33 +90,33 @@ export interface AppToolsExtendAPI<B extends Bundler = 'webpack'> {
102
90
  useHookRunners: () => ReturnType<typeof getHookRunners>;
103
91
  }
104
92
  export interface AppToolsExtendHooks extends Record<string, PluginHook<(...args: any[]) => any>> {
105
- onBeforeConfig: PluginHook<BeforeConfigFn>;
106
- onAfterPrepare: PluginHook<AfterPrepareFn>;
107
- deploy: PluginHook<DeplpoyFn>;
108
- _internalRuntimePlugins: PluginHook<InternalRuntimePluginsFn>;
109
- _internalServerPlugins: PluginHook<InternalServerPluginsFn>;
110
- checkEntryPoint: PluginHook<CheckEntryPointFn>;
111
- modifyEntrypoints: PluginHook<ModifyEntrypointsFn>;
112
- modifyFileSystemRoutes: PluginHook<ModifyFileSystemRoutesFn>;
113
- modifyServerRoutes: PluginHook<ModifyServerRoutesFn>;
114
- generateEntryCode: PluginHook<GenerateEntryCodeFn>;
115
- onBeforeGenerateRoutes: PluginHook<BeforeGenerateRoutesFn>;
93
+ onBeforeConfig: AsyncHook<BeforeConfigFn>;
94
+ onAfterPrepare: AsyncHook<AfterPrepareFn>;
95
+ deploy: AsyncHook<DeplpoyFn>;
96
+ _internalRuntimePlugins: AsyncHook<InternalRuntimePluginsFn>;
97
+ _internalServerPlugins: AsyncHook<InternalServerPluginsFn>;
98
+ checkEntryPoint: AsyncHook<CheckEntryPointFn>;
99
+ modifyEntrypoints: AsyncHook<ModifyEntrypointsFn>;
100
+ modifyFileSystemRoutes: AsyncHook<ModifyFileSystemRoutesFn>;
101
+ modifyServerRoutes: AsyncHook<ModifyServerRoutesFn>;
102
+ generateEntryCode: AsyncHook<GenerateEntryCodeFn>;
103
+ onBeforeGenerateRoutes: AsyncHook<BeforeGenerateRoutesFn>;
116
104
  /**
117
105
  * @deprecated
118
106
  */
119
- onBeforePrintInstructions: PluginHook<BeforePrintInstructionsFn>;
107
+ onBeforePrintInstructions: AsyncHook<BeforePrintInstructionsFn>;
120
108
  /**
121
109
  * @deprecated
122
110
  */
123
- registerDev: PluginHook<RegisterDevFn>;
111
+ registerDev: CollectAsyncHook<RegisterDevFn>;
124
112
  /**
125
113
  * @deprecated
126
114
  */
127
- registerBuildPlatform: PluginHook<RegisterBuildPlatformFn>;
115
+ registerBuildPlatform: CollectAsyncHook<RegisterBuildPlatformFn>;
128
116
  /**
129
117
  * @deprecated
130
118
  */
131
- addRuntimeExports: PluginHook<AddRuntimeExportsFn>;
119
+ addRuntimeExports: AsyncHook<AddRuntimeExportsFn>;
132
120
  }
133
121
  export type AppToolsExtendContext<B extends Bundler = 'webpack'> = {
134
122
  metaName: string;
@@ -138,8 +126,32 @@ export type AppToolsExtendContext<B extends Bundler = 'webpack'> = {
138
126
  internalSrcAlias: string;
139
127
  apiDirectory: string;
140
128
  lambdaDirectory: string;
129
+ serverConfigFile: string;
141
130
  serverPlugins: ServerPlugin[];
142
131
  moduleType: 'module' | 'commonjs';
132
+ /** Information for entry points */
133
+ entrypoints: Entrypoint[];
134
+ /** Selected entry points */
135
+ checkedEntries: string[];
136
+ /** Information for server routes */
137
+ serverRoutes: ServerRoute[];
138
+ /** Whether to use api only mode */
139
+ apiOnly: boolean;
143
140
  _internalContext: InternalContext<AppTools<B>>;
141
+ /**
142
+ * Information for HTML templates by entry
143
+ * @private
144
+ */
145
+ partialsByEntrypoint?: Record<string, HtmlPartials>;
146
+ /**
147
+ * Information for HTML templates
148
+ * @private
149
+ */
150
+ htmlTemplates: HtmlTemplates;
151
+ /**
152
+ * @deprecated compat old plugin, default is app tools
153
+ */
154
+ toolsType?: string;
144
155
  };
145
156
  export type AppToolsContext<B extends Bundler = 'webpack'> = AppContext<AppTools<B>> & AppToolsExtendContext<B>;
157
+ export type AppToolsHooks<B extends Bundler = 'webpack'> = Hooks<AppToolsUserConfig<B>, AppToolsNormalizedConfig> & AppToolsExtendHooks;
@@ -1,3 +1,3 @@
1
- import type { IAppContext } from '../types';
1
+ import type { AppToolsContext } from '../types/new';
2
2
  export declare const addServerConfigToDeps: (dependencies: string[], appDirectory: string, serverConfigFile: string) => Promise<void>;
3
- export declare function generateWatchFiles(appContext: IAppContext, configDir?: string): Promise<string[]>;
3
+ export declare function generateWatchFiles(appContext: AppToolsContext<'shared'>, configDir?: string): Promise<string[]>;
@@ -20,7 +20,6 @@ export declare const initAppContext: ({ appDirectory, runtimeConfigFile, options
20
20
  apiDirectory: string;
21
21
  lambdaDirectory: string;
22
22
  sharedDirectory: string;
23
- distDirectory: string;
24
23
  serverPlugins: never[];
25
24
  internalDirectory: string;
26
25
  htmlTemplates: {};
@@ -0,0 +1 @@
1
+ export declare function isAutoLoadPlugins(appDirectory: string, configFile?: string, packageJsonConfig?: string): Promise<boolean>;
@@ -1,5 +1,15 @@
1
+ import type { CLIPluginAPI } from '@modern-js/plugin-v2';
2
+ import type { Plugin } from '@modern-js/plugin-v2';
1
3
  import type { ServerPlugin as ServerPluginInstance } from '@modern-js/server-core';
2
4
  import type { ServerPlugin } from '@modern-js/types';
3
- import type { AppTools, PluginAPI } from '../types';
4
- export declare function getServerPlugins(api: PluginAPI<AppTools<'shared'>>, metaName?: string): Promise<ServerPlugin[]>;
5
- export declare function loadServerPlugins(api: PluginAPI<AppTools<'shared'>>, appDirectory: string, metaName: string): Promise<ServerPluginInstance[]>;
5
+ import type { InternalPlugins } from '@modern-js/types';
6
+ import type { AppTools } from '../types';
7
+ export declare function getServerPlugins(api: CLIPluginAPI<AppTools<'shared'>>, metaName?: string): Promise<ServerPlugin[]>;
8
+ export declare function loadServerPlugins(api: CLIPluginAPI<AppTools<'shared'>>, appDirectory: string, metaName: string): Promise<ServerPluginInstance[]>;
9
+ /**
10
+ * Load internal plugins which in @modern-js scope and user's custom plugins.
11
+ * @param appDirectory - Application root directory.
12
+ * @param internalPlugins - Internal plugins.
13
+ * @returns Plugin Objects has been required.
14
+ */
15
+ export declare const loadInternalPlugins: (appDirectory: string, internalPlugins?: InternalPlugins, autoLoad?: InternalPlugins, autoLoadPlugins?: boolean) => Promise<Plugin[]>;
@@ -1,3 +1,3 @@
1
- import type { CliHooksRunner, IAppContext } from '@modern-js/core';
2
- import type { AppNormalizedConfig, AppTools } from '../types';
3
- export declare const printInstructions: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<void>;
1
+ import type { AppNormalizedConfig } from '../types';
2
+ import type { AppToolsContext, AppToolsHooks } from '../types/new';
3
+ export declare const printInstructions: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<void>;
@@ -1,3 +1,2 @@
1
- import type { ToRunners } from '@modern-js/core';
2
- import type { AppToolsHooks } from '../types/hooks';
3
- export declare function restart(hooksRunner: ToRunners<AppToolsHooks>, filename: string): Promise<void>;
1
+ import type { AppToolsHooks } from '../types/new';
2
+ export declare function restart(hooks: AppToolsHooks<'shared'>, filename: string): Promise<void>;
@@ -1,4 +1,5 @@
1
1
  import type { IAppContext } from '@modern-js/core';
2
- export declare const generateRoutes: (appContext: IAppContext) => Promise<void>;
2
+ import type { AppToolsContext } from '../types/new';
3
+ export declare const generateRoutes: (appContext: AppToolsContext<'shared'> | IAppContext) => Promise<void>;
3
4
  export declare const getPathWithoutExt: (filename: string) => string;
4
5
  export declare const isMainEntry: (entryName: string, mainEntryName?: string) => boolean;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.63.0",
18
+ "version": "2.63.1-alpha.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -35,9 +35,9 @@
35
35
  "default": "./dist/cjs/index.js"
36
36
  },
37
37
  "./cli/run": {
38
- "types": "./dist/types/new/run.d.ts",
39
- "jsnext:source": "./src/new/run.ts",
40
- "default": "./dist/cjs/new/run.js"
38
+ "types": "./dist/types/run/index.d.ts",
39
+ "jsnext:source": "./src/run/index.ts",
40
+ "default": "./dist/cjs/run/index.js"
41
41
  },
42
42
  "./types": {
43
43
  "types": "./lib/types.d.ts",
@@ -64,7 +64,7 @@
64
64
  "./dist/types/index.d.ts"
65
65
  ],
66
66
  "cli/run": [
67
- "./dist/types/new/run.d.ts"
67
+ "./dist/types/run/index.d.ts"
68
68
  ],
69
69
  "types": [
70
70
  "./lib/types.d.ts"
@@ -85,8 +85,8 @@
85
85
  "@babel/parser": "^7.22.15",
86
86
  "@babel/traverse": "^7.23.2",
87
87
  "@babel/types": "^7.26.0",
88
- "@rsbuild/core": "~1.1.5",
89
- "@rsbuild/plugin-node-polyfill": "~1.2.0",
88
+ "@rsbuild/core": "1.1.8",
89
+ "@rsbuild/plugin-node-polyfill": "1.2.0",
90
90
  "@swc/helpers": "0.5.13",
91
91
  "@vercel/nft": "^0.26.4",
92
92
  "es-module-lexer": "^1.1.0",
@@ -96,23 +96,23 @@
96
96
  "mlly": "^1.6.1",
97
97
  "pkg-types": "^1.1.0",
98
98
  "std-env": "^3.7.0",
99
- "@modern-js/plugin-v2": "2.63.0",
100
- "@modern-js/node-bundle-require": "2.63.0",
101
99
  "@modern-js/core": "2.63.0",
100
+ "@modern-js/node-bundle-require": "2.63.0",
102
101
  "@modern-js/plugin": "2.63.0",
103
102
  "@modern-js/plugin-i18n": "2.63.0",
104
- "@modern-js/plugin-data-loader": "2.63.0",
105
- "@modern-js/rsbuild-plugin-esbuild": "2.63.0",
103
+ "@modern-js/plugin-v2": "2.63.0",
106
104
  "@modern-js/prod-server": "2.63.0",
105
+ "@modern-js/rsbuild-plugin-esbuild": "2.63.0",
107
106
  "@modern-js/server": "2.63.0",
108
107
  "@modern-js/server-core": "2.63.0",
109
108
  "@modern-js/server-utils": "2.63.0",
110
109
  "@modern-js/types": "2.63.0",
111
110
  "@modern-js/uni-builder": "2.63.0",
112
- "@modern-js/utils": "2.63.0"
111
+ "@modern-js/utils": "2.63.0",
112
+ "@modern-js/plugin-data-loader": "2.63.0"
113
113
  },
114
114
  "devDependencies": {
115
- "@rsbuild/plugin-webpack-swc": "~1.0.8",
115
+ "@rsbuild/plugin-webpack-swc": "1.0.9",
116
116
  "@types/babel__traverse": "7.20.6",
117
117
  "@types/jest": "^29",
118
118
  "@types/node": "^16",
@@ -139,8 +139,7 @@
139
139
  "sideEffects": false,
140
140
  "publishConfig": {
141
141
  "registry": "https://registry.npmjs.org/",
142
- "access": "public",
143
- "provenance": true
142
+ "access": "public"
144
143
  },
145
144
  "scripts": {
146
145
  "new": "modern-lib new",
package/dist/cjs/hooks.js DELETED
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var hooks_exports = {};
20
- __export(hooks_exports, {
21
- hooks: () => hooks
22
- });
23
- module.exports = __toCommonJS(hooks_exports);
24
- var import_plugin = require("@modern-js/plugin");
25
- const hooks = {
26
- _internalRuntimePlugins: (0, import_plugin.createAsyncWaterfall)(),
27
- modifyFileSystemRoutes: (0, import_plugin.createAsyncWaterfall)(),
28
- modifyServerRoutes: (0, import_plugin.createAsyncWaterfall)(),
29
- /** add entry point info to entrypoints array */
30
- modifyEntrypoints: (0, import_plugin.createAsyncWaterfall)(),
31
- /** add entry type */
32
- checkEntryPoint: (0, import_plugin.createAsyncWaterfall)(),
33
- generateEntryCode: (0, import_plugin.createAsyncWorkflow)(),
34
- htmlPartials: (0, import_plugin.createAsyncWaterfall)(),
35
- beforeGenerateRoutes: (0, import_plugin.createAsyncWaterfall)(),
36
- _internalServerPlugins: (0, import_plugin.createAsyncWaterfall)(),
37
- beforeDev: (0, import_plugin.createAsyncWorkflow)(),
38
- afterDev: (0, import_plugin.createAsyncWorkflow)(),
39
- beforeCreateCompiler: (0, import_plugin.createAsyncWorkflow)(),
40
- afterCreateCompiler: (0, import_plugin.createAsyncWorkflow)(),
41
- beforePrintInstructions: (0, import_plugin.createAsyncWaterfall)(),
42
- beforeBuild: (0, import_plugin.createAsyncWorkflow)(),
43
- afterBuild: (0, import_plugin.createAsyncWorkflow)(),
44
- beforeDeploy: (0, import_plugin.createAsyncWorkflow)(),
45
- deploy: (0, import_plugin.createAsyncWorkflow)(),
46
- afterDeploy: (0, import_plugin.createAsyncWorkflow)(),
47
- beforeRestart: (0, import_plugin.createAsyncWorkflow)(),
48
- /**
49
- * @deprecated
50
- */
51
- registerDev: (0, import_plugin.createParallelWorkflow)(),
52
- /**
53
- * @deprecated
54
- */
55
- registerBuildPlatform: (0, import_plugin.createParallelWorkflow)()
56
- };
57
- // Annotate the CommonJS export names for ESM import in node:
58
- 0 && (module.exports = {
59
- hooks
60
- });
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var new_exports = {};
21
- __export(new_exports, {
22
- appTools: () => appTools,
23
- initAppContext: () => import_context.initAppContext
24
- });
25
- module.exports = __toCommonJS(new_exports);
26
- var import_plugin_v2 = require("@modern-js/plugin-v2");
27
- var import_old = require("../old");
28
- var import_compat = require("./compat");
29
- var import_constants = require("./constants");
30
- var import_context = require("./context");
31
- __reExport(new_exports, require("../defineConfig"), module.exports);
32
- const appTools = (options = {
33
- // default webpack to be compatible with original projects
34
- bundler: "webpack"
35
- }) => ({
36
- name: "@modern-js/app-tools",
37
- usePlugins: [
38
- (0, import_compat.compatPlugin)(),
39
- (0, import_old.appTools)(options)
40
- ],
41
- post: [
42
- "@modern-js/app-tools-old"
43
- ],
44
- registryHooks: {
45
- onBeforeConfig: (0, import_plugin_v2.createAsyncHook)(),
46
- onAfterPrepare: (0, import_plugin_v2.createAsyncHook)(),
47
- deploy: (0, import_plugin_v2.createAsyncHook)(),
48
- _internalRuntimePlugins: (0, import_plugin_v2.createAsyncHook)(),
49
- _internalServerPlugins: (0, import_plugin_v2.createAsyncHook)(),
50
- checkEntryPoint: (0, import_plugin_v2.createAsyncHook)(),
51
- modifyEntrypoints: (0, import_plugin_v2.createAsyncHook)(),
52
- modifyFileSystemRoutes: (0, import_plugin_v2.createAsyncHook)(),
53
- modifyServerRoutes: (0, import_plugin_v2.createAsyncHook)(),
54
- generateEntryCode: (0, import_plugin_v2.createAsyncHook)(),
55
- onBeforeGenerateRoutes: (0, import_plugin_v2.createAsyncHook)(),
56
- onBeforePrintInstructions: (0, import_plugin_v2.createAsyncHook)(),
57
- registerDev: (0, import_plugin_v2.createAsyncHook)(),
58
- registerBuildPlatform: (0, import_plugin_v2.createAsyncHook)(),
59
- addRuntimeExports: (0, import_plugin_v2.createAsyncHook)()
60
- },
61
- setup: (api) => {
62
- var _userConfig_output;
63
- const context = api.getAppContext();
64
- const userConfig = api.getConfig();
65
- api.updateAppContext((0, import_context.initAppContext)({
66
- appDirectory: context.appDirectory,
67
- options: {},
68
- serverConfigFile: import_constants.DEFAULT_SERVER_CONFIG_FILE,
69
- runtimeConfigFile: import_constants.DEFAULT_RUNTIME_CONFIG_FILE,
70
- tempDir: (_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir
71
- }));
72
- }
73
- });
74
- // Annotate the CommonJS export names for ESM import in node:
75
- 0 && (module.exports = {
76
- appTools,
77
- initAppContext,
78
- ...require("../defineConfig")
79
- });