@modern-js/app-tools 2.63.1 → 2.63.2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/modern.js +1 -1
- package/dist/cjs/commands/build.js +19 -13
- package/dist/cjs/commands/deploy.js +5 -5
- package/dist/cjs/commands/dev.js +11 -11
- package/dist/cjs/commands/index.js +6 -6
- package/dist/cjs/commands/inspect.js +1 -1
- package/dist/cjs/commands/serve.js +4 -4
- package/dist/cjs/{new/compat → compat}/hooks.js +5 -5
- package/dist/cjs/{new/compat → compat}/index.js +4 -1
- package/dist/cjs/config/default.js +6 -1
- package/dist/cjs/config/legacy/index.js +0 -1
- package/dist/cjs/index.js +154 -5
- package/dist/cjs/plugins/analyze/getServerRoutes.js +12 -2
- package/dist/cjs/plugins/analyze/index.js +25 -10
- package/dist/cjs/plugins/analyze/utils.js +6 -0
- package/dist/cjs/plugins/serverBuild.js +30 -32
- package/dist/cjs/{new/run.js → run/index.js} +6 -6
- package/dist/cjs/{new → utils}/getConfigFile.js +1 -1
- package/dist/cjs/{new/context.js → utils/initAppContext.js} +3 -3
- package/dist/cjs/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
- package/dist/cjs/utils/loadPlugins.js +35 -4
- package/dist/cjs/utils/printInstructions.js +2 -11
- package/dist/cjs/utils/restart.js +2 -2
- package/dist/esm/commands/build.js +18 -12
- package/dist/esm/commands/deploy.js +6 -6
- package/dist/esm/commands/dev.js +11 -11
- package/dist/esm/commands/index.js +8 -8
- package/dist/esm/commands/inspect.js +1 -1
- package/dist/esm/commands/serve.js +6 -6
- package/dist/esm/{new/compat → compat}/hooks.js +15 -25
- package/dist/esm/{new/compat → compat}/index.js +4 -1
- package/dist/esm/config/default.js +12 -1
- package/dist/esm/config/legacy/index.js +0 -1
- package/dist/esm/index.js +245 -2
- package/dist/esm/plugins/analyze/getServerRoutes.js +11 -2
- package/dist/esm/plugins/analyze/index.js +76 -34
- package/dist/esm/plugins/analyze/utils.js +5 -0
- package/dist/esm/plugins/serverBuild.js +52 -56
- package/dist/esm/{new/run.js → run/index.js} +6 -6
- package/dist/esm/{new → utils}/getConfigFile.js +1 -1
- package/dist/esm/{new/utils/index.js → utils/isAutoLoadPlugins.js} +6 -6
- package/dist/esm/utils/loadPlugins.js +95 -7
- package/dist/esm/utils/printInstructions.js +1 -28
- package/dist/esm/utils/restart.js +3 -3
- package/dist/esm-node/commands/build.js +19 -13
- package/dist/esm-node/commands/deploy.js +5 -5
- package/dist/esm-node/commands/dev.js +12 -12
- package/dist/esm-node/commands/index.js +6 -6
- package/dist/esm-node/commands/inspect.js +1 -1
- package/dist/esm-node/commands/serve.js +5 -5
- package/dist/esm-node/{new/compat → compat}/hooks.js +5 -5
- package/dist/esm-node/{new/compat → compat}/index.js +4 -1
- package/dist/esm-node/config/default.js +6 -1
- package/dist/esm-node/config/legacy/index.js +0 -1
- package/dist/esm-node/index.js +140 -2
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +11 -2
- package/dist/esm-node/plugins/analyze/index.js +26 -11
- package/dist/esm-node/plugins/analyze/utils.js +5 -0
- package/dist/esm-node/plugins/serverBuild.js +30 -32
- package/dist/esm-node/{new/run.js → run/index.js} +6 -6
- package/dist/esm-node/{new → utils}/getConfigFile.js +1 -1
- package/dist/esm-node/{new/utils/index.js → utils/isAutoLoadPlugins.js} +2 -2
- package/dist/esm-node/utils/loadPlugins.js +34 -4
- package/dist/esm-node/utils/printInstructions.js +1 -9
- package/dist/esm-node/utils/restart.js +2 -2
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/index.d.ts +6 -6
- package/dist/types/commands/inspect.d.ts +2 -2
- package/dist/types/commands/serve.d.ts +2 -2
- package/dist/types/{new/compat → compat}/hooks.d.ts +2 -2
- package/dist/types/compat/index.d.ts +2 -0
- package/dist/types/index.d.ts +5 -3
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
- package/dist/types/plugins/analyze/utils.d.ts +1 -0
- package/dist/types/plugins/serverBuild.d.ts +2 -2
- package/dist/types/types/config/index.d.ts +0 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/new.d.ts +11 -16
- package/dist/types/utils/generateWatchFiles.d.ts +2 -2
- package/dist/types/utils/isAutoLoadPlugins.d.ts +1 -0
- package/dist/types/utils/loadPlugins.d.ts +13 -3
- package/dist/types/utils/printInstructions.d.ts +1 -3
- package/dist/types/utils/restart.d.ts +2 -3
- package/package.json +23 -23
- package/dist/cjs/hooks.js +0 -60
- package/dist/cjs/new/index.js +0 -79
- package/dist/cjs/new/loadPlugins.js +0 -57
- package/dist/cjs/old.js +0 -179
- package/dist/esm/hooks.js +0 -36
- package/dist/esm/new/index.js +0 -55
- package/dist/esm/new/loadPlugins.js +0 -94
- package/dist/esm/old.js +0 -258
- package/dist/esm-node/hooks.js +0 -36
- package/dist/esm-node/new/index.js +0 -52
- package/dist/esm-node/new/loadPlugins.js +0 -33
- package/dist/esm-node/old.js +0 -140
- package/dist/types/hooks.d.ts +0 -2
- package/dist/types/new/compat/index.d.ts +0 -2
- package/dist/types/new/index.d.ts +0 -6
- package/dist/types/new/loadPlugins.d.ts +0 -9
- package/dist/types/new/utils/index.d.ts +0 -1
- package/dist/types/old.d.ts +0 -13
- /package/dist/cjs/{new/compat → compat}/utils.js +0 -0
- /package/dist/cjs/{new/constants.js → constants.js} +0 -0
- /package/dist/esm/{new/compat → compat}/utils.js +0 -0
- /package/dist/esm/{new/constants.js → constants.js} +0 -0
- /package/dist/esm/{new/context.js → utils/initAppContext.js} +0 -0
- /package/dist/esm-node/{new/compat → compat}/utils.js +0 -0
- /package/dist/esm-node/{new/constants.js → constants.js} +0 -0
- /package/dist/esm-node/{new/context.js → utils/initAppContext.js} +0 -0
- /package/dist/types/{new/compat → compat}/utils.d.ts +0 -0
- /package/dist/types/{new/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/types/{new/run.d.ts → run/index.d.ts} +0 -0
- /package/dist/types/{new → utils}/getConfigFile.d.ts +0 -0
- /package/dist/types/{new/context.d.ts → utils/initAppContext.d.ts} +0 -0
@@ -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 '../
|
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 = (
|
45
|
-
|
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:
|
111
|
+
registerDev: CollectAsyncHook<RegisterDevFn>;
|
122
112
|
/**
|
123
113
|
* @deprecated
|
124
114
|
*/
|
125
|
-
registerBuildPlatform:
|
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 {
|
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:
|
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 {
|
4
|
-
|
5
|
-
export declare function
|
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 {
|
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 {
|
2
|
-
|
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.
|
18
|
+
"version": "2.63.2",
|
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/
|
39
|
-
"jsnext:source": "./src/
|
40
|
-
"default": "./dist/cjs/
|
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/
|
67
|
+
"./dist/types/run/index.d.ts"
|
68
68
|
],
|
69
69
|
"types": [
|
70
70
|
"./lib/types.d.ts"
|
@@ -85,7 +85,7 @@
|
|
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.
|
88
|
+
"@rsbuild/core": "1.1.9",
|
89
89
|
"@rsbuild/plugin-node-polyfill": "1.2.0",
|
90
90
|
"@swc/helpers": "0.5.13",
|
91
91
|
"@vercel/nft": "^0.26.4",
|
@@ -96,20 +96,20 @@
|
|
96
96
|
"mlly": "^1.6.1",
|
97
97
|
"pkg-types": "^1.1.0",
|
98
98
|
"std-env": "^3.7.0",
|
99
|
-
"@modern-js/
|
100
|
-
"@modern-js/
|
101
|
-
"@modern-js/
|
102
|
-
"@modern-js/plugin-data-loader": "2.63.
|
103
|
-
"@modern-js/prod-server": "2.63.
|
104
|
-
"@modern-js/plugin-
|
105
|
-
"@modern-js/plugin-
|
106
|
-
"@modern-js/
|
107
|
-
"@modern-js/server": "2.63.
|
108
|
-
"@modern-js/server
|
109
|
-
"@modern-js/
|
110
|
-
"@modern-js/
|
111
|
-
"@modern-js/
|
112
|
-
"@modern-js/utils": "2.63.
|
99
|
+
"@modern-js/core": "2.63.2",
|
100
|
+
"@modern-js/plugin": "2.63.2",
|
101
|
+
"@modern-js/node-bundle-require": "2.63.2",
|
102
|
+
"@modern-js/plugin-data-loader": "2.63.2",
|
103
|
+
"@modern-js/prod-server": "2.63.2",
|
104
|
+
"@modern-js/plugin-i18n": "2.63.2",
|
105
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.63.2",
|
106
|
+
"@modern-js/plugin-v2": "2.63.2",
|
107
|
+
"@modern-js/server-core": "2.63.2",
|
108
|
+
"@modern-js/server": "2.63.2",
|
109
|
+
"@modern-js/server-utils": "2.63.2",
|
110
|
+
"@modern-js/types": "2.63.2",
|
111
|
+
"@modern-js/uni-builder": "2.63.2",
|
112
|
+
"@modern-js/utils": "2.63.2"
|
113
113
|
},
|
114
114
|
"devDependencies": {
|
115
115
|
"@rsbuild/plugin-webpack-swc": "1.0.9",
|
@@ -120,9 +120,9 @@
|
|
120
120
|
"ts-node": "^10.9.1",
|
121
121
|
"tsconfig-paths": "^4.2.0",
|
122
122
|
"typescript": "^5",
|
123
|
-
"webpack": "^5.
|
124
|
-
"@scripts/
|
125
|
-
"@scripts/
|
123
|
+
"webpack": "^5.97.1",
|
124
|
+
"@scripts/build": "2.63.2",
|
125
|
+
"@scripts/jest-config": "2.63.2"
|
126
126
|
},
|
127
127
|
"peerDependencies": {
|
128
128
|
"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
|
-
});
|
package/dist/cjs/new/index.js
DELETED
@@ -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
|
-
});
|
package/dist/esm/hooks.js
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
import { createAsyncWaterfall, createAsyncWorkflow, createParallelWorkflow } from "@modern-js/plugin";
|
2
|
-
var hooks = {
|
3
|
-
_internalRuntimePlugins: createAsyncWaterfall(),
|
4
|
-
modifyFileSystemRoutes: createAsyncWaterfall(),
|
5
|
-
modifyServerRoutes: createAsyncWaterfall(),
|
6
|
-
/** add entry point info to entrypoints array */
|
7
|
-
modifyEntrypoints: createAsyncWaterfall(),
|
8
|
-
/** add entry type */
|
9
|
-
checkEntryPoint: createAsyncWaterfall(),
|
10
|
-
generateEntryCode: createAsyncWorkflow(),
|
11
|
-
htmlPartials: createAsyncWaterfall(),
|
12
|
-
beforeGenerateRoutes: createAsyncWaterfall(),
|
13
|
-
_internalServerPlugins: createAsyncWaterfall(),
|
14
|
-
beforeDev: createAsyncWorkflow(),
|
15
|
-
afterDev: createAsyncWorkflow(),
|
16
|
-
beforeCreateCompiler: createAsyncWorkflow(),
|
17
|
-
afterCreateCompiler: createAsyncWorkflow(),
|
18
|
-
beforePrintInstructions: createAsyncWaterfall(),
|
19
|
-
beforeBuild: createAsyncWorkflow(),
|
20
|
-
afterBuild: createAsyncWorkflow(),
|
21
|
-
beforeDeploy: createAsyncWorkflow(),
|
22
|
-
deploy: createAsyncWorkflow(),
|
23
|
-
afterDeploy: createAsyncWorkflow(),
|
24
|
-
beforeRestart: createAsyncWorkflow(),
|
25
|
-
/**
|
26
|
-
* @deprecated
|
27
|
-
*/
|
28
|
-
registerDev: createParallelWorkflow(),
|
29
|
-
/**
|
30
|
-
* @deprecated
|
31
|
-
*/
|
32
|
-
registerBuildPlatform: createParallelWorkflow()
|
33
|
-
};
|
34
|
-
export {
|
35
|
-
hooks
|
36
|
-
};
|