@modern-js/app-tools 1.17.0 → 1.18.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # @modern-js/app-tools
2
2
 
3
+ ## 1.18.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [3586707]
8
+ - Updated dependencies [c1a4d9b]
9
+ - Updated dependencies [8016a8a]
10
+ - Updated dependencies [f6a3aa1]
11
+ - Updated dependencies [9f7bfa6]
12
+ - Updated dependencies [23fa468]
13
+ - Updated dependencies [9fcfbd4]
14
+ - Updated dependencies [6c2c745]
15
+ - Updated dependencies [55988fa]
16
+ - Updated dependencies [bc3bbd8]
17
+ - @modern-js/prod-server@1.18.1-alpha.0
18
+ - @modern-js/plugin@1.18.1-alpha.0
19
+ - @modern-js/server@1.18.1-alpha.0
20
+ - @modern-js/utils@1.18.1-alpha.0
21
+ - @modern-js/core@1.18.1-alpha.0
22
+ - @modern-js/plugin-i18n@1.18.1-alpha.0
23
+ - @modern-js/plugin-jarvis@1.18.1-alpha.0
24
+ - @modern-js/webpack@1.18.1-alpha.0
25
+ - @modern-js/new-action@1.18.1-alpha.0
26
+ - @modern-js/node-bundle-require@1.18.1-alpha.0
27
+ - @modern-js/upgrade@1.18.1-alpha.0
28
+ - @modern-js/types@1.18.1-alpha.0
29
+
30
+ ## 1.18.0
31
+
32
+ ### Patch Changes
33
+
34
+ - 66ad36f: feat: add source.enableAsyncEntry config
35
+
36
+ feat: 新增 source.enableAsyncEntry 配置项
37
+
38
+ - Updated dependencies [8280920]
39
+ - Updated dependencies [3d5e3a5]
40
+ - Updated dependencies [8280920]
41
+ - Updated dependencies [2b7406d]
42
+ - Updated dependencies [9f13d8c]
43
+ - Updated dependencies [fc7214d]
44
+ - Updated dependencies [60a2e3a]
45
+ - Updated dependencies [5227370]
46
+ - Updated dependencies [66ad36f]
47
+ - Updated dependencies [7928bae]
48
+ - @modern-js/utils@1.18.0
49
+ - @modern-js/prod-server@1.18.0
50
+ - @modern-js/server@1.18.0
51
+ - @modern-js/upgrade@1.18.0
52
+ - @modern-js/core@1.18.0
53
+ - @modern-js/plugin-i18n@1.18.0
54
+ - @modern-js/plugin-jarvis@1.18.0
55
+ - @modern-js/webpack@1.18.0
56
+ - @modern-js/new-action@1.18.0
57
+ - @modern-js/node-bundle-require@1.18.0
58
+ - @modern-js/plugin@1.18.0
59
+ - @modern-js/types@1.18.0
60
+
3
61
  ## 1.17.0
4
62
 
5
63
  ### Patch Changes
@@ -4,6 +4,7 @@ export const APP_FILE_NAME = 'App';
4
4
  export const PAGES_DIR_NAME = 'pages';
5
5
  export const FILE_SYSTEM_ROUTES_FILE_NAME = 'routes.js';
6
6
  export const ENTRY_POINT_FILE_NAME = 'index.js';
7
+ export const ENTRY_BOOTSTRAP_FILE_NAME = 'bootstrap.js';
7
8
  export const FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = /^\[(\S+)\]([*+?]?)$/;
8
9
  export const FILE_SYSTEM_ROUTES_LAYOUT = '_layout';
9
10
  export const FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = '_app';
@@ -2,7 +2,7 @@ import path from 'path';
2
2
  import { fs } from '@modern-js/utils';
3
3
  import * as templates from "./templates";
4
4
  import { getClientRoutes } from "./getClientRoutes";
5
- import { FILE_SYSTEM_ROUTES_FILE_NAME, ENTRY_POINT_FILE_NAME } from "./constants";
5
+ import { FILE_SYSTEM_ROUTES_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_BOOTSTRAP_FILE_NAME } from "./constants";
6
6
  import { getDefaultImports } from "./utils";
7
7
 
8
8
  const createImportSpecifier = specifiers => {
@@ -157,11 +157,23 @@ export const generateCode = async (appContext, config, entrypoints, api) => {
157
157
  imports: createImportStatements(importStatements),
158
158
  renderFunction,
159
159
  exportStatement
160
- }); // generate entry file.
161
-
160
+ });
162
161
  const entryFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_FILE_NAME}`);
163
- entrypoint.entry = entryFile;
164
- fs.outputFileSync(entryFile, code, 'utf8');
162
+ entrypoint.entry = entryFile; // generate entry file.
163
+
164
+ if (config.source.enableAsyncEntry) {
165
+ const {
166
+ code: asyncEntryCode
167
+ } = await hookRunners.modifyAsyncEntry({
168
+ entrypoint,
169
+ code: `import('./${ENTRY_BOOTSTRAP_FILE_NAME}');`
170
+ });
171
+ fs.outputFileSync(entryFile, asyncEntryCode, 'utf8');
172
+ const bootstrapFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_BOOTSTRAP_FILE_NAME}`);
173
+ fs.outputFileSync(bootstrapFile, code, 'utf8');
174
+ } else {
175
+ fs.outputFileSync(entryFile, code, 'utf8');
176
+ }
165
177
  }
166
178
  }
167
179
  };
@@ -15,6 +15,7 @@ export const modifyEntryExport = createAsyncWaterfall();
15
15
  export const addRuntimeExports = createAsyncWaterfall();
16
16
  export const modifyEntryRuntimePlugins = createAsyncWaterfall();
17
17
  export const modifyEntryRenderFunction = createAsyncWaterfall();
18
+ export const modifyAsyncEntry = createAsyncWaterfall();
18
19
  export const modifyFileSystemRoutes = createAsyncWaterfall();
19
20
  export const modifyServerRoutes = createAsyncWaterfall();
20
21
  export const htmlPartials = createAsyncWaterfall();
@@ -23,6 +24,7 @@ export const addDefineTypes = createAsyncWaterfall();
23
24
  export default (() => ({
24
25
  name: '@modern-js/plugin-analyze',
25
26
  registerHook: {
27
+ modifyAsyncEntry,
26
28
  modifyEntryImports,
27
29
  modifyEntryExport,
28
30
  modifyEntryRuntimePlugins,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.PAGES_DIR_NAME = exports.JS_EXTENSIONS = exports.INDEX_FILE_NAME = exports.HTML_PARTIALS_FOLDER = exports.HTML_PARTIALS_EXTENSIONS = exports.FILE_SYSTEM_ROUTES_LAYOUT = exports.FILE_SYSTEM_ROUTES_INDEX = exports.FILE_SYSTEM_ROUTES_IGNORED_REGEX = exports.FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = exports.FILE_SYSTEM_ROUTES_FILE_NAME = exports.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = exports.FILE_SYSTEM_ROUTES_COMPONENTS_DIR = exports.ENTRY_POINT_FILE_NAME = exports.APP_FILE_NAME = void 0;
6
+ exports.PAGES_DIR_NAME = exports.JS_EXTENSIONS = exports.INDEX_FILE_NAME = exports.HTML_PARTIALS_FOLDER = exports.HTML_PARTIALS_EXTENSIONS = exports.FILE_SYSTEM_ROUTES_LAYOUT = exports.FILE_SYSTEM_ROUTES_INDEX = exports.FILE_SYSTEM_ROUTES_IGNORED_REGEX = exports.FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = exports.FILE_SYSTEM_ROUTES_FILE_NAME = exports.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = exports.FILE_SYSTEM_ROUTES_COMPONENTS_DIR = exports.ENTRY_POINT_FILE_NAME = exports.ENTRY_BOOTSTRAP_FILE_NAME = exports.APP_FILE_NAME = void 0;
7
7
  const JS_EXTENSIONS = ['.js', '.ts', '.jsx', '.tsx'];
8
8
  exports.JS_EXTENSIONS = JS_EXTENSIONS;
9
9
  const INDEX_FILE_NAME = 'index';
@@ -16,6 +16,8 @@ const FILE_SYSTEM_ROUTES_FILE_NAME = 'routes.js';
16
16
  exports.FILE_SYSTEM_ROUTES_FILE_NAME = FILE_SYSTEM_ROUTES_FILE_NAME;
17
17
  const ENTRY_POINT_FILE_NAME = 'index.js';
18
18
  exports.ENTRY_POINT_FILE_NAME = ENTRY_POINT_FILE_NAME;
19
+ const ENTRY_BOOTSTRAP_FILE_NAME = 'bootstrap.js';
20
+ exports.ENTRY_BOOTSTRAP_FILE_NAME = ENTRY_BOOTSTRAP_FILE_NAME;
19
21
  const FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = /^\[(\S+)\]([*+?]?)$/;
20
22
  exports.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP;
21
23
  const FILE_SYSTEM_ROUTES_LAYOUT = '_layout';
@@ -179,13 +179,28 @@ const generateCode = async (appContext, config, entrypoints, api) => {
179
179
  imports: createImportStatements(importStatements),
180
180
  renderFunction,
181
181
  exportStatement
182
- }); // generate entry file.
182
+ });
183
183
 
184
184
  const entryFile = _path.default.resolve(internalDirectory, `./${entryName}/${_constants.ENTRY_POINT_FILE_NAME}`);
185
185
 
186
- entrypoint.entry = entryFile;
186
+ entrypoint.entry = entryFile; // generate entry file.
187
+
188
+ if (config.source.enableAsyncEntry) {
189
+ const {
190
+ code: asyncEntryCode
191
+ } = await hookRunners.modifyAsyncEntry({
192
+ entrypoint,
193
+ code: `import('./${_constants.ENTRY_BOOTSTRAP_FILE_NAME}');`
194
+ });
195
+
196
+ _utils.fs.outputFileSync(entryFile, asyncEntryCode, 'utf8');
197
+
198
+ const bootstrapFile = _path.default.resolve(internalDirectory, `./${entryName}/${_constants.ENTRY_BOOTSTRAP_FILE_NAME}`);
187
199
 
188
- _utils.fs.outputFileSync(entryFile, code, 'utf8');
200
+ _utils.fs.outputFileSync(bootstrapFile, code, 'utf8');
201
+ } else {
202
+ _utils.fs.outputFileSync(entryFile, code, 'utf8');
203
+ }
189
204
  }
190
205
  }
191
206
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.modifyServerRoutes = exports.modifyFileSystemRoutes = exports.modifyEntryRuntimePlugins = exports.modifyEntryRenderFunction = exports.modifyEntryImports = exports.modifyEntryExport = exports.htmlPartials = exports.default = exports.beforeGenerateRoutes = exports.addRuntimeExports = exports.addDefineTypes = void 0;
6
+ exports.modifyServerRoutes = exports.modifyFileSystemRoutes = exports.modifyEntryRuntimePlugins = exports.modifyEntryRenderFunction = exports.modifyEntryImports = exports.modifyEntryExport = exports.modifyAsyncEntry = exports.htmlPartials = exports.default = exports.beforeGenerateRoutes = exports.addRuntimeExports = exports.addDefineTypes = void 0;
7
7
 
8
8
  var path = _interopRequireWildcard(require("path"));
9
9
 
@@ -36,6 +36,8 @@ const modifyEntryRuntimePlugins = (0, _plugin.createAsyncWaterfall)();
36
36
  exports.modifyEntryRuntimePlugins = modifyEntryRuntimePlugins;
37
37
  const modifyEntryRenderFunction = (0, _plugin.createAsyncWaterfall)();
38
38
  exports.modifyEntryRenderFunction = modifyEntryRenderFunction;
39
+ const modifyAsyncEntry = (0, _plugin.createAsyncWaterfall)();
40
+ exports.modifyAsyncEntry = modifyAsyncEntry;
39
41
  const modifyFileSystemRoutes = (0, _plugin.createAsyncWaterfall)();
40
42
  exports.modifyFileSystemRoutes = modifyFileSystemRoutes;
41
43
  const modifyServerRoutes = (0, _plugin.createAsyncWaterfall)();
@@ -50,6 +52,7 @@ exports.addDefineTypes = addDefineTypes;
50
52
  var _default = () => ({
51
53
  name: '@modern-js/plugin-analyze',
52
54
  registerHook: {
55
+ modifyAsyncEntry,
53
56
  modifyEntryImports,
54
57
  modifyEntryExport,
55
58
  modifyEntryRuntimePlugins,
@@ -4,6 +4,7 @@ export declare const APP_FILE_NAME = "App";
4
4
  export declare const PAGES_DIR_NAME = "pages";
5
5
  export declare const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
6
6
  export declare const ENTRY_POINT_FILE_NAME = "index.js";
7
+ export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.js";
7
8
  export declare const FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP: RegExp;
8
9
  export declare const FILE_SYSTEM_ROUTES_LAYOUT = "_layout";
9
10
  export declare const FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = "_app";
@@ -17,6 +17,10 @@ export declare const modifyEntryRenderFunction: import("@modern-js/plugin").Asyn
17
17
  entrypoint: Entrypoint;
18
18
  code: string;
19
19
  }>;
20
+ export declare const modifyAsyncEntry: import("@modern-js/plugin").AsyncWaterfall<{
21
+ entrypoint: Entrypoint;
22
+ code: string;
23
+ }>;
20
24
  export declare const modifyFileSystemRoutes: import("@modern-js/plugin").AsyncWaterfall<{
21
25
  entrypoint: Entrypoint;
22
26
  routes: Route[];
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.17.0",
14
+ "version": "1.18.1-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -56,27 +56,27 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@babel/runtime": "^7.18.0",
59
- "@modern-js/core": "1.17.0",
60
- "@modern-js/new-action": "1.17.0",
61
- "@modern-js/upgrade": "1.17.0",
62
- "@modern-js/node-bundle-require": "1.17.0",
63
- "@modern-js/plugin": "1.17.0",
64
- "@modern-js/plugin-i18n": "1.17.0",
65
- "@modern-js/plugin-jarvis": "1.17.0",
66
- "@modern-js/prod-server": "1.17.0",
67
- "@modern-js/server": "1.17.0",
68
- "@modern-js/types": "1.17.0",
69
- "@modern-js/utils": "1.17.0",
70
- "@modern-js/webpack": "1.17.0",
59
+ "@modern-js/core": "1.18.1-alpha.0",
60
+ "@modern-js/new-action": "1.18.1-alpha.0",
61
+ "@modern-js/upgrade": "1.18.1-alpha.0",
62
+ "@modern-js/node-bundle-require": "1.18.1-alpha.0",
63
+ "@modern-js/plugin": "1.18.1-alpha.0",
64
+ "@modern-js/plugin-i18n": "1.18.1-alpha.0",
65
+ "@modern-js/plugin-jarvis": "1.18.1-alpha.0",
66
+ "@modern-js/prod-server": "1.18.1-alpha.0",
67
+ "@modern-js/server": "1.18.1-alpha.0",
68
+ "@modern-js/types": "1.18.1-alpha.0",
69
+ "@modern-js/utils": "1.18.1-alpha.0",
70
+ "@modern-js/webpack": "1.18.1-alpha.0",
71
71
  "@babel/parser": "^7.18.0",
72
72
  "@babel/traverse": "^7.18.0",
73
73
  "@babel/types": "^7.18.0"
74
74
  },
75
75
  "devDependencies": {
76
- "@modern-js/server-core": "1.17.0",
76
+ "@modern-js/server-core": "1.18.1-alpha.0",
77
77
  "@types/babel__traverse": "^7.14.2",
78
- "@scripts/build": "1.17.0",
79
- "@scripts/jest-config": "1.17.0",
78
+ "@scripts/build": "1.18.1-alpha.0",
79
+ "@scripts/jest-config": "1.18.1-alpha.0",
80
80
  "@types/jest": "^27",
81
81
  "@types/node": "^14",
82
82
  "jest": "^27",