@modern-js/runtime 2.63.3 → 2.63.4

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 (38) hide show
  1. package/dist/cjs/cli/code.js +2 -2
  2. package/dist/cjs/cli/index.js +102 -108
  3. package/dist/cjs/cli/ssr/index.js +49 -52
  4. package/dist/cjs/document/cli/index.js +32 -34
  5. package/dist/cjs/router/cli/code/index.js +5 -5
  6. package/dist/cjs/router/cli/handler.js +6 -6
  7. package/dist/cjs/router/cli/index.js +76 -78
  8. package/dist/cjs/router/runtime/plugin.js +1 -4
  9. package/dist/cjs/state/cli/index.js +22 -24
  10. package/dist/esm/cli/code.js +3 -3
  11. package/dist/esm/cli/index.js +120 -130
  12. package/dist/esm/cli/ssr/index.js +50 -53
  13. package/dist/esm/document/cli/index.js +28 -30
  14. package/dist/esm/router/cli/code/index.js +8 -8
  15. package/dist/esm/router/cli/handler.js +6 -6
  16. package/dist/esm/router/cli/index.js +161 -157
  17. package/dist/esm/router/runtime/plugin.js +1 -4
  18. package/dist/esm/state/cli/index.js +23 -25
  19. package/dist/esm-node/cli/code.js +2 -2
  20. package/dist/esm-node/cli/index.js +102 -108
  21. package/dist/esm-node/cli/ssr/index.js +49 -52
  22. package/dist/esm-node/document/cli/index.js +32 -34
  23. package/dist/esm-node/router/cli/code/index.js +5 -5
  24. package/dist/esm-node/router/cli/handler.js +6 -6
  25. package/dist/esm-node/router/cli/index.js +76 -78
  26. package/dist/esm-node/router/runtime/plugin.js +1 -4
  27. package/dist/esm-node/state/cli/index.js +22 -24
  28. package/dist/types/cli/code.d.ts +2 -9
  29. package/dist/types/cli/index.d.ts +3 -3
  30. package/dist/types/cli/ssr/index.d.ts +2 -2
  31. package/dist/types/document/cli/index.d.ts +2 -2
  32. package/dist/types/router/cli/code/index.d.ts +3 -3
  33. package/dist/types/router/cli/code/templates.d.ts +2 -2
  34. package/dist/types/router/cli/handler.d.ts +4 -4
  35. package/dist/types/router/cli/index.d.ts +2 -2
  36. package/dist/types/router/runtime/types.d.ts +0 -10
  37. package/dist/types/state/cli/index.d.ts +2 -2
  38. package/package.json +11 -11
@@ -48,7 +48,7 @@ var ssrBuilderPlugin = function(modernAPI) {
48
48
  api.modifyEnvironmentConfig(function(config, param) {
49
49
  var name = param.name, mergeEnvironmentConfig = param.mergeEnvironmentConfig;
50
50
  var isServerEnvironment = config.output.target === "node" || name === "workerSSR";
51
- var userConfig = modernAPI.useResolvedConfigContext();
51
+ var userConfig = modernAPI.getNormalizedConfig();
52
52
  var useLoadablePlugin = isUseSSRBundle(userConfig) && !isServerEnvironment && checkUseStringSSR(userConfig);
53
53
  return mergeEnvironmentConfig(config, {
54
54
  source: {
@@ -78,61 +78,58 @@ var ssrPlugin = function() {
78
78
  "@modern-js/runtime"
79
79
  ],
80
80
  setup: function(api) {
81
- var appContext = api.useAppContext();
82
- return {
83
- // for bundle
84
- config: function config() {
85
- var _api_useAppContext = api.useAppContext(), _api_useAppContext_bundlerType = _api_useAppContext.bundlerType, bundlerType = _api_useAppContext_bundlerType === void 0 ? "webpack" : _api_useAppContext_bundlerType;
86
- var babelHandler = function() {
87
- if (bundlerType === "webpack") {
88
- return function(config2) {
89
- var _config_plugins;
90
- var userConfig = api.useResolvedConfigContext();
91
- (_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
92
- if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
93
- var _config_plugins1;
94
- (_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
95
- }
96
- };
97
- } else if (bundlerType === "rspack") {
98
- return function(config2) {
99
- var userConfig = api.useResolvedConfigContext();
100
- if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
101
- var _config_plugins, _config_plugins1;
102
- (_config_plugins = config2.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
103
- (_config_plugins1 = config2.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
104
- }
105
- };
106
- }
107
- }();
108
- return {
109
- builderPlugins: [
110
- ssrBuilderPlugin(api)
111
- ],
112
- source: {
113
- alias: {
114
- // ensure that all packages use the same storage in @modern-js/runtime-utils/node
115
- "@modern-js/runtime-utils/node$": require.resolve("@modern-js/runtime-utils/node")
81
+ var appContext = api.getAppContext();
82
+ api.config(function() {
83
+ var _api_getAppContext = api.getAppContext(), _api_getAppContext_bundlerType = _api_getAppContext.bundlerType, bundlerType = _api_getAppContext_bundlerType === void 0 ? "webpack" : _api_getAppContext_bundlerType;
84
+ var babelHandler = function() {
85
+ if (bundlerType === "webpack") {
86
+ return function(config) {
87
+ var _config_plugins;
88
+ var userConfig = api.getNormalizedConfig();
89
+ (_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
90
+ if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
91
+ var _config_plugins1;
92
+ (_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
116
93
  }
117
- },
118
- tools: {
119
- babel: babelHandler,
120
- bundlerChain: function(chain, param) {
121
- var isServer = param.isServer;
122
- if (isServer && appContext.moduleType === "module") {
123
- chain.output.libraryTarget("module").set("chunkFormat", "module");
124
- chain.output.library({
125
- type: "module"
126
- });
127
- chain.experiments(_object_spread_props(_object_spread({}, chain.get("experiments")), {
128
- outputModule: true
129
- }));
130
- }
94
+ };
95
+ } else if (bundlerType === "rspack") {
96
+ return function(config) {
97
+ var userConfig = api.useResolvedConfigContext();
98
+ if (isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig)) {
99
+ var _config_plugins, _config_plugins1;
100
+ (_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(path.join(__dirname, "./babel-plugin-ssr-loader-id"));
101
+ (_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
131
102
  }
103
+ };
104
+ }
105
+ }();
106
+ return {
107
+ builderPlugins: [
108
+ ssrBuilderPlugin(api)
109
+ ],
110
+ source: {
111
+ alias: {
112
+ // ensure that all packages use the same storage in @modern-js/runtime-utils/node
113
+ "@modern-js/runtime-utils/node$": require.resolve("@modern-js/runtime-utils/node")
132
114
  }
133
- };
134
- }
135
- };
115
+ },
116
+ tools: {
117
+ babel: babelHandler,
118
+ bundlerChain: function(chain, param) {
119
+ var isServer = param.isServer;
120
+ if (isServer && appContext.moduleType === "module") {
121
+ chain.output.libraryTarget("module").set("chunkFormat", "module");
122
+ chain.output.library({
123
+ type: "module"
124
+ });
125
+ chain.experiments(_object_spread_props(_object_spread({}, chain.get("experiments")), {
126
+ outputModule: true
127
+ }));
128
+ }
129
+ }
130
+ }
131
+ };
132
+ });
136
133
  }
137
134
  };
138
135
  };
@@ -50,7 +50,7 @@ var documentPlugin = function() {
50
50
  }
51
51
  return _ts_generator(this, function(_state) {
52
52
  documentEntry = function(entryName, templateParameters) {
53
- var _api_useAppContext = api.useAppContext(), entrypoints = _api_useAppContext.entrypoints, internalDirectory = _api_useAppContext.internalDirectory, appDirectory = _api_useAppContext.appDirectory;
53
+ var _api_getAppContext = api.getAppContext(), entrypoints = _api_getAppContext.entrypoints, internalDirectory = _api_getAppContext.internalDirectory, appDirectory = _api_getAppContext.appDirectory;
54
54
  var documentFilePath = getDocumenByEntryName(entrypoints, entryName, appDirectory);
55
55
  if (!documentFilePath) {
56
56
  return null;
@@ -62,7 +62,7 @@ var documentPlugin = function() {
62
62
  switch (_state2.label) {
63
63
  case 0:
64
64
  htmlWebpackPlugin = param.htmlWebpackPlugin;
65
- config = api.useResolvedConfigContext();
65
+ config = api.getNormalizedConfig();
66
66
  documentParams = getDocParams({
67
67
  config,
68
68
  entryName,
@@ -156,7 +156,7 @@ var documentPlugin = function() {
156
156
  }, React.createElement(Document, null));
157
157
  html = ReactDomServer.renderToStaticMarkup(HTMLElement);
158
158
  debug("entry %s's document jsx rendered html: %o", entryName, html);
159
- partialsByEntrypoint = api.useAppContext().partialsByEntrypoint;
159
+ partialsByEntrypoint = api.getAppContext().partialsByEntrypoint;
160
160
  scripts = [
161
161
  htmlWebpackPlugin.tags.headTags.filter(function(item) {
162
162
  return item.tagName === "script";
@@ -218,35 +218,33 @@ var documentPlugin = function() {
218
218
  };
219
219
  }();
220
220
  };
221
- return [
222
- 2,
223
- {
224
- config: function() {
225
- var _userConfig_tools;
226
- var userConfig = api.useConfigContext();
227
- if (((_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.htmlPlugin) === false) {
228
- return {};
221
+ api.config(function() {
222
+ var _userConfig_tools;
223
+ var userConfig = api.getConfig();
224
+ if (((_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.htmlPlugin) === false) {
225
+ return {};
226
+ }
227
+ return {
228
+ tools: {
229
+ htmlPlugin: function(options, entry) {
230
+ var hackParameters = typeof (options === null || options === void 0 ? void 0 : options.templateParameters) === "function" ? options === null || options === void 0 ? void 0 : options.templateParameters({}, {}, {}, {}) : _object_spread({}, options === null || options === void 0 ? void 0 : options.templateParameters);
231
+ var templateContent = documentEntry(
232
+ entry.entryName,
233
+ // options,
234
+ hackParameters
235
+ );
236
+ var documentHtmlOptions = templateContent ? {
237
+ templateContent,
238
+ // Note: the behavior of inject/modify tags in afterTemplateExecution hook will not take effect
239
+ inject: false
240
+ } : {};
241
+ return _object_spread({}, options, documentHtmlOptions);
229
242
  }
230
- return {
231
- tools: {
232
- htmlPlugin: function(options, entry) {
233
- var hackParameters = typeof (options === null || options === void 0 ? void 0 : options.templateParameters) === "function" ? options === null || options === void 0 ? void 0 : options.templateParameters({}, {}, {}, {}) : _object_spread({}, options === null || options === void 0 ? void 0 : options.templateParameters);
234
- var templateContent = documentEntry(
235
- entry.entryName,
236
- // options,
237
- hackParameters
238
- );
239
- var documentHtmlOptions = templateContent ? {
240
- templateContent,
241
- // Note: the behavior of inject/modify tags in afterTemplateExecution hook will not take effect
242
- inject: false
243
- } : {};
244
- return _object_spread({}, options, documentHtmlOptions);
245
- }
246
- }
247
- };
248
243
  }
249
- }
244
+ };
245
+ });
246
+ return [
247
+ 2
250
248
  ];
251
249
  });
252
250
  });
@@ -13,18 +13,18 @@ import * as templates from "./templates";
13
13
  import { getServerCombinedModueFile, getServerLoadersFile } from "./utils";
14
14
  var generateCode = function() {
15
15
  var _ref = _async_to_generator(function(appContext, config, entrypoints, api) {
16
- var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hookRunners, isV5, getRoutes, oldVersion;
16
+ var internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName, hooks, isV5, getRoutes, oldVersion;
17
17
  function generateEntryCode(entrypoint) {
18
18
  return _generateEntryCode.apply(this, arguments);
19
19
  }
20
20
  function _generateEntryCode() {
21
21
  _generateEntryCode = _async_to_generator(function(entrypoint) {
22
- var entryName, isMainEntry, isAutoMount, pageRoutesEntry, nestedRoutesEntry, metaName, _config_output, initialRoutes, nestedRoutes, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, _$config, ssrByRouteIds, clonedRoutes, markedRoutes, routes, ssr, useSSG, mode, hasPageRoute, code, _, _tmp, _config_output1, routesServerFile, filtedRoutesForServer, routesForServerLoaderMatches, code1, serverRoutesCode, serverLoaderCombined, serverLoaderFile;
22
+ var entryName, isMainEntry, isAutoMount, pageRoutesEntry, nestedRoutesEntry, metaName, _config_output, initialRoutes, nestedRoutes, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, route, _$config, ssrByRouteIds, clonedRoutes, markedRoutes, routes, ssr, useSSG, mode, hasPageRoute, code, _, _1, _tmp, _config_output1, routesServerFile, filtedRoutesForServer, routesForServerLoaderMatches, code1, serverRoutesCode, serverLoaderCombined, serverLoaderFile;
23
23
  return _ts_generator(this, function(_state) {
24
24
  switch (_state.label) {
25
25
  case 0:
26
26
  entryName = entrypoint.entryName, isMainEntry = entrypoint.isMainEntry, isAutoMount = entrypoint.isAutoMount, pageRoutesEntry = entrypoint.pageRoutesEntry, nestedRoutesEntry = entrypoint.nestedRoutesEntry;
27
- metaName = api.useAppContext().metaName;
27
+ metaName = api.getAppContext().metaName;
28
28
  if (!isAutoMount)
29
29
  return [
30
30
  3,
@@ -89,13 +89,13 @@ var generateCode = function() {
89
89
  }
90
90
  _state.label = 2;
91
91
  case 2:
92
- _$config = api.useResolvedConfigContext();
92
+ _$config = api.getNormalizedConfig();
93
93
  ssrByRouteIds = _$config.server.ssrByRouteIds || [];
94
94
  clonedRoutes = cloneDeep(initialRoutes);
95
95
  markedRoutes = ssrByRouteIds.length > 0 ? markRoutes(clonedRoutes, ssrByRouteIds) : initialRoutes;
96
96
  return [
97
97
  4,
98
- hookRunners.modifyFileSystemRoutes({
98
+ hooks.modifyFileSystemRoutes.call({
99
99
  entrypoint,
100
100
  routes: markedRoutes
101
101
  })
@@ -116,7 +116,7 @@ var generateCode = function() {
116
116
  process.exit(1);
117
117
  }
118
118
  }
119
- _ = hookRunners.beforeGenerateRoutes;
119
+ _1 = (_ = hooks.onBeforeGenerateRoutes).call;
120
120
  _tmp = {
121
121
  entrypoint
122
122
  };
@@ -135,7 +135,7 @@ var generateCode = function() {
135
135
  case 4:
136
136
  return [
137
137
  4,
138
- _.apply(hookRunners, [
138
+ _1.apply(_, [
139
139
  (_tmp.code = _state.sent(), _tmp)
140
140
  ])
141
141
  ];
@@ -221,7 +221,7 @@ var generateCode = function() {
221
221
  switch (_state.label) {
222
222
  case 0:
223
223
  internalDirectory = appContext.internalDirectory, srcDirectory = appContext.srcDirectory, internalDirAlias = appContext.internalDirAlias, internalSrcAlias = appContext.internalSrcAlias, packageName = appContext.packageName;
224
- hookRunners = api.useHookRunners();
224
+ hooks = api.getHooks();
225
225
  isV5 = isRouterV5(config);
226
226
  getRoutes = isV5 ? getClientRoutesLegacy : getClientRoutes;
227
227
  oldVersion = _type_of(config === null || config === void 0 ? void 0 : config.runtime.router) === "object" ? Boolean((config === null || config === void 0 ? void 0 : config.runtime.router).oldVersion) : false;
@@ -13,7 +13,7 @@ function _handleModifyEntrypoints() {
13
13
  _handleModifyEntrypoints = _async_to_generator(function(api, entrypoints) {
14
14
  var config;
15
15
  return _ts_generator(this, function(_state) {
16
- config = api.useResolvedConfigContext();
16
+ config = api.getNormalizedConfig();
17
17
  return [
18
18
  2,
19
19
  modifyEntrypoints(entrypoints, config)
@@ -31,9 +31,9 @@ function _handleGeneratorEntryCode() {
31
31
  return _ts_generator(this, function(_state) {
32
32
  switch (_state.label) {
33
33
  case 0:
34
- appContext = api.useAppContext();
35
- internalDirectory = api.useAppContext().internalDirectory;
36
- resolvedConfig = api.useResolvedConfigContext();
34
+ appContext = api.getAppContext();
35
+ internalDirectory = appContext.internalDirectory;
36
+ resolvedConfig = api.getNormalizedConfig();
37
37
  return [
38
38
  4,
39
39
  import("./code")
@@ -111,7 +111,7 @@ function _handleFileChange() {
111
111
  return _ts_generator(this, function(_state) {
112
112
  switch (_state.label) {
113
113
  case 0:
114
- appContext = api.useAppContext();
114
+ appContext = api.getAppContext();
115
115
  appDirectory = appContext.appDirectory, entrypoints = appContext.entrypoints;
116
116
  filename = e.filename, eventType = e.eventType;
117
117
  nestedRouteEntries = entrypoints.map(function(point) {
@@ -134,7 +134,7 @@ function _handleFileChange() {
134
134
  3,
135
135
  3
136
136
  ];
137
- resolvedConfig = api.useResolvedConfigContext();
137
+ resolvedConfig = api.getNormalizedConfig();
138
138
  return [
139
139
  4,
140
140
  import("./code")
@@ -18,167 +18,171 @@ var routerPlugin = function() {
18
18
  setup: function(api) {
19
19
  var nestedRoutes = {};
20
20
  var nestedRoutesForServer = {};
21
- return {
22
- _internalRuntimePlugins: function _internalRuntimePlugins(param) {
23
- var entrypoint = param.entrypoint, plugins = param.plugins;
24
- var _getEntryOptions;
25
- var _api_useAppContext = api.useAppContext(), packageName = _api_useAppContext.packageName, serverRoutes = _api_useAppContext.serverRoutes, metaName = _api_useAppContext.metaName;
26
- var serverBase = serverRoutes.filter(function(route) {
27
- return route.entryName === entrypoint.entryName;
28
- }).map(function(route) {
29
- return route.urlPath;
30
- }).sort(function(a, b) {
31
- return a.length - b.length > 0 ? -1 : 1;
21
+ api._internalRuntimePlugins(function(param) {
22
+ var entrypoint = param.entrypoint, plugins = param.plugins;
23
+ var _getEntryOptions;
24
+ var _api_getAppContext = api.getAppContext(), packageName = _api_getAppContext.packageName, serverRoutes = _api_getAppContext.serverRoutes, metaName = _api_getAppContext.metaName;
25
+ var serverBase = serverRoutes.filter(function(route) {
26
+ return route.entryName === entrypoint.entryName;
27
+ }).map(function(route) {
28
+ return route.urlPath;
29
+ }).sort(function(a, b) {
30
+ return a.length - b.length > 0 ? -1 : 1;
31
+ });
32
+ var userConfig = api.getNormalizedConfig();
33
+ var routerConfig = (_getEntryOptions = getEntryOptions(entrypoint.entryName, entrypoint.isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.router;
34
+ if (routerConfig && !isV5(userConfig)) {
35
+ plugins.push({
36
+ name: "router",
37
+ path: "@".concat(metaName, "/runtime/router"),
38
+ config: typeof routerConfig === "boolean" ? {
39
+ serverBase
40
+ } : _object_spread_props(_object_spread({}, routerConfig), {
41
+ serverBase
42
+ })
32
43
  });
33
- var userConfig = api.useResolvedConfigContext();
34
- var routerConfig = (_getEntryOptions = getEntryOptions(entrypoint.entryName, entrypoint.isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.router;
35
- if (routerConfig && !isV5(userConfig)) {
36
- plugins.push({
37
- name: "router",
38
- path: "@".concat(metaName, "/runtime/router"),
39
- config: typeof routerConfig === "boolean" ? {
40
- serverBase
41
- } : _object_spread_props(_object_spread({}, routerConfig), {
42
- serverBase
43
- })
44
- });
44
+ }
45
+ return {
46
+ entrypoint,
47
+ plugins
48
+ };
49
+ });
50
+ api.checkEntryPoint(function(param) {
51
+ var path2 = param.path, entry = param.entry;
52
+ return {
53
+ path: path2,
54
+ entry: entry || isRouteEntry(path2)
55
+ };
56
+ });
57
+ api.config(function() {
58
+ return {
59
+ source: {
60
+ include: [
61
+ // react-router v6 is no longer support ie 11
62
+ // so we need to compile these packages to ensure the compatibility
63
+ // https://github.com/remix-run/react-router/commit/f6df0697e1b2064a2b3a12e8b39577326fdd945b
64
+ /node_modules\/react-router/,
65
+ /node_modules\/react-router-dom/,
66
+ /node_modules\/@remix-run\/router/
67
+ ]
45
68
  }
46
- return {
47
- entrypoint,
48
- plugins
49
- };
50
- },
51
- checkEntryPoint: function checkEntryPoint(param) {
52
- var path2 = param.path, entry = param.entry;
53
- return {
54
- path: path2,
55
- entry: entry || isRouteEntry(path2)
56
- };
57
- },
58
- config: function config() {
59
- return {
60
- source: {
61
- include: [
62
- // react-router v6 is no longer support ie 11
63
- // so we need to compile these packages to ensure the compatibility
64
- // https://github.com/remix-run/react-router/commit/f6df0697e1b2064a2b3a12e8b39577326fdd945b
65
- /node_modules\/react-router/,
66
- /node_modules\/react-router-dom/,
67
- /node_modules\/@remix-run\/router/
68
- ]
69
+ };
70
+ });
71
+ api.modifyEntrypoints(function() {
72
+ var _ref = _async_to_generator(function(param) {
73
+ var entrypoints, newEntryPoints;
74
+ return _ts_generator(this, function(_state) {
75
+ switch (_state.label) {
76
+ case 0:
77
+ entrypoints = param.entrypoints;
78
+ return [
79
+ 4,
80
+ handleModifyEntrypoints(api, entrypoints)
81
+ ];
82
+ case 1:
83
+ newEntryPoints = _state.sent();
84
+ return [
85
+ 2,
86
+ {
87
+ entrypoints: newEntryPoints
88
+ }
89
+ ];
69
90
  }
70
- };
71
- },
72
- modifyEntrypoints: function modifyEntrypoints(param) {
73
- var entrypoints = param.entrypoints;
74
- return _async_to_generator(function() {
75
- var newEntryPoints;
76
- return _ts_generator(this, function(_state) {
77
- switch (_state.label) {
78
- case 0:
79
- return [
80
- 4,
81
- handleModifyEntrypoints(api, entrypoints)
82
- ];
83
- case 1:
84
- newEntryPoints = _state.sent();
85
- return [
86
- 2,
87
- {
88
- entrypoints: newEntryPoints
89
- }
90
- ];
91
- }
92
- });
93
- })();
94
- },
95
- generateEntryCode: function generateEntryCode(param) {
96
- var entrypoints = param.entrypoints;
97
- return _async_to_generator(function() {
98
- return _ts_generator(this, function(_state) {
99
- switch (_state.label) {
100
- case 0:
101
- return [
102
- 4,
103
- handleGeneratorEntryCode(api, entrypoints)
104
- ];
105
- case 1:
106
- _state.sent();
107
- return [
108
- 2
109
- ];
110
- }
111
- });
112
- })();
113
- },
114
- addRuntimeExports: function addRuntimeExports() {
115
- var userConfig = api.useResolvedConfigContext();
116
- var _api_useAppContext = api.useAppContext(), internalDirectory = _api_useAppContext.internalDirectory, metaName = _api_useAppContext.metaName;
117
- var pluginsExportsUtils = createRuntimeExportsUtils(internalDirectory, "plugins");
118
- if (!isV5(userConfig)) {
119
- pluginsExportsUtils.addExport("export { default as router } from '@".concat(metaName, "/runtime/router'"));
120
- }
121
- },
122
- fileChange: function fileChange(e) {
123
- return _async_to_generator(function() {
124
- return _ts_generator(this, function(_state) {
125
- switch (_state.label) {
126
- case 0:
127
- return [
128
- 4,
129
- handleFileChange(api, e)
130
- ];
131
- case 1:
132
- _state.sent();
133
- return [
134
- 2
135
- ];
136
- }
137
- });
138
- })();
139
- },
140
- modifyFileSystemRoutes: function modifyFileSystemRoutes(param) {
141
- var entrypoint = param.entrypoint, routes = param.routes;
142
- return _async_to_generator(function() {
143
- return _ts_generator(this, function(_state) {
144
- nestedRoutes[entrypoint.entryName] = routes;
145
- nestedRoutesForServer[entrypoint.entryName] = filterRoutesForServer(routes);
146
- return [
147
- 2,
148
- {
149
- entrypoint,
150
- routes
151
- }
152
- ];
153
- });
154
- })();
155
- },
156
- beforeGenerateRoutes: function beforeGenerateRoutes(param) {
157
- var entrypoint = param.entrypoint, code = param.code;
158
- return _async_to_generator(function() {
159
- var distDirectory;
160
- return _ts_generator(this, function(_state) {
161
- switch (_state.label) {
162
- case 0:
163
- distDirectory = api.useAppContext().distDirectory;
164
- return [
165
- 4,
166
- fs.outputJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutesForServer)
167
- ];
168
- case 1:
169
- _state.sent();
170
- return [
171
- 2,
172
- {
173
- entrypoint,
174
- code
175
- }
176
- ];
177
- }
178
- });
179
- })();
91
+ });
92
+ });
93
+ return function(_) {
94
+ return _ref.apply(this, arguments);
95
+ };
96
+ }());
97
+ api.generateEntryCode(function() {
98
+ var _ref = _async_to_generator(function(param) {
99
+ var entrypoints;
100
+ return _ts_generator(this, function(_state) {
101
+ switch (_state.label) {
102
+ case 0:
103
+ entrypoints = param.entrypoints;
104
+ return [
105
+ 4,
106
+ handleGeneratorEntryCode(api, entrypoints)
107
+ ];
108
+ case 1:
109
+ _state.sent();
110
+ return [
111
+ 2
112
+ ];
113
+ }
114
+ });
115
+ });
116
+ return function(_) {
117
+ return _ref.apply(this, arguments);
118
+ };
119
+ }());
120
+ api.addRuntimeExports(function() {
121
+ var userConfig = api.useResolvedConfigContext();
122
+ var _api_useAppContext = api.useAppContext(), internalDirectory = _api_useAppContext.internalDirectory, metaName = _api_useAppContext.metaName;
123
+ var pluginsExportsUtils = createRuntimeExportsUtils(internalDirectory, "plugins");
124
+ if (!isV5(userConfig)) {
125
+ pluginsExportsUtils.addExport("export { default as router } from '@".concat(metaName, "/runtime/router'"));
180
126
  }
181
- };
127
+ });
128
+ api.onFileChanged(function() {
129
+ var _ref = _async_to_generator(function(e) {
130
+ return _ts_generator(this, function(_state) {
131
+ switch (_state.label) {
132
+ case 0:
133
+ return [
134
+ 4,
135
+ handleFileChange(api, e)
136
+ ];
137
+ case 1:
138
+ _state.sent();
139
+ return [
140
+ 2
141
+ ];
142
+ }
143
+ });
144
+ });
145
+ return function(e) {
146
+ return _ref.apply(this, arguments);
147
+ };
148
+ }());
149
+ api.modifyFileSystemRoutes(function(param) {
150
+ var entrypoint = param.entrypoint, routes = param.routes;
151
+ nestedRoutes[entrypoint.entryName] = routes;
152
+ nestedRoutesForServer[entrypoint.entryName] = filterRoutesForServer(routes);
153
+ return {
154
+ entrypoint,
155
+ routes
156
+ };
157
+ });
158
+ api.onBeforeGenerateRoutes(function() {
159
+ var _ref = _async_to_generator(function(param) {
160
+ var entrypoint, code, distDirectory;
161
+ return _ts_generator(this, function(_state) {
162
+ switch (_state.label) {
163
+ case 0:
164
+ entrypoint = param.entrypoint, code = param.code;
165
+ distDirectory = api.getAppContext().distDirectory;
166
+ return [
167
+ 4,
168
+ fs.outputJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutesForServer)
169
+ ];
170
+ case 1:
171
+ _state.sent();
172
+ return [
173
+ 2,
174
+ {
175
+ entrypoint,
176
+ code
177
+ }
178
+ ];
179
+ }
180
+ });
181
+ });
182
+ return function(_) {
183
+ return _ref.apply(this, arguments);
184
+ };
185
+ }());
182
186
  }
183
187
  };
184
188
  };