@modern-js/app-tools 2.63.1 → 2.63.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) 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 +21 -6
  9. package/dist/cjs/{new/compat → compat}/index.js +7 -2
  10. package/dist/cjs/{new/compat → compat}/utils.js +29 -8
  11. package/dist/cjs/config/default.js +6 -1
  12. package/dist/cjs/config/legacy/index.js +0 -1
  13. package/dist/cjs/index.js +154 -5
  14. package/dist/cjs/plugins/analyze/getServerRoutes.js +12 -2
  15. package/dist/cjs/plugins/analyze/index.js +25 -10
  16. package/dist/cjs/plugins/analyze/utils.js +6 -0
  17. package/dist/cjs/plugins/deploy/platforms/netlify.js +7 -4
  18. package/dist/cjs/plugins/deploy/platforms/node.js +6 -3
  19. package/dist/cjs/plugins/deploy/platforms/vercel.js +7 -4
  20. package/dist/cjs/plugins/serverBuild.js +30 -32
  21. package/dist/cjs/{new/run.js → run/index.js} +6 -6
  22. package/dist/cjs/{new → utils}/getConfigFile.js +1 -1
  23. package/dist/cjs/{new/context.js → utils/initAppContext.js} +3 -3
  24. package/dist/cjs/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  25. package/dist/cjs/utils/loadPlugins.js +35 -4
  26. package/dist/cjs/utils/printInstructions.js +2 -11
  27. package/dist/cjs/utils/restart.js +2 -2
  28. package/dist/esm/commands/build.js +18 -12
  29. package/dist/esm/commands/deploy.js +6 -6
  30. package/dist/esm/commands/dev.js +11 -11
  31. package/dist/esm/commands/index.js +8 -8
  32. package/dist/esm/commands/inspect.js +1 -1
  33. package/dist/esm/commands/serve.js +6 -6
  34. package/dist/esm/{new/compat → compat}/hooks.js +98 -49
  35. package/dist/esm/{new/compat → compat}/index.js +8 -3
  36. package/dist/esm/{new/compat → compat}/utils.js +29 -8
  37. package/dist/esm/config/default.js +12 -1
  38. package/dist/esm/config/legacy/index.js +0 -1
  39. package/dist/esm/index.js +245 -2
  40. package/dist/esm/plugins/analyze/getServerRoutes.js +11 -2
  41. package/dist/esm/plugins/analyze/index.js +76 -34
  42. package/dist/esm/plugins/analyze/utils.js +5 -0
  43. package/dist/esm/plugins/deploy/platforms/netlify.js +6 -3
  44. package/dist/esm/plugins/deploy/platforms/node.js +5 -2
  45. package/dist/esm/plugins/deploy/platforms/vercel.js +6 -3
  46. package/dist/esm/plugins/serverBuild.js +52 -56
  47. package/dist/esm/{new/run.js → run/index.js} +6 -6
  48. package/dist/esm/{new → utils}/getConfigFile.js +1 -1
  49. package/dist/esm/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
  50. package/dist/esm/utils/loadPlugins.js +95 -7
  51. package/dist/esm/utils/printInstructions.js +1 -28
  52. package/dist/esm/utils/restart.js +3 -3
  53. package/dist/esm-node/commands/build.js +19 -13
  54. package/dist/esm-node/commands/deploy.js +5 -5
  55. package/dist/esm-node/commands/dev.js +12 -12
  56. package/dist/esm-node/commands/index.js +6 -6
  57. package/dist/esm-node/commands/inspect.js +1 -1
  58. package/dist/esm-node/commands/serve.js +5 -5
  59. package/dist/esm-node/{new/compat → compat}/hooks.js +21 -6
  60. package/dist/esm-node/{new/compat → compat}/index.js +8 -3
  61. package/dist/esm-node/{new/compat → compat}/utils.js +29 -8
  62. package/dist/esm-node/config/default.js +6 -1
  63. package/dist/esm-node/config/legacy/index.js +0 -1
  64. package/dist/esm-node/index.js +140 -2
  65. package/dist/esm-node/plugins/analyze/getServerRoutes.js +11 -2
  66. package/dist/esm-node/plugins/analyze/index.js +26 -11
  67. package/dist/esm-node/plugins/analyze/utils.js +5 -0
  68. package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -3
  69. package/dist/esm-node/plugins/deploy/platforms/node.js +5 -2
  70. package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -3
  71. package/dist/esm-node/plugins/serverBuild.js +30 -32
  72. package/dist/esm-node/{new/run.js → run/index.js} +6 -6
  73. package/dist/esm-node/{new → utils}/getConfigFile.js +1 -1
  74. package/dist/esm-node/{new/utils/index.js → utils/isAutoLoadPlugins.js} +2 -2
  75. package/dist/esm-node/utils/loadPlugins.js +34 -4
  76. package/dist/esm-node/utils/printInstructions.js +1 -9
  77. package/dist/esm-node/utils/restart.js +2 -2
  78. package/dist/types/commands/build.d.ts +2 -2
  79. package/dist/types/commands/deploy.d.ts +2 -2
  80. package/dist/types/commands/dev.d.ts +2 -2
  81. package/dist/types/commands/index.d.ts +6 -6
  82. package/dist/types/commands/inspect.d.ts +2 -2
  83. package/dist/types/commands/serve.d.ts +2 -2
  84. package/dist/types/{new/compat → compat}/hooks.d.ts +2 -2
  85. package/dist/types/compat/index.d.ts +2 -0
  86. package/dist/types/{new/compat → compat}/utils.d.ts +8 -1
  87. package/dist/types/index.d.ts +5 -3
  88. package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
  89. package/dist/types/plugins/analyze/utils.d.ts +1 -0
  90. package/dist/types/plugins/serverBuild.d.ts +2 -2
  91. package/dist/types/types/config/index.d.ts +0 -1
  92. package/dist/types/types/index.d.ts +2 -0
  93. package/dist/types/types/new.d.ts +11 -16
  94. package/dist/types/utils/generateWatchFiles.d.ts +2 -2
  95. package/dist/types/utils/isAutoLoadPlugins.d.ts +1 -0
  96. package/dist/types/utils/loadPlugins.d.ts +13 -3
  97. package/dist/types/utils/printInstructions.d.ts +1 -3
  98. package/dist/types/utils/restart.d.ts +2 -3
  99. package/package.json +24 -28
  100. package/dist/cjs/hooks.js +0 -60
  101. package/dist/cjs/new/index.js +0 -79
  102. package/dist/cjs/new/loadPlugins.js +0 -57
  103. package/dist/cjs/old.js +0 -179
  104. package/dist/cjs/plugins/deploy/dependencies/index.js +0 -237
  105. package/dist/cjs/plugins/deploy/dependencies/utils.js +0 -179
  106. package/dist/cjs/plugins/deploy/exports.js +0 -28
  107. package/dist/esm/hooks.js +0 -36
  108. package/dist/esm/new/index.js +0 -55
  109. package/dist/esm/new/loadPlugins.js +0 -94
  110. package/dist/esm/old.js +0 -258
  111. package/dist/esm/plugins/deploy/dependencies/index.js +0 -615
  112. package/dist/esm/plugins/deploy/dependencies/utils.js +0 -421
  113. package/dist/esm/plugins/deploy/exports.js +0 -4
  114. package/dist/esm-node/hooks.js +0 -36
  115. package/dist/esm-node/new/index.js +0 -52
  116. package/dist/esm-node/new/loadPlugins.js +0 -33
  117. package/dist/esm-node/old.js +0 -140
  118. package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -202
  119. package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -137
  120. package/dist/esm-node/plugins/deploy/exports.js +0 -4
  121. package/dist/types/hooks.d.ts +0 -2
  122. package/dist/types/new/compat/index.d.ts +0 -2
  123. package/dist/types/new/index.d.ts +0 -6
  124. package/dist/types/new/loadPlugins.d.ts +0 -9
  125. package/dist/types/new/utils/index.d.ts +0 -1
  126. package/dist/types/old.d.ts +0 -13
  127. package/dist/types/plugins/deploy/dependencies/index.d.ts +0 -20
  128. package/dist/types/plugins/deploy/dependencies/utils.d.ts +0 -44
  129. package/dist/types/plugins/deploy/exports.d.ts +0 -1
  130. /package/dist/cjs/{new/constants.js → constants.js} +0 -0
  131. /package/dist/esm/{new/constants.js → constants.js} +0 -0
  132. /package/dist/esm/{new/context.js → utils/initAppContext.js} +0 -0
  133. /package/dist/esm-node/{new/constants.js → constants.js} +0 -0
  134. /package/dist/esm-node/{new/context.js → utils/initAppContext.js} +0 -0
  135. /package/dist/types/{new/constants.d.ts → constants.d.ts} +0 -0
  136. /package/dist/types/{new/run.d.ts → run/index.d.ts} +0 -0
  137. /package/dist/types/{new → utils}/getConfigFile.d.ts +0 -0
  138. /package/dist/types/{new/context.d.ts → utils/initAppContext.d.ts} +0 -0
@@ -6,4 +6,5 @@ export declare const parseModule: ({ source, filename, }: {
6
6
  }) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean]>;
7
7
  export declare const getServerCombinedModueFile: (internalDirectory: string, entryName: string) => string;
8
8
  export declare const checkIsBuildCommands: () => boolean;
9
+ export declare const checkIsServeCommand: () => boolean;
9
10
  export declare const isSubDirOrEqual: (parent: string, child: string) => boolean;
@@ -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;
@@ -40,7 +40,6 @@ export interface AppToolsUserConfig<B extends Bundler> {
40
40
  testing?: TestingUserConfig;
41
41
  builderPlugins?: Array<LooseRsbuildPlugin | UniBuilderPlugin>;
42
42
  performance?: PerformanceUserConfig;
43
- devtools?: any;
44
43
  environments?: RsbuildConfig['environments'];
45
44
  }
46
45
  interface SharedNormalizedConfig<RawConfig> {
@@ -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,9 +1,9 @@
1
1
  import type { DevToolData, RegisterBuildPlatformResult } from '@modern-js/core';
2
- import type { AppContext, AsyncHook, InternalContext, PluginHook, PluginHookTap, TransformFunction } from '@modern-js/plugin-v2';
2
+ import type { AppContext, AsyncHook, CollectAsyncHook, InternalContext, PluginHook, PluginHookTap, TransformFunction } from '@modern-js/plugin-v2';
3
3
  import type { Hooks } from '@modern-js/plugin-v2/cli';
4
4
  import type { Entrypoint, HtmlPartials, HtmlTemplates, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
5
5
  import type { AppTools } from '.';
6
- import type { getHookRunners } from '../new/compat/hooks';
6
+ import type { getHookRunners } from '../compat/hooks';
7
7
  import type { AppToolsNormalizedConfig, AppToolsUserConfig } from './config';
8
8
  import type { RuntimePlugin } from './hooks';
9
9
  import type { Bundler } from './utils';
@@ -41,18 +41,8 @@ export type BeforeGenerateRoutesFn = TransformFunction<{
41
41
  export type BeforePrintInstructionsFn = TransformFunction<{
42
42
  instructions: string;
43
43
  }>;
44
- export type RegisterDevFn = (params: {
45
- name: string;
46
- entry: string;
47
- type: string;
48
- config: any;
49
- }) => Promise<DevToolData> | DevToolData;
50
- export type RegisterBuildPlatformFn = (params: {
51
- name: string;
52
- entry: string;
53
- type: string;
54
- config: any;
55
- }) => Promise<RegisterBuildPlatformResult> | RegisterBuildPlatformResult;
44
+ export type RegisterDevFn = () => Promise<DevToolData> | DevToolData;
45
+ export type RegisterBuildPlatformFn = () => Promise<RegisterBuildPlatformResult> | RegisterBuildPlatformResult;
56
46
  export type AddRuntimeExportsFn = () => Promise<void> | void;
57
47
  export interface AppToolsExtendAPI<B extends Bundler = 'webpack'> {
58
48
  onBeforeConfig: PluginHookTap<BeforeConfigFn>;
@@ -118,11 +108,11 @@ export interface AppToolsExtendHooks extends Record<string, PluginHook<(...args:
118
108
  /**
119
109
  * @deprecated
120
110
  */
121
- registerDev: AsyncHook<RegisterDevFn>;
111
+ registerDev: CollectAsyncHook<RegisterDevFn>;
122
112
  /**
123
113
  * @deprecated
124
114
  */
125
- registerBuildPlatform: AsyncHook<RegisterBuildPlatformFn>;
115
+ registerBuildPlatform: CollectAsyncHook<RegisterBuildPlatformFn>;
126
116
  /**
127
117
  * @deprecated
128
118
  */
@@ -136,6 +126,7 @@ export type AppToolsExtendContext<B extends Bundler = 'webpack'> = {
136
126
  internalSrcAlias: string;
137
127
  apiDirectory: string;
138
128
  lambdaDirectory: string;
129
+ serverConfigFile: string;
139
130
  serverPlugins: ServerPlugin[];
140
131
  moduleType: 'module' | 'commonjs';
141
132
  /** Information for entry points */
@@ -157,6 +148,10 @@ export type AppToolsExtendContext<B extends Bundler = 'webpack'> = {
157
148
  * @private
158
149
  */
159
150
  htmlTemplates: HtmlTemplates;
151
+ /**
152
+ * @deprecated compat old plugin, default is app tools
153
+ */
154
+ toolsType?: string;
160
155
  };
161
156
  export type AppToolsContext<B extends Bundler = 'webpack'> = AppContext<AppTools<B>> & AppToolsExtendContext<B>;
162
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[]>;
@@ -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,5 +1,3 @@
1
- import type { CliHooksRunner, IAppContext } from '@modern-js/core';
2
- import type { AppNormalizedConfig, AppTools } from '../types';
1
+ import type { AppNormalizedConfig } from '../types';
3
2
  import type { AppToolsContext, AppToolsHooks } from '../types/new';
4
3
  export declare const printInstructions: (hooks: AppToolsHooks<'shared'>, appContext: AppToolsContext<'shared'>, config: AppNormalizedConfig<'shared'>) => Promise<void>;
5
- export declare const printInstructionsCompat: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, 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>;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.63.1",
18
+ "version": "2.63.3",
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",
@@ -48,11 +48,6 @@
48
48
  "types": "./dist/types/exports/server.d.ts",
49
49
  "jsnext:source": "./src/exports/server.ts",
50
50
  "default": "./dist/cjs/exports/server.js"
51
- },
52
- "./deploy": {
53
- "types": "./dist/types/plugins/deploy/exports.d.ts",
54
- "jsnext:source": "./src/plugins/deploy/exports.ts",
55
- "default": "./dist/cjs/plugins/deploy/exports.js"
56
51
  }
57
52
  },
58
53
  "engines": {
@@ -64,7 +59,7 @@
64
59
  "./dist/types/index.d.ts"
65
60
  ],
66
61
  "cli/run": [
67
- "./dist/types/new/run.d.ts"
62
+ "./dist/types/run/index.d.ts"
68
63
  ],
69
64
  "types": [
70
65
  "./lib/types.d.ts"
@@ -85,7 +80,7 @@
85
80
  "@babel/parser": "^7.22.15",
86
81
  "@babel/traverse": "^7.23.2",
87
82
  "@babel/types": "^7.26.0",
88
- "@rsbuild/core": "1.1.8",
83
+ "@rsbuild/core": "1.1.10",
89
84
  "@rsbuild/plugin-node-polyfill": "1.2.0",
90
85
  "@swc/helpers": "0.5.13",
91
86
  "@vercel/nft": "^0.26.4",
@@ -95,21 +90,22 @@
95
90
  "flatted": "^3.2.9",
96
91
  "mlly": "^1.6.1",
97
92
  "pkg-types": "^1.1.0",
93
+ "ndepe": "0.1.4",
98
94
  "std-env": "^3.7.0",
99
- "@modern-js/node-bundle-require": "2.63.1",
100
- "@modern-js/core": "2.63.1",
101
- "@modern-js/plugin": "2.63.1",
102
- "@modern-js/plugin-data-loader": "2.63.1",
103
- "@modern-js/prod-server": "2.63.1",
104
- "@modern-js/plugin-v2": "2.63.1",
105
- "@modern-js/plugin-i18n": "2.63.1",
106
- "@modern-js/rsbuild-plugin-esbuild": "2.63.1",
107
- "@modern-js/server": "2.63.1",
108
- "@modern-js/server-core": "2.63.1",
109
- "@modern-js/types": "2.63.1",
110
- "@modern-js/uni-builder": "2.63.1",
111
- "@modern-js/server-utils": "2.63.1",
112
- "@modern-js/utils": "2.63.1"
95
+ "@modern-js/core": "2.63.3",
96
+ "@modern-js/node-bundle-require": "2.63.3",
97
+ "@modern-js/plugin-data-loader": "2.63.3",
98
+ "@modern-js/plugin": "2.63.3",
99
+ "@modern-js/plugin-i18n": "2.63.3",
100
+ "@modern-js/plugin-v2": "2.63.3",
101
+ "@modern-js/prod-server": "2.63.3",
102
+ "@modern-js/rsbuild-plugin-esbuild": "2.63.3",
103
+ "@modern-js/server": "2.63.3",
104
+ "@modern-js/server-core": "2.63.3",
105
+ "@modern-js/server-utils": "2.63.3",
106
+ "@modern-js/uni-builder": "2.63.3",
107
+ "@modern-js/utils": "2.63.3",
108
+ "@modern-js/types": "2.63.3"
113
109
  },
114
110
  "devDependencies": {
115
111
  "@rsbuild/plugin-webpack-swc": "1.0.9",
@@ -120,9 +116,9 @@
120
116
  "ts-node": "^10.9.1",
121
117
  "tsconfig-paths": "^4.2.0",
122
118
  "typescript": "^5",
123
- "webpack": "^5.96.1",
124
- "@scripts/jest-config": "2.63.1",
125
- "@scripts/build": "2.63.1"
119
+ "webpack": "^5.97.1",
120
+ "@scripts/jest-config": "2.63.3",
121
+ "@scripts/build": "2.63.3"
126
122
  },
127
123
  "peerDependencies": {
128
124
  "ts-node": "^10.7.0",
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
- });
@@ -1,57 +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 loadPlugins_exports = {};
20
- __export(loadPlugins_exports, {
21
- loadInternalPlugins: () => loadInternalPlugins
22
- });
23
- module.exports = __toCommonJS(loadPlugins_exports);
24
- var import_utils = require("@modern-js/utils");
25
- const debug = (0, import_utils.createDebugger)("load-plugins");
26
- const resolveCliPlugin = async (p, appDirectory) => {
27
- const pkg = typeof p === "string" ? p : p[0];
28
- const pluginOptions = typeof p === "string" ? void 0 : p[1];
29
- const path = (0, import_utils.tryResolve)(pkg, appDirectory);
30
- let module2;
31
- try {
32
- module2 = await (0, import_utils.compatibleRequire)(path);
33
- } catch (e) {
34
- ({ default: module2 } = await (0, import_utils.dynamicImport)(path));
35
- }
36
- if (typeof module2 === "function") {
37
- const result = module2(pluginOptions);
38
- return result;
39
- }
40
- return module2;
41
- };
42
- const loadInternalPlugins = async (appDirectory, internalPlugins, autoLoad, autoLoadPlugins) => {
43
- const plugins = [
44
- ...autoLoadPlugins ? (0, import_utils.getInternalPlugins)(appDirectory, internalPlugins) : [],
45
- ...autoLoad ? (0, import_utils.getInternalPlugins)(appDirectory, autoLoad) : []
46
- ];
47
- const loadedPlugins = await Promise.all(plugins.map((plugin) => {
48
- const loadedPlugin = resolveCliPlugin(plugin, appDirectory);
49
- debug(`resolve plugin %s: %s`, plugin, loadedPlugin);
50
- return loadedPlugin;
51
- }));
52
- return loadedPlugins;
53
- };
54
- // Annotate the CommonJS export names for ESM import in node:
55
- 0 && (module.exports = {
56
- loadInternalPlugins
57
- });
package/dist/cjs/old.js DELETED
@@ -1,179 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var old_exports = {};
31
- __export(old_exports, {
32
- appTools: () => appTools,
33
- default: () => old_default,
34
- dev: () => import_dev.dev,
35
- mergeConfig: () => import_core.mergeConfig
36
- });
37
- module.exports = __toCommonJS(old_exports);
38
- var import_path = __toESM(require("path"));
39
- var import_language_detector = require("@modern-js/plugin-i18n/language-detector");
40
- var import_uni_builder = require("@modern-js/uni-builder");
41
- var import_utils = require("@modern-js/utils");
42
- var import_hooks = require("./hooks");
43
- var import_locale = require("./locale");
44
- var import_analyze = __toESM(require("./plugins/analyze"));
45
- var import_deploy = __toESM(require("./plugins/deploy"));
46
- var import_initialize = __toESM(require("./plugins/initialize"));
47
- var import_serverBuild = __toESM(require("./plugins/serverBuild"));
48
- var import_commands = require("./commands");
49
- var import_generateWatchFiles = require("./utils/generateWatchFiles");
50
- var import_restart = require("./utils/restart");
51
- var import_dev = require("./commands/dev");
52
- var import_core = require("@modern-js/core");
53
- __reExport(old_exports, require("./defineConfig"), module.exports);
54
- __reExport(old_exports, require("./types"), module.exports);
55
- const appTools = (options = {
56
- // default webpack to be compatible with original projects
57
- bundler: "webpack"
58
- }) => ({
59
- name: "@modern-js/app-tools-old",
60
- post: [
61
- "@modern-js/plugin-initialize",
62
- "@modern-js/plugin-analyze",
63
- "@modern-js/plugin-ssr",
64
- "@modern-js/plugin-document",
65
- "@modern-js/plugin-state",
66
- "@modern-js/plugin-router",
67
- "@modern-js/plugin-router-v5",
68
- "@modern-js/plugin-polyfill"
69
- ],
70
- registerHook: import_hooks.hooks,
71
- usePlugins: [
72
- (0, import_initialize.default)({
73
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
74
- "rspack",
75
- "experimental-rspack"
76
- ].includes(options.bundler) ? "rspack" : "webpack"
77
- }),
78
- (0, import_analyze.default)({
79
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
80
- "rspack",
81
- "experimental-rspack"
82
- ].includes(options.bundler) ? "rspack" : "webpack"
83
- }),
84
- (0, import_serverBuild.default)(),
85
- (0, import_deploy.default)()
86
- ],
87
- setup: (api) => {
88
- const appContext = api.useAppContext();
89
- api.setAppContext({
90
- ...appContext,
91
- toolsType: "app-tools"
92
- });
93
- const locale = (0, import_language_detector.getLocaleLanguage)();
94
- import_locale.i18n.changeLanguage({
95
- locale
96
- });
97
- return {
98
- async beforeConfig() {
99
- var _userConfig_output;
100
- const userConfig = api.useConfigContext();
101
- const appContext2 = api.useAppContext();
102
- if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
103
- api.setAppContext({
104
- ...appContext2,
105
- internalDirectory: import_path.default.resolve(appContext2.appDirectory, userConfig.output.tempDir)
106
- });
107
- }
108
- },
109
- async commands({ program }) {
110
- await (0, import_commands.devCommand)(program, api);
111
- await (0, import_commands.buildCommand)(program, api);
112
- (0, import_commands.serverCommand)(program, api);
113
- (0, import_commands.deployCommand)(program, api);
114
- (0, import_commands.newCommand)(program, locale);
115
- (0, import_commands.inspectCommand)(program, api);
116
- (0, import_commands.upgradeCommand)(program);
117
- (0, import_utils.deprecatedCommands)(program);
118
- },
119
- async prepare() {
120
- const command = (0, import_utils.getCommand)();
121
- if (command === "deploy") {
122
- const isSkipBuild = [
123
- "-s",
124
- "--skip-build"
125
- ].some((tag) => {
126
- return (0, import_utils.getArgv)().includes(tag);
127
- });
128
- if (isSkipBuild) {
129
- return;
130
- }
131
- }
132
- if (command === "dev" || command === "start" || command === "build" || command === "deploy") {
133
- const resolvedConfig = api.useResolvedConfigContext();
134
- if (resolvedConfig.output.cleanDistPath) {
135
- const appContext2 = api.useAppContext();
136
- await (0, import_utils.emptyDir)(appContext2.distDirectory);
137
- }
138
- }
139
- },
140
- async watchFiles() {
141
- const appContext2 = api.useAppContext();
142
- const config = api.useResolvedConfigContext();
143
- const files = await (0, import_generateWatchFiles.generateWatchFiles)(appContext2, config.source.configDir);
144
- const watchFiles = (0, import_uni_builder.castArray)(config.dev.watchFiles);
145
- watchFiles.forEach(({ type, paths }) => {
146
- if (type === "reload-server") {
147
- files.push(...Array.isArray(paths) ? paths : [
148
- paths
149
- ]);
150
- }
151
- });
152
- return files;
153
- },
154
- // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
155
- async fileChange(e) {
156
- const { filename, eventType, isPrivate } = e;
157
- if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
158
- const { closeServer } = await import("./utils/createServer.js");
159
- await closeServer();
160
- await (0, import_restart.restart)(api.useHookRunners(), filename);
161
- }
162
- },
163
- async beforeRestart() {
164
- (0, import_utils.cleanRequireCache)([
165
- require.resolve("./plugins/analyze")
166
- ]);
167
- }
168
- };
169
- }
170
- });
171
- var old_default = appTools;
172
- // Annotate the CommonJS export names for ESM import in node:
173
- 0 && (module.exports = {
174
- appTools,
175
- dev,
176
- mergeConfig,
177
- ...require("./defineConfig"),
178
- ...require("./types")
179
- });