@modern-js/app-tools 1.21.2 → 2.0.0-beta.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.
- package/CHANGELOG.md +139 -0
- package/dist/js/modern/analyze/constants.js +1 -0
- package/dist/js/modern/analyze/generateCode.js +118 -16
- package/dist/js/modern/analyze/getBundleEntry.js +3 -2
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +198 -0
- package/dist/js/modern/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +8 -28
- package/dist/js/modern/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +21 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +31 -12
- package/dist/js/modern/analyze/index.js +2 -1
- package/dist/js/modern/analyze/nestedRoutes.js +127 -0
- package/dist/js/modern/analyze/templates.js +164 -10
- package/dist/js/modern/analyze/utils.js +2 -1
- package/dist/js/modern/builder/builderPlugins/compatModern.js +226 -0
- package/dist/js/modern/builder/createHtmlConfig.js +58 -0
- package/dist/js/modern/builder/createOutputConfig.js +67 -0
- package/dist/js/modern/builder/createSourceConfig.js +85 -0
- package/dist/js/modern/builder/createToolsConfig.js +94 -0
- package/dist/js/modern/builder/index.js +106 -0
- package/dist/js/modern/builder/share.js +48 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +37 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +44 -0
- package/dist/js/modern/commands/build.js +41 -95
- package/dist/js/modern/commands/dev.js +15 -19
- package/dist/js/modern/commands/inspect.js +17 -58
- package/dist/js/modern/commands/start.js +2 -1
- package/dist/js/modern/index.js +14 -4
- package/dist/js/modern/locale/en.js +0 -1
- package/dist/js/modern/locale/zh.js +0 -1
- package/dist/js/modern/utils/commands.js +5 -0
- package/dist/js/modern/utils/createCompiler.js +37 -40
- package/dist/js/modern/utils/createServer.js +16 -0
- package/dist/js/modern/utils/printInstructions.js +1 -1
- package/dist/js/node/analyze/constants.js +3 -1
- package/dist/js/node/analyze/generateCode.js +121 -14
- package/dist/js/node/analyze/getBundleEntry.js +3 -2
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +221 -0
- package/dist/js/node/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +16 -35
- package/dist/js/node/analyze/getClientRoutes/index.js +21 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +42 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +30 -11
- package/dist/js/node/analyze/index.js +2 -1
- package/dist/js/node/analyze/nestedRoutes.js +144 -0
- package/dist/js/node/analyze/templates.js +167 -10
- package/dist/js/node/analyze/utils.js +6 -2
- package/dist/js/node/builder/builderPlugins/compatModern.js +245 -0
- package/dist/js/node/builder/createHtmlConfig.js +76 -0
- package/dist/js/node/builder/createOutputConfig.js +75 -0
- package/dist/js/node/builder/createSourceConfig.js +99 -0
- package/dist/js/node/builder/createToolsConfig.js +103 -0
- package/dist/js/node/builder/index.js +129 -0
- package/dist/js/node/builder/share.js +63 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +46 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +53 -0
- package/dist/js/node/commands/build.js +44 -98
- package/dist/js/node/commands/dev.js +13 -23
- package/dist/js/node/commands/inspect.js +18 -74
- package/dist/js/node/commands/start.js +3 -1
- package/dist/js/node/index.js +19 -2
- package/dist/js/node/locale/en.js +0 -1
- package/dist/js/node/locale/zh.js +0 -1
- package/dist/js/node/utils/commands.js +14 -0
- package/dist/js/node/utils/createCompiler.js +43 -49
- package/dist/js/node/utils/createServer.js +21 -2
- package/dist/js/node/utils/printInstructions.js +1 -1
- package/dist/js/treeshaking/analyze/constants.js +16 -0
- package/dist/js/treeshaking/analyze/generateCode.js +412 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +77 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +210 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +211 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +27 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +109 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +153 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +170 -0
- package/dist/js/treeshaking/analyze/index.js +214 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +32 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +18 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +207 -0
- package/dist/js/treeshaking/analyze/templates.js +189 -0
- package/dist/js/treeshaking/analyze/utils.js +95 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +231 -0
- package/dist/js/treeshaking/builder/createHtmlConfig.js +59 -0
- package/dist/js/treeshaking/builder/createOutputConfig.js +67 -0
- package/dist/js/treeshaking/builder/createSourceConfig.js +100 -0
- package/dist/js/treeshaking/builder/createToolsConfig.js +90 -0
- package/dist/js/treeshaking/builder/index.js +172 -0
- package/dist/js/treeshaking/builder/share.js +50 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +58 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +53 -0
- package/dist/js/treeshaking/commands/build.js +168 -0
- package/dist/js/treeshaking/commands/deploy.js +29 -0
- package/dist/js/treeshaking/commands/dev.js +146 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +52 -0
- package/dist/js/treeshaking/commands/start.js +78 -0
- package/dist/js/treeshaking/exports/server.js +1 -0
- package/dist/js/treeshaking/hooks.js +21 -0
- package/dist/js/treeshaking/index.js +304 -0
- package/dist/js/treeshaking/locale/en.js +34 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +34 -0
- package/dist/js/treeshaking/utils/commands.js +5 -0
- package/dist/js/treeshaking/utils/config.js +140 -0
- package/dist/js/treeshaking/utils/createCompiler.js +117 -0
- package/dist/js/treeshaking/utils/createServer.js +83 -0
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +68 -0
- package/dist/js/treeshaking/utils/language.js +5 -0
- package/dist/js/treeshaking/utils/printInstructions.js +35 -0
- package/dist/js/treeshaking/utils/routes.js +33 -0
- package/dist/js/treeshaking/utils/types.js +0 -0
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/analyze/generateCode.d.ts +1 -1
- package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
- package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
- package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
- package/dist/types/analyze/index.d.ts +2 -2
- package/dist/types/analyze/nestedRoutes.d.ts +5 -0
- package/dist/types/analyze/templates.d.ts +17 -3
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +14 -0
- package/dist/types/builder/createHtmlConfig.d.ts +6 -0
- package/dist/types/builder/createOutputConfig.d.ts +3 -0
- package/dist/types/builder/createSourceConfig.d.ts +5 -0
- package/dist/types/builder/createToolsConfig.d.ts +13 -0
- package/dist/types/builder/index.d.ts +19 -0
- package/dist/types/builder/share.d.ts +26 -0
- package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
- package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/commands/inspect.d.ts +5 -6
- package/dist/types/commands/start.d.ts +2 -1
- package/dist/types/hooks.d.ts +15 -10
- package/dist/types/index.d.ts +4 -2
- package/dist/types/locale/en.d.ts +0 -1
- package/dist/types/locale/index.d.ts +0 -2
- package/dist/types/locale/zh.d.ts +0 -1
- package/dist/types/utils/commands.d.ts +1 -0
- package/dist/types/utils/createCompiler.d.ts +9 -10
- package/dist/types/utils/createServer.d.ts +8 -1
- package/dist/types/utils/printInstructions.d.ts +3 -2
- package/dist/types/utils/types.d.ts +2 -3
- package/package.json +25 -43
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { webpack } from '@modern-js/builder-webpack-provider/types';
|
|
2
2
|
export declare const beforeDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
3
3
|
export declare const afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
4
4
|
export declare const beforeCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
5
|
-
|
|
5
|
+
bundlerConfigs: webpack.Configuration[];
|
|
6
6
|
}, unknown>;
|
|
7
7
|
export declare const afterCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
8
|
-
compiler: Compiler | MultiCompiler | undefined;
|
|
8
|
+
compiler: webpack.Compiler | webpack.MultiCompiler | undefined;
|
|
9
9
|
}, unknown>;
|
|
10
10
|
export declare const beforePrintInstructions: import("@modern-js/plugin").AsyncWaterfall<{
|
|
11
11
|
instructions: string;
|
|
12
12
|
}>;
|
|
13
13
|
export declare const beforeBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
14
|
-
|
|
14
|
+
bundlerConfigs?: webpack.Configuration[] | undefined;
|
|
15
|
+
}, unknown>;
|
|
16
|
+
export declare const afterBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
17
|
+
stats?: webpack.Stats | webpack.MultiStats | undefined;
|
|
15
18
|
}, unknown>;
|
|
16
|
-
export declare const afterBuild: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
17
19
|
export declare const beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
18
20
|
export declare const afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
19
21
|
export declare const hooks: {
|
|
20
22
|
beforeDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
21
23
|
afterDev: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
22
24
|
beforeCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
23
|
-
|
|
25
|
+
bundlerConfigs: webpack.Configuration[];
|
|
24
26
|
}, unknown>;
|
|
25
27
|
afterCreateCompiler: import("@modern-js/plugin").AsyncWorkflow<{
|
|
26
|
-
compiler: Compiler | MultiCompiler | undefined;
|
|
28
|
+
compiler: webpack.Compiler | webpack.MultiCompiler | undefined;
|
|
27
29
|
}, unknown>;
|
|
28
30
|
beforePrintInstructions: import("@modern-js/plugin").AsyncWaterfall<{
|
|
29
31
|
instructions: string;
|
|
30
32
|
}>;
|
|
31
33
|
beforeBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
32
|
-
|
|
34
|
+
bundlerConfigs?: webpack.Configuration[] | undefined;
|
|
35
|
+
}, unknown>;
|
|
36
|
+
afterBuild: import("@modern-js/plugin").AsyncWorkflow<{
|
|
37
|
+
stats?: webpack.Stats | webpack.MultiStats | undefined;
|
|
33
38
|
}, unknown>;
|
|
34
|
-
afterBuild: import("@modern-js/plugin").AsyncWorkflow<void, unknown>;
|
|
35
39
|
beforeDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
36
40
|
afterDeploy: import("@modern-js/plugin").AsyncWorkflow<Record<string, any>, unknown>;
|
|
37
|
-
};
|
|
41
|
+
};
|
|
42
|
+
export declare type AppHooks = typeof hooks;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineConfig, CliPlugin } from '@modern-js/core';
|
|
2
|
-
|
|
2
|
+
import { hooks, AppHooks } from './hooks';
|
|
3
|
+
export { defineConfig, hooks };
|
|
4
|
+
export type { AppHooks, CliPlugin };
|
|
3
5
|
|
|
4
|
-
declare const _default: () => CliPlugin
|
|
6
|
+
declare const _default: () => CliPlugin<AppHooks>;
|
|
5
7
|
|
|
6
8
|
export default _default;
|
|
@@ -30,7 +30,6 @@ declare const localeKeys: {
|
|
|
30
30
|
inspect: {
|
|
31
31
|
env: string;
|
|
32
32
|
output: string;
|
|
33
|
-
noConsole: string;
|
|
34
33
|
verbose: string;
|
|
35
34
|
};
|
|
36
35
|
};
|
|
@@ -64,7 +63,6 @@ declare const localeKeys: {
|
|
|
64
63
|
inspect: {
|
|
65
64
|
env: string;
|
|
66
65
|
output: string;
|
|
67
|
-
noConsole: string;
|
|
68
66
|
verbose: string;
|
|
69
67
|
};
|
|
70
68
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCommand: () => string;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type webpack from '@modern-js/builder-webpack-provider/webpack';
|
|
2
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
3
|
+
import type { AppHooks } from '../hooks';
|
|
4
|
+
import { BuilderOptions } from '../builder';
|
|
5
|
+
export declare const createDevCompiler: ({
|
|
4
6
|
api,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
target,
|
|
8
|
+
normalizedConfig,
|
|
7
9
|
appContext
|
|
8
10
|
}: {
|
|
9
|
-
api: PluginAPI
|
|
10
|
-
|
|
11
|
-
userConfig: NormalizedConfig;
|
|
12
|
-
appContext: IAppContext;
|
|
13
|
-
}) => Promise<webpack.MultiCompiler>;
|
|
11
|
+
api: PluginAPI<AppHooks>;
|
|
12
|
+
} & BuilderOptions) => Promise<webpack.Compiler | webpack.MultiCompiler>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Server, ModernDevServerOptions } from '@modern-js/server';
|
|
2
|
+
import type { InternalPlugins } from '@modern-js/types';
|
|
2
3
|
export declare const getServer: () => Server | null;
|
|
3
4
|
export declare const closeServer: () => Promise<void>;
|
|
4
|
-
export declare const createServer: (options: ModernDevServerOptions) => Promise<Server>;
|
|
5
|
+
export declare const createServer: (options: ModernDevServerOptions) => Promise<Server>;
|
|
6
|
+
export declare const injectDataLoaderPlugin: (internalPlugins: InternalPlugins) => {
|
|
7
|
+
'@modern-js/plugin-data-loader': {
|
|
8
|
+
path: string;
|
|
9
|
+
forced: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { IAppContext, NormalizedConfig, ToRunners
|
|
2
|
-
|
|
1
|
+
import type { IAppContext, NormalizedConfig, ToRunners } from '@modern-js/core';
|
|
2
|
+
import type { AppHooks } from '../hooks';
|
|
3
|
+
export declare const printInstructions: (hookRunners: ToRunners<AppHooks>, appContext: IAppContext, config: NormalizedConfig) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "
|
|
14
|
+
"version": "2.0.0-beta.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -55,28 +55,33 @@
|
|
|
55
55
|
"modern": "./bin/modern.js"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@babel/runtime": "^7.18.0",
|
|
59
|
-
"@modern-js/core": "1.21.2",
|
|
60
|
-
"@modern-js/new-action": "1.21.2",
|
|
61
|
-
"@modern-js/upgrade": "1.21.2",
|
|
62
|
-
"@modern-js/node-bundle-require": "1.21.2",
|
|
63
|
-
"@modern-js/plugin": "1.21.2",
|
|
64
|
-
"@modern-js/plugin-i18n": "1.21.2",
|
|
65
|
-
"@modern-js/plugin-jarvis": "1.21.2",
|
|
66
|
-
"@modern-js/prod-server": "1.21.2",
|
|
67
|
-
"@modern-js/server": "1.21.2",
|
|
68
|
-
"@modern-js/types": "1.21.2",
|
|
69
|
-
"@modern-js/utils": "1.21.2",
|
|
70
|
-
"@modern-js/webpack": "1.21.2",
|
|
71
58
|
"@babel/parser": "^7.18.0",
|
|
59
|
+
"@babel/runtime": "^7.18.0",
|
|
72
60
|
"@babel/traverse": "^7.18.0",
|
|
73
|
-
"@babel/types": "^7.18.0"
|
|
61
|
+
"@babel/types": "^7.18.0",
|
|
62
|
+
"@modern-js/core": "2.0.0-beta.0",
|
|
63
|
+
"@modern-js/new-action": "2.0.0-beta.0",
|
|
64
|
+
"@modern-js/node-bundle-require": "2.0.0-beta.0",
|
|
65
|
+
"@modern-js/plugin": "2.0.0-beta.0",
|
|
66
|
+
"@modern-js/plugin-data-loader": "2.0.0-beta.0",
|
|
67
|
+
"@modern-js/plugin-i18n": "2.0.0-beta.0",
|
|
68
|
+
"@modern-js/plugin-jarvis": "2.0.0-beta.0",
|
|
69
|
+
"@modern-js/prod-server": "2.0.0-beta.0",
|
|
70
|
+
"@modern-js/server": "2.0.0-beta.0",
|
|
71
|
+
"@modern-js/types": "2.0.0-beta.0",
|
|
72
|
+
"@modern-js/upgrade": "2.0.0-beta.0",
|
|
73
|
+
"@modern-js/utils": "2.0.0-beta.0",
|
|
74
|
+
"@modern-js/builder": "2.0.0-beta.0",
|
|
75
|
+
"@modern-js/builder-shared": "2.0.0-beta.0",
|
|
76
|
+
"@modern-js/builder-webpack-provider": "2.0.0-beta.0",
|
|
77
|
+
"@modern-js/builder-plugin-node-polyfill": "2.0.0-beta.0",
|
|
78
|
+
"@modern-js/builder-plugin-esbuild": "2.0.0-beta.0"
|
|
74
79
|
},
|
|
75
80
|
"devDependencies": {
|
|
76
|
-
"@modern-js/server-core": "
|
|
81
|
+
"@modern-js/server-core": "2.0.0-beta.0",
|
|
82
|
+
"@scripts/build": "2.0.0-beta.0",
|
|
83
|
+
"@scripts/jest-config": "2.0.0-beta.0",
|
|
77
84
|
"@types/babel__traverse": "^7.14.2",
|
|
78
|
-
"@scripts/build": "1.21.2",
|
|
79
|
-
"@scripts/jest-config": "1.21.2",
|
|
80
85
|
"@types/jest": "^27",
|
|
81
86
|
"@types/node": "^14",
|
|
82
87
|
"jest": "^27",
|
|
@@ -87,33 +92,10 @@
|
|
|
87
92
|
"registry": "https://registry.npmjs.org/",
|
|
88
93
|
"access": "public"
|
|
89
94
|
},
|
|
90
|
-
"wireit": {
|
|
91
|
-
"build": {
|
|
92
|
-
"command": "modern build",
|
|
93
|
-
"files": [
|
|
94
|
-
"src/**/*",
|
|
95
|
-
"tsconfig.json",
|
|
96
|
-
"package.json"
|
|
97
|
-
],
|
|
98
|
-
"output": [
|
|
99
|
-
"dist/**/*"
|
|
100
|
-
]
|
|
101
|
-
},
|
|
102
|
-
"test": {
|
|
103
|
-
"command": "jest --passWithNoTests",
|
|
104
|
-
"files": [
|
|
105
|
-
"src/**/*",
|
|
106
|
-
"tsconfig.json",
|
|
107
|
-
"package.json",
|
|
108
|
-
"tests/**/*"
|
|
109
|
-
],
|
|
110
|
-
"output": []
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
95
|
"scripts": {
|
|
114
96
|
"new": "modern new",
|
|
115
97
|
"dev": "modern build --watch",
|
|
116
|
-
"build": "
|
|
117
|
-
"test": "
|
|
98
|
+
"build": "modern build",
|
|
99
|
+
"test": "jest --passWithNoTests"
|
|
118
100
|
}
|
|
119
101
|
}
|