@modern-js/app-tools 1.21.3 → 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.
Files changed (146) hide show
  1. package/CHANGELOG.md +138 -16
  2. package/dist/js/modern/analyze/constants.js +1 -0
  3. package/dist/js/modern/analyze/generateCode.js +118 -16
  4. package/dist/js/modern/analyze/getBundleEntry.js +3 -2
  5. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +198 -0
  6. package/dist/js/modern/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +8 -28
  7. package/dist/js/modern/analyze/getClientRoutes/index.js +2 -0
  8. package/dist/js/modern/analyze/getClientRoutes/utils.js +21 -0
  9. package/dist/js/modern/analyze/getFileSystemEntry.js +31 -12
  10. package/dist/js/modern/analyze/index.js +2 -1
  11. package/dist/js/modern/analyze/nestedRoutes.js +127 -0
  12. package/dist/js/modern/analyze/templates.js +164 -10
  13. package/dist/js/modern/analyze/utils.js +2 -1
  14. package/dist/js/modern/builder/builderPlugins/compatModern.js +226 -0
  15. package/dist/js/modern/builder/createHtmlConfig.js +58 -0
  16. package/dist/js/modern/builder/createOutputConfig.js +67 -0
  17. package/dist/js/modern/builder/createSourceConfig.js +85 -0
  18. package/dist/js/modern/builder/createToolsConfig.js +94 -0
  19. package/dist/js/modern/builder/index.js +106 -0
  20. package/dist/js/modern/builder/share.js +48 -0
  21. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +37 -0
  22. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +44 -0
  23. package/dist/js/modern/commands/build.js +41 -95
  24. package/dist/js/modern/commands/dev.js +15 -19
  25. package/dist/js/modern/commands/inspect.js +17 -58
  26. package/dist/js/modern/commands/start.js +2 -1
  27. package/dist/js/modern/index.js +14 -4
  28. package/dist/js/modern/locale/en.js +0 -1
  29. package/dist/js/modern/locale/zh.js +0 -1
  30. package/dist/js/modern/utils/commands.js +5 -0
  31. package/dist/js/modern/utils/createCompiler.js +37 -40
  32. package/dist/js/modern/utils/createServer.js +16 -0
  33. package/dist/js/modern/utils/printInstructions.js +1 -1
  34. package/dist/js/node/analyze/constants.js +3 -1
  35. package/dist/js/node/analyze/generateCode.js +121 -14
  36. package/dist/js/node/analyze/getBundleEntry.js +3 -2
  37. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +221 -0
  38. package/dist/js/node/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +16 -35
  39. package/dist/js/node/analyze/getClientRoutes/index.js +21 -0
  40. package/dist/js/node/analyze/getClientRoutes/utils.js +42 -0
  41. package/dist/js/node/analyze/getFileSystemEntry.js +30 -11
  42. package/dist/js/node/analyze/index.js +2 -1
  43. package/dist/js/node/analyze/nestedRoutes.js +144 -0
  44. package/dist/js/node/analyze/templates.js +167 -10
  45. package/dist/js/node/analyze/utils.js +6 -2
  46. package/dist/js/node/builder/builderPlugins/compatModern.js +245 -0
  47. package/dist/js/node/builder/createHtmlConfig.js +76 -0
  48. package/dist/js/node/builder/createOutputConfig.js +75 -0
  49. package/dist/js/node/builder/createSourceConfig.js +99 -0
  50. package/dist/js/node/builder/createToolsConfig.js +103 -0
  51. package/dist/js/node/builder/index.js +129 -0
  52. package/dist/js/node/builder/share.js +63 -0
  53. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +46 -0
  54. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +53 -0
  55. package/dist/js/node/commands/build.js +44 -98
  56. package/dist/js/node/commands/dev.js +13 -23
  57. package/dist/js/node/commands/inspect.js +18 -74
  58. package/dist/js/node/commands/start.js +3 -1
  59. package/dist/js/node/index.js +19 -2
  60. package/dist/js/node/locale/en.js +0 -1
  61. package/dist/js/node/locale/zh.js +0 -1
  62. package/dist/js/node/utils/commands.js +14 -0
  63. package/dist/js/node/utils/createCompiler.js +43 -49
  64. package/dist/js/node/utils/createServer.js +21 -2
  65. package/dist/js/node/utils/printInstructions.js +1 -1
  66. package/dist/js/treeshaking/analyze/constants.js +16 -0
  67. package/dist/js/treeshaking/analyze/generateCode.js +412 -0
  68. package/dist/js/treeshaking/analyze/getBundleEntry.js +77 -0
  69. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +210 -0
  70. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +211 -0
  71. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +2 -0
  72. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +27 -0
  73. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +109 -0
  74. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +153 -0
  75. package/dist/js/treeshaking/analyze/getServerRoutes.js +170 -0
  76. package/dist/js/treeshaking/analyze/index.js +214 -0
  77. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +32 -0
  78. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +18 -0
  79. package/dist/js/treeshaking/analyze/nestedRoutes.js +207 -0
  80. package/dist/js/treeshaking/analyze/templates.js +189 -0
  81. package/dist/js/treeshaking/analyze/utils.js +95 -0
  82. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +231 -0
  83. package/dist/js/treeshaking/builder/createHtmlConfig.js +59 -0
  84. package/dist/js/treeshaking/builder/createOutputConfig.js +67 -0
  85. package/dist/js/treeshaking/builder/createSourceConfig.js +100 -0
  86. package/dist/js/treeshaking/builder/createToolsConfig.js +90 -0
  87. package/dist/js/treeshaking/builder/index.js +172 -0
  88. package/dist/js/treeshaking/builder/share.js +50 -0
  89. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +58 -0
  90. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +53 -0
  91. package/dist/js/treeshaking/commands/build.js +168 -0
  92. package/dist/js/treeshaking/commands/deploy.js +29 -0
  93. package/dist/js/treeshaking/commands/dev.js +146 -0
  94. package/dist/js/treeshaking/commands/index.js +3 -0
  95. package/dist/js/treeshaking/commands/inspect.js +52 -0
  96. package/dist/js/treeshaking/commands/start.js +78 -0
  97. package/dist/js/treeshaking/exports/server.js +1 -0
  98. package/dist/js/treeshaking/hooks.js +21 -0
  99. package/dist/js/treeshaking/index.js +304 -0
  100. package/dist/js/treeshaking/locale/en.js +34 -0
  101. package/dist/js/treeshaking/locale/index.js +9 -0
  102. package/dist/js/treeshaking/locale/zh.js +34 -0
  103. package/dist/js/treeshaking/utils/commands.js +5 -0
  104. package/dist/js/treeshaking/utils/config.js +140 -0
  105. package/dist/js/treeshaking/utils/createCompiler.js +117 -0
  106. package/dist/js/treeshaking/utils/createServer.js +83 -0
  107. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +68 -0
  108. package/dist/js/treeshaking/utils/language.js +5 -0
  109. package/dist/js/treeshaking/utils/printInstructions.js +35 -0
  110. package/dist/js/treeshaking/utils/routes.js +33 -0
  111. package/dist/js/treeshaking/utils/types.js +0 -0
  112. package/dist/types/analyze/constants.d.ts +1 -0
  113. package/dist/types/analyze/generateCode.d.ts +1 -1
  114. package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
  115. package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
  116. package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
  117. package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
  118. package/dist/types/analyze/index.d.ts +2 -2
  119. package/dist/types/analyze/nestedRoutes.d.ts +5 -0
  120. package/dist/types/analyze/templates.d.ts +17 -3
  121. package/dist/types/analyze/utils.d.ts +2 -1
  122. package/dist/types/builder/builderPlugins/compatModern.d.ts +14 -0
  123. package/dist/types/builder/createHtmlConfig.d.ts +6 -0
  124. package/dist/types/builder/createOutputConfig.d.ts +3 -0
  125. package/dist/types/builder/createSourceConfig.d.ts +5 -0
  126. package/dist/types/builder/createToolsConfig.d.ts +13 -0
  127. package/dist/types/builder/index.d.ts +19 -0
  128. package/dist/types/builder/share.d.ts +26 -0
  129. package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
  130. package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
  131. package/dist/types/commands/build.d.ts +2 -1
  132. package/dist/types/commands/deploy.d.ts +2 -1
  133. package/dist/types/commands/dev.d.ts +2 -1
  134. package/dist/types/commands/inspect.d.ts +5 -6
  135. package/dist/types/commands/start.d.ts +2 -1
  136. package/dist/types/hooks.d.ts +15 -10
  137. package/dist/types/index.d.ts +4 -2
  138. package/dist/types/locale/en.d.ts +0 -1
  139. package/dist/types/locale/index.d.ts +0 -2
  140. package/dist/types/locale/zh.d.ts +0 -1
  141. package/dist/types/utils/commands.d.ts +1 -0
  142. package/dist/types/utils/createCompiler.d.ts +9 -10
  143. package/dist/types/utils/createServer.d.ts +8 -1
  144. package/dist/types/utils/printInstructions.d.ts +3 -2
  145. package/dist/types/utils/types.d.ts +2 -3
  146. package/package.json +25 -43
@@ -1,37 +1,42 @@
1
- import type { Compiler, Configuration, MultiCompiler } from '@modern-js/webpack';
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
- webpackConfigs: Configuration[];
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
- webpackConfigs: Configuration[];
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
- webpackConfigs: Configuration[];
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
- webpackConfigs: Configuration[];
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;
@@ -1,6 +1,8 @@
1
1
  import { defineConfig, CliPlugin } from '@modern-js/core';
2
- export { defineConfig };
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;
@@ -28,7 +28,6 @@ export declare const EN_LOCALE: {
28
28
  inspect: {
29
29
  env: string;
30
30
  output: string;
31
- noConsole: string;
32
31
  verbose: string;
33
32
  };
34
33
  };
@@ -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
  };
@@ -28,7 +28,6 @@ export declare const ZH_LOCALE: {
28
28
  inspect: {
29
29
  env: string;
30
30
  output: string;
31
- noConsole: string;
32
31
  verbose: string;
33
32
  };
34
33
  };
@@ -0,0 +1 @@
1
+ export declare const getCommand: () => string;
@@ -1,13 +1,12 @@
1
- import { webpack, Configuration } from '@modern-js/webpack';
2
- import type { IAppContext, NormalizedConfig, PluginAPI } from '@modern-js/core';
3
- export declare const createCompiler: ({
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
- webpackConfigs,
6
- userConfig,
7
+ target,
8
+ normalizedConfig,
7
9
  appContext
8
10
  }: {
9
- api: PluginAPI;
10
- webpackConfigs: Configuration[];
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, CliHooks } from '@modern-js/core';
2
- export declare const printInstructions: (hookRunners: ToRunners<CliHooks>, appContext: IAppContext, config: NormalizedConfig) => Promise<void>;
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>;
@@ -15,8 +15,7 @@ export declare type StartOptions = {
15
15
  apiOnly?: boolean;
16
16
  };
17
17
  export declare type InspectOptions = {
18
- env?: string;
19
- output?: string;
20
- console?: boolean;
18
+ env: string;
19
+ output: string;
21
20
  verbose?: boolean;
22
21
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.3",
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.3",
60
- "@modern-js/new-action": "1.21.3",
61
- "@modern-js/upgrade": "1.21.3",
62
- "@modern-js/node-bundle-require": "1.21.3",
63
- "@modern-js/plugin": "1.21.3",
64
- "@modern-js/plugin-i18n": "1.21.3",
65
- "@modern-js/plugin-jarvis": "1.21.3",
66
- "@modern-js/prod-server": "1.21.3",
67
- "@modern-js/server": "1.21.3",
68
- "@modern-js/types": "1.21.3",
69
- "@modern-js/utils": "1.21.3",
70
- "@modern-js/webpack": "1.21.3",
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": "1.21.3",
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.3",
79
- "@scripts/jest-config": "1.21.3",
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": "wireit",
117
- "test": "wireit"
98
+ "build": "modern build",
99
+ "test": "jest --passWithNoTests"
118
100
  }
119
101
  }