@modern-js/app-tools 2.0.0-beta.0 → 2.0.0-beta.2

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 (279) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/dist/js/modern/analyze/generateCode.js +30 -38
  3. package/dist/js/modern/analyze/getBundleEntry.js +5 -13
  4. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
  5. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
  6. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
  7. package/dist/js/modern/analyze/getFileSystemEntry.js +5 -18
  8. package/dist/js/modern/analyze/getHtmlTemplate.js +3 -10
  9. package/dist/js/modern/analyze/getServerRoutes.js +25 -38
  10. package/dist/js/modern/analyze/index.js +90 -48
  11. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
  12. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
  13. package/dist/js/modern/analyze/nestedRoutes.js +8 -33
  14. package/dist/js/modern/analyze/templates.js +22 -37
  15. package/dist/js/modern/analyze/utils.js +0 -7
  16. package/dist/js/modern/builder/builderPlugins/compatModern.js +41 -58
  17. package/dist/js/modern/builder/index.js +56 -37
  18. package/dist/js/modern/builder/share.js +1 -5
  19. package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
  20. package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
  21. package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
  22. package/dist/js/modern/commands/build.js +12 -46
  23. package/dist/js/modern/commands/dev.js +20 -23
  24. package/dist/js/modern/commands/inspect.js +4 -19
  25. package/dist/js/modern/commands/start.js +1 -2
  26. package/dist/js/modern/config/default.js +207 -0
  27. package/dist/js/modern/config/index.js +2 -0
  28. package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
  29. package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +19 -18
  30. package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
  31. package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
  32. package/dist/js/modern/config/initial/index.js +11 -0
  33. package/dist/js/modern/config/initial/inits.js +117 -0
  34. package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
  35. package/dist/js/modern/defineConfig.js +12 -0
  36. package/dist/js/modern/hooks.js +23 -19
  37. package/dist/js/modern/index.js +12 -19
  38. package/dist/js/modern/initialize/index.js +72 -0
  39. package/dist/js/modern/schema/Schema.js +39 -0
  40. package/dist/js/modern/schema/index.js +139 -0
  41. package/dist/js/modern/schema/legacy.js +284 -0
  42. package/dist/js/modern/types/config/deploy.js +0 -0
  43. package/dist/js/modern/types/config/dev.js +0 -0
  44. package/dist/js/modern/types/config/experiments.js +0 -0
  45. package/dist/js/modern/types/config/html.js +0 -0
  46. package/dist/js/modern/types/config/index.js +2 -0
  47. package/dist/js/modern/types/config/output.js +0 -0
  48. package/dist/js/modern/types/config/performance.js +0 -0
  49. package/dist/js/modern/types/config/security.js +0 -0
  50. package/dist/js/modern/types/config/source.js +0 -0
  51. package/dist/js/modern/types/config/tools.js +0 -0
  52. package/dist/js/modern/types/hooks.js +0 -0
  53. package/dist/js/modern/types/index.js +4 -0
  54. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  55. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  56. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  57. package/dist/js/modern/types/legacyConfig/output.js +1 -0
  58. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  59. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  60. package/dist/js/modern/utils/config.js +2 -13
  61. package/dist/js/modern/utils/createFileWatcher.js +82 -0
  62. package/dist/js/modern/utils/createServer.js +0 -5
  63. package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
  64. package/dist/js/modern/utils/printInstructions.js +2 -1
  65. package/dist/js/modern/utils/restart.js +17 -0
  66. package/dist/js/modern/utils/routes.js +0 -2
  67. package/dist/js/node/analyze/generateCode.js +30 -61
  68. package/dist/js/node/analyze/getBundleEntry.js +5 -19
  69. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
  70. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
  71. package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
  72. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
  73. package/dist/js/node/analyze/getFileSystemEntry.js +5 -26
  74. package/dist/js/node/analyze/getHtmlTemplate.js +3 -24
  75. package/dist/js/node/analyze/getServerRoutes.js +24 -46
  76. package/dist/js/node/analyze/index.js +91 -70
  77. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
  78. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
  79. package/dist/js/node/analyze/nestedRoutes.js +8 -41
  80. package/dist/js/node/analyze/templates.js +22 -47
  81. package/dist/js/node/analyze/utils.js +0 -20
  82. package/dist/js/node/builder/builderPlugins/compatModern.js +41 -69
  83. package/dist/js/node/builder/index.js +57 -51
  84. package/dist/js/node/builder/share.js +1 -13
  85. package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
  86. package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
  87. package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
  88. package/dist/js/node/commands/build.js +10 -57
  89. package/dist/js/node/commands/deploy.js +0 -2
  90. package/dist/js/node/commands/dev.js +19 -34
  91. package/dist/js/node/commands/index.js +0 -6
  92. package/dist/js/node/commands/inspect.js +4 -26
  93. package/dist/js/node/commands/start.js +1 -11
  94. package/dist/js/node/config/default.js +214 -0
  95. package/dist/js/node/config/index.js +31 -0
  96. package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
  97. package/dist/js/node/{builder → config/initial}/createOutputConfig.js +19 -20
  98. package/dist/js/node/config/initial/createSourceConfig.js +38 -0
  99. package/dist/js/node/config/initial/createToolsConfig.js +47 -0
  100. package/dist/js/node/config/initial/index.js +24 -0
  101. package/dist/js/node/config/initial/inits.js +127 -0
  102. package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
  103. package/dist/js/node/defineConfig.js +20 -0
  104. package/dist/js/node/exports/server.js +0 -1
  105. package/dist/js/node/hooks.js +23 -30
  106. package/dist/js/node/index.js +35 -48
  107. package/dist/js/node/initialize/index.js +79 -0
  108. package/dist/js/node/locale/index.js +0 -4
  109. package/dist/js/node/schema/Schema.js +46 -0
  110. package/dist/js/node/schema/index.js +152 -0
  111. package/dist/js/node/schema/legacy.js +291 -0
  112. package/dist/js/node/types/config/deploy.js +0 -0
  113. package/dist/js/node/types/config/dev.js +0 -0
  114. package/dist/js/node/types/config/experiments.js +0 -0
  115. package/dist/js/node/types/config/html.js +0 -0
  116. package/dist/js/node/types/config/index.js +16 -0
  117. package/dist/js/node/types/config/output.js +0 -0
  118. package/dist/js/node/types/config/performance.js +0 -0
  119. package/dist/js/node/types/config/security.js +0 -0
  120. package/dist/js/node/types/config/source.js +0 -0
  121. package/dist/js/node/types/config/tools.js +0 -0
  122. package/dist/js/node/types/hooks.js +0 -0
  123. package/dist/js/node/types/index.js +38 -0
  124. package/dist/js/node/types/legacyConfig/deploy.js +0 -0
  125. package/dist/js/node/types/legacyConfig/dev.js +0 -0
  126. package/dist/js/node/types/legacyConfig/index.js +0 -0
  127. package/dist/js/node/types/legacyConfig/output.js +5 -0
  128. package/dist/js/node/types/legacyConfig/source.js +0 -0
  129. package/dist/js/node/types/legacyConfig/tools.js +0 -0
  130. package/dist/js/node/utils/commands.js +0 -2
  131. package/dist/js/node/utils/config.js +2 -26
  132. package/dist/js/node/utils/createFileWatcher.js +90 -0
  133. package/dist/js/node/utils/createServer.js +0 -15
  134. package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
  135. package/dist/js/node/utils/language.js +0 -2
  136. package/dist/js/node/utils/printInstructions.js +2 -5
  137. package/dist/js/node/utils/restart.js +23 -0
  138. package/dist/js/node/utils/routes.js +0 -5
  139. package/dist/js/treeshaking/analyze/generateCode.js +58 -101
  140. package/dist/js/treeshaking/analyze/getBundleEntry.js +12 -20
  141. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
  142. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
  143. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
  144. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +5 -18
  145. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +3 -27
  146. package/dist/js/treeshaking/analyze/getServerRoutes.js +29 -41
  147. package/dist/js/treeshaking/analyze/index.js +195 -91
  148. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
  149. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
  150. package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
  151. package/dist/js/treeshaking/analyze/templates.js +31 -50
  152. package/dist/js/treeshaking/analyze/utils.js +7 -14
  153. package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +50 -68
  154. package/dist/js/treeshaking/builder/index.js +69 -65
  155. package/dist/js/treeshaking/builder/share.js +1 -5
  156. package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
  157. package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
  158. package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
  159. package/dist/js/treeshaking/commands/build.js +41 -116
  160. package/dist/js/treeshaking/commands/deploy.js +0 -3
  161. package/dist/js/treeshaking/commands/dev.js +38 -46
  162. package/dist/js/treeshaking/commands/inspect.js +9 -27
  163. package/dist/js/treeshaking/commands/start.js +1 -9
  164. package/dist/js/treeshaking/config/default.js +200 -0
  165. package/dist/js/treeshaking/config/index.js +2 -0
  166. package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
  167. package/dist/js/treeshaking/config/initial/createOutputConfig.js +67 -0
  168. package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
  169. package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
  170. package/dist/js/treeshaking/config/initial/index.js +11 -0
  171. package/dist/js/treeshaking/config/initial/inits.js +114 -0
  172. package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
  173. package/dist/js/treeshaking/defineConfig.js +14 -0
  174. package/dist/js/treeshaking/hooks.js +23 -19
  175. package/dist/js/treeshaking/index.js +8 -43
  176. package/dist/js/treeshaking/initialize/index.js +121 -0
  177. package/dist/js/treeshaking/schema/Schema.js +75 -0
  178. package/dist/js/treeshaking/schema/index.js +138 -0
  179. package/dist/js/treeshaking/schema/legacy.js +273 -0
  180. package/dist/js/treeshaking/types/config/deploy.js +0 -0
  181. package/dist/js/treeshaking/types/config/dev.js +0 -0
  182. package/dist/js/treeshaking/types/config/experiments.js +0 -0
  183. package/dist/js/treeshaking/types/config/html.js +0 -0
  184. package/dist/js/treeshaking/types/config/index.js +2 -0
  185. package/dist/js/treeshaking/types/config/output.js +0 -0
  186. package/dist/js/treeshaking/types/config/performance.js +0 -0
  187. package/dist/js/treeshaking/types/config/security.js +0 -0
  188. package/dist/js/treeshaking/types/config/source.js +0 -0
  189. package/dist/js/treeshaking/types/config/tools.js +0 -0
  190. package/dist/js/treeshaking/types/hooks.js +0 -0
  191. package/dist/js/treeshaking/types/index.js +4 -0
  192. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
  193. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
  194. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
  195. package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
  196. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
  197. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
  198. package/dist/js/treeshaking/utils/config.js +2 -18
  199. package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
  200. package/dist/js/treeshaking/utils/createServer.js +0 -10
  201. package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
  202. package/dist/js/treeshaking/utils/printInstructions.js +0 -5
  203. package/dist/js/treeshaking/utils/restart.js +45 -0
  204. package/dist/js/treeshaking/utils/routes.js +0 -4
  205. package/dist/types/analyze/generateCode.d.ts +3 -2
  206. package/dist/types/analyze/getBundleEntry.d.ts +2 -2
  207. package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
  208. package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
  209. package/dist/types/analyze/getServerRoutes.d.ts +3 -2
  210. package/dist/types/analyze/index.d.ts +3 -42
  211. package/dist/types/analyze/nestedRoutes.d.ts +1 -1
  212. package/dist/types/analyze/templates.d.ts +4 -2
  213. package/dist/types/analyze/utils.d.ts +1 -1
  214. package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -3
  215. package/dist/types/builder/index.d.ts +7 -8
  216. package/dist/types/builder/share.d.ts +2 -2
  217. package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
  218. package/dist/types/commands/build.d.ts +2 -2
  219. package/dist/types/commands/deploy.d.ts +2 -2
  220. package/dist/types/commands/dev.d.ts +2 -2
  221. package/dist/types/commands/inspect.d.ts +6 -1
  222. package/dist/types/commands/start.d.ts +2 -2
  223. package/dist/types/config/default.d.ts +3 -0
  224. package/dist/types/config/index.d.ts +2 -0
  225. package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
  226. package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
  227. package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
  228. package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
  229. package/dist/types/config/initial/index.d.ts +4 -0
  230. package/dist/types/config/initial/inits.d.ts +4 -0
  231. package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
  232. package/dist/types/defineConfig.d.ts +7 -0
  233. package/dist/types/hooks.d.ts +2 -42
  234. package/dist/types/index.d.ts +5 -7
  235. package/dist/types/initialize/index.d.ts +3 -0
  236. package/dist/types/schema/Schema.d.ts +14 -0
  237. package/dist/types/schema/index.d.ts +4 -0
  238. package/dist/types/schema/legacy.d.ts +3 -0
  239. package/dist/types/types/config/deploy.d.ts +9 -0
  240. package/dist/types/types/config/dev.d.ts +13 -0
  241. package/dist/types/types/config/experiments.d.ts +4 -0
  242. package/dist/types/types/config/html.d.ts +4 -0
  243. package/dist/types/types/config/index.d.ts +62 -0
  244. package/dist/types/types/config/output.d.ts +23 -0
  245. package/dist/types/types/config/performance.d.ts +4 -0
  246. package/dist/types/types/config/security.d.ts +4 -0
  247. package/dist/types/types/config/source.d.ts +22 -0
  248. package/dist/types/types/config/tools.d.ts +15 -0
  249. package/dist/types/types/hooks.d.ts +80 -0
  250. package/dist/types/types/index.d.ts +23 -0
  251. package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
  252. package/dist/types/types/legacyConfig/dev.d.ts +12 -0
  253. package/dist/types/types/legacyConfig/index.d.ts +33 -0
  254. package/dist/types/types/legacyConfig/output.d.ts +51 -0
  255. package/dist/types/types/legacyConfig/source.d.ts +25 -0
  256. package/dist/types/types/legacyConfig/tools.d.ts +16 -0
  257. package/dist/types/utils/config.d.ts +2 -3
  258. package/dist/types/utils/createFileWatcher.d.ts +3 -0
  259. package/dist/types/utils/printInstructions.d.ts +3 -3
  260. package/dist/types/utils/restart.d.ts +3 -0
  261. package/package.json +26 -25
  262. package/dist/js/modern/builder/createHtmlConfig.js +0 -58
  263. package/dist/js/modern/builder/createSourceConfig.js +0 -85
  264. package/dist/js/modern/builder/createToolsConfig.js +0 -94
  265. package/dist/js/modern/utils/createCompiler.js +0 -58
  266. package/dist/js/node/builder/createHtmlConfig.js +0 -76
  267. package/dist/js/node/builder/createSourceConfig.js +0 -99
  268. package/dist/js/node/builder/createToolsConfig.js +0 -103
  269. package/dist/js/node/utils/createCompiler.js +0 -75
  270. package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
  271. package/dist/js/treeshaking/builder/createOutputConfig.js +0 -67
  272. package/dist/js/treeshaking/builder/createSourceConfig.js +0 -100
  273. package/dist/js/treeshaking/builder/createToolsConfig.js +0 -90
  274. package/dist/js/treeshaking/utils/createCompiler.js +0 -117
  275. package/dist/types/builder/createHtmlConfig.d.ts +0 -6
  276. package/dist/types/builder/createOutputConfig.d.ts +0 -3
  277. package/dist/types/builder/createSourceConfig.d.ts +0 -5
  278. package/dist/types/builder/createToolsConfig.d.ts +0 -13
  279. package/dist/types/utils/createCompiler.d.ts +0 -12
@@ -4,41 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getClientRoutes = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _utils = require("@modern-js/utils");
11
-
12
9
  var _makeLegalIdentifier = require("../makeLegalIdentifier");
13
-
14
10
  var _constants = require("../constants");
15
-
16
11
  var _utils2 = require("../utils");
17
-
18
12
  var _utils3 = require("./utils");
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
-
24
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
-
26
16
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
28
17
  const compName = (srcDirectory, filePath) => {
29
18
  const legalCompName = (0, _makeLegalIdentifier.makeLegalIdentifier)(_path.default.relative(srcDirectory, filePath));
30
19
  return `Comp_${legalCompName}`;
31
20
  };
32
-
33
21
  const layoutNameAbbr = filePath => {
34
22
  const prefix = 'L_';
35
23
  const dirName = _path.default.dirname(filePath).split('/').pop() || '';
36
24
  return `${prefix}${(0, _makeLegalIdentifier.makeLegalIdentifier)(dirName)}`;
37
25
  };
38
-
39
26
  const parents = [];
40
- /* eslint-disable no-param-reassign */
41
27
 
28
+ /* eslint-disable no-param-reassign */
42
29
  const recursiveReadDirLegacy = ({
43
30
  dir,
44
31
  routes,
@@ -50,7 +37,6 @@ const recursiveReadDirLegacy = ({
50
37
  let resetParent = false;
51
38
  let parent = parents[parents.length - 1];
52
39
  const layout = (0, _utils3.findLayout)(dir);
53
-
54
40
  if (layout) {
55
41
  if (_basePath === '/') {
56
42
  throw new Error(`should use _app instead of _layout in ${dir}`);
@@ -72,18 +58,13 @@ const recursiveReadDirLegacy = ({
72
58
  routes = route.routes;
73
59
  }
74
60
  }
75
-
76
61
  for (const relative of _utils.fs.readdirSync(dir)) {
77
62
  const filePath = _path.default.join(dir, relative);
78
-
79
63
  if (!(0, _utils3.shouldSkip)(filePath)) {
80
64
  const filename = _path.default.basename(filePath, _path.default.extname(filePath));
81
-
82
65
  const alias = (0, _utils2.replaceWithAlias)(srcDirectory, filePath, srcAlias);
83
66
  const componentName = compName(srcDirectory, filePath);
84
-
85
67
  const dynamicRouteMatched = _constants.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP.exec(filename);
86
-
87
68
  if (dynamicRouteMatched) {
88
69
  if (hasDynamicRoute) {
89
70
  throw new Error(`Can't set two dynamic route in one directory: ${dir}`);
@@ -91,7 +72,6 @@ const recursiveReadDirLegacy = ({
91
72
  hasDynamicRoute = true;
92
73
  }
93
74
  }
94
-
95
75
  const route = {
96
76
  path: `${_basePath}${dynamicRouteMatched ? `:${dynamicRouteMatched[1]}${dynamicRouteMatched[2]}` : filename}`,
97
77
  _component: alias,
@@ -99,7 +79,6 @@ const recursiveReadDirLegacy = ({
99
79
  exact: true,
100
80
  parent
101
81
  };
102
-
103
82
  if (_utils.fs.statSync(filePath).isDirectory()) {
104
83
  recursiveReadDirLegacy({
105
84
  dir: filePath,
@@ -110,39 +89,33 @@ const recursiveReadDirLegacy = ({
110
89
  });
111
90
  continue;
112
91
  }
113
-
114
92
  if (filename === _constants.FILE_SYSTEM_ROUTES_LAYOUT) {
115
93
  continue;
116
94
  }
117
-
118
95
  if (filename === _constants.FILE_SYSTEM_ROUTES_INDEX) {
119
96
  route.path = _basePath === '/' ? _basePath : `${_basePath.substring(0, _basePath.length - 1)}`;
120
97
  }
121
-
122
98
  if (filename === '404' && _basePath === '/') {
123
99
  route.path = '*';
124
100
  route.exact = false;
125
101
  }
126
-
127
102
  routes.push(route);
128
103
  }
129
104
  }
130
-
131
105
  if (resetParent) {
132
106
  parents.pop();
133
107
  }
134
108
  };
135
109
  /* eslint-enable no-param-reassign */
136
110
 
137
-
138
111
  const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory, internalDirAlias) => {
139
112
  const flat = routes => routes.reduce((memo, route) => memo.concat(Array.isArray(route.routes) ? flat(route.routes) : [route]), []);
140
-
141
113
  const generate = route => {
142
114
  const codes = [];
143
115
  let lastComponent = route.component;
144
- const imports = [`import React from 'react';`, `import ${lastComponent} from '${route._component}'`]; // eslint-disable-next-line no-param-reassign, no-cond-assign
116
+ const imports = [`import React from 'react';`, `import ${lastComponent} from '${route._component}'`];
145
117
 
118
+ // eslint-disable-next-line no-param-reassign, no-cond-assign
146
119
  while (route = route.parent) {
147
120
  const layoutComponent = route.component;
148
121
  const layoutComponentAbbr = layoutNameAbbr(route._component);
@@ -151,17 +124,13 @@ const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory,
151
124
  codes.push(`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`);
152
125
  lastComponent = currentComponent;
153
126
  }
154
-
155
127
  const file = _path.default.resolve(internalComponentsDir, `${lastComponent}.jsx`);
156
-
157
128
  _utils.fs.outputFileSync(file, `${imports.join('\n')}\n${codes.join('\n')}\nexport default ${lastComponent}`);
158
-
159
129
  return {
160
130
  component: lastComponent,
161
131
  _component: (0, _utils2.replaceWithAlias)(internalDirectory, file, internalDirAlias)
162
132
  };
163
133
  };
164
-
165
134
  const normalized = flat(nested).map(route => route.parent ? _objectSpread(_objectSpread(_objectSpread({}, route), generate(route)), {}, {
166
135
  parent: undefined
167
136
  }) : _objectSpread(_objectSpread({}, route), {}, {
@@ -169,7 +138,6 @@ const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory,
169
138
  }));
170
139
  return normalized;
171
140
  };
172
-
173
141
  const getClientRoutes = ({
174
142
  entrypoint,
175
143
  srcDirectory,
@@ -181,15 +149,12 @@ const getClientRoutes = ({
181
149
  entry,
182
150
  entryName
183
151
  } = entrypoint;
184
-
185
152
  if (!_utils.fs.existsSync(entry)) {
186
153
  throw new Error(`generate file system routes error, ${entry} directory not found.`);
187
154
  }
188
-
189
155
  if (!(_utils.fs.existsSync(entry) && _utils.fs.statSync(entry).isDirectory())) {
190
156
  throw new Error(`generate file system routes error, ${entry} should be directory.`);
191
157
  }
192
-
193
158
  let routes = [];
194
159
  recursiveReadDirLegacy({
195
160
  dir: entry,
@@ -198,25 +163,20 @@ const getClientRoutes = ({
198
163
  srcDirectory,
199
164
  srcAlias
200
165
  });
201
-
202
166
  const internalComponentsDir = _path.default.resolve(internalDirectory, `${entryName}/${_constants.FILE_SYSTEM_ROUTES_COMPONENTS_DIR}`);
203
-
204
167
  _utils.fs.emptyDirSync(internalComponentsDir);
205
-
206
168
  routes = normalizeNestedRoutes(routes, internalComponentsDir, internalDirectory, internalDirAlias);
207
- parents.length = 0; // FIXME: support more situations
169
+ parents.length = 0;
208
170
 
171
+ // FIXME: support more situations
209
172
  routes.sort((a, b) => {
210
173
  const delta = (0, _utils3.getRouteWeight)(a.path) - (0, _utils3.getRouteWeight)(b.path);
211
-
212
174
  if (delta === 0) {
213
175
  return a.path.length - b.path.length;
214
176
  }
215
-
216
177
  return delta;
217
178
  });
218
179
  (0, _utils3.debug)(`fileSystem routes: %o`, routes);
219
180
  return routes;
220
181
  };
221
-
222
182
  exports.getClientRoutes = getClientRoutes;
@@ -15,7 +15,5 @@ Object.defineProperty(exports, "getClientRoutesLegacy", {
15
15
  return _getRoutesLegacy.getClientRoutes;
16
16
  }
17
17
  });
18
-
19
18
  var _getRoutes = require("./getRoutes");
20
-
21
19
  var _getRoutesLegacy = require("./getRoutesLegacy");
@@ -4,39 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.shouldSkip = exports.getRouteWeight = exports.findLayout = exports.debug = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _utils = require("@modern-js/utils");
11
-
12
9
  var _constants = require("../constants");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  const debug = (0, _utils.createDebugger)('get-client-routes');
17
12
  exports.debug = debug;
18
-
19
13
  const findLayout = dir => (0, _utils.findExists)(_constants.JS_EXTENSIONS.map(ext => _path.default.resolve(dir, `${_constants.FILE_SYSTEM_ROUTES_LAYOUT}${ext}`)));
20
-
21
14
  exports.findLayout = findLayout;
22
-
23
15
  const getRouteWeight = route => route === '*' ? 999 : route.split(':').length - 1;
24
-
25
16
  exports.getRouteWeight = getRouteWeight;
26
-
27
17
  const shouldSkip = file => {
28
18
  // should not skip directory.
29
19
  if (_utils.fs.statSync(file).isDirectory()) {
30
20
  return false;
31
21
  }
32
-
33
22
  const ext = _path.default.extname(file);
34
-
35
23
  if (_constants.FILE_SYSTEM_ROUTES_IGNORED_REGEX.test(file) || !_constants.JS_EXTENSIONS.includes(ext) || _constants.FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT === _path.default.basename(file, ext)) {
36
24
  return true;
37
25
  }
38
-
39
26
  return false;
40
27
  };
41
-
42
28
  exports.shouldSkip = shouldSkip;
@@ -4,57 +4,41 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getFileSystemEntry = void 0;
7
-
8
7
  var _fs = _interopRequireDefault(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  var _utils = require("@modern-js/utils");
13
-
14
10
  var _isDefaultExportFunction = require("./isDefaultExportFunction");
15
-
16
11
  var _constants = require("./constants");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  const hasIndex = dir => (0, _utils.findExists)(_constants.JS_EXTENSIONS.map(ext => _path.default.resolve(dir, `${_constants.INDEX_FILE_NAME}${ext}`)));
21
-
22
14
  const hasApp = dir => (0, _utils.findExists)(_constants.JS_EXTENSIONS.map(ext => _path.default.resolve(dir, `${_constants.APP_FILE_NAME}${ext}`)));
23
-
24
15
  const hasPages = dir => _fs.default.existsSync(_path.default.join(dir, _constants.PAGES_DIR_NAME));
25
-
26
16
  const hasNestedRoutes = dir => _fs.default.existsSync(_path.default.join(dir, _constants.NESTED_ROUTES_DIR));
27
-
28
17
  const isBundleEntry = dir => hasApp(dir) || hasPages(dir) || hasIndex(dir) || hasNestedRoutes(dir);
29
-
30
18
  const scanDir = dirs => dirs.map(dir => {
31
19
  const indexFile = hasIndex(dir);
32
20
  const customBootstrap = (0, _isDefaultExportFunction.isDefaultExportFunction)(indexFile) ? indexFile : false;
33
-
34
21
  const entryName = _path.default.basename(dir);
35
-
36
22
  if (indexFile && !customBootstrap) {
37
23
  return {
38
24
  entryName,
39
25
  entry: indexFile,
26
+ absoluteEntryDir: _path.default.resolve(dir),
40
27
  isAutoMount: false
41
28
  };
42
29
  }
43
-
44
30
  const isHasApp = hasApp(dir);
45
-
46
31
  if (isHasApp) {
47
32
  return {
48
33
  entryName,
49
34
  entry: _path.default.join(dir, _constants.APP_FILE_NAME),
50
35
  isAutoMount: true,
36
+ absoluteEntryDir: _path.default.resolve(dir),
51
37
  customBootstrap
52
38
  };
53
39
  }
54
-
55
40
  const isHasNestedRoutes = hasNestedRoutes(dir);
56
41
  const isHasPages = hasPages(dir);
57
-
58
42
  if (isHasNestedRoutes || isHasPages) {
59
43
  const entrypoint = {
60
44
  entryName,
@@ -63,27 +47,24 @@ const scanDir = dirs => dirs.map(dir => {
63
47
  globalApp: (0, _utils.findExists)(_constants.JS_EXTENSIONS.map(ext => _path.default.resolve(dir, `./${_constants.PAGES_DIR_NAME}/${_constants.FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT}${ext}`)))
64
48
  },
65
49
  isAutoMount: true,
50
+ absoluteEntryDir: _path.default.resolve(dir),
66
51
  customBootstrap
67
52
  };
68
-
69
53
  if (isHasPages) {
70
54
  entrypoint.entry = _path.default.join(dir, _constants.PAGES_DIR_NAME);
71
55
  }
72
-
73
56
  if (isHasNestedRoutes) {
74
57
  entrypoint.nestedRoutesEntry = _path.default.join(dir, _constants.NESTED_ROUTES_DIR);
75
58
  }
76
-
77
59
  return entrypoint;
78
60
  }
79
-
80
61
  return {
81
62
  entryName,
82
63
  entry: indexFile,
64
+ absoluteEntryDir: _path.default.resolve(dir),
83
65
  isAutoMount: false
84
66
  };
85
67
  });
86
-
87
68
  const getFileSystemEntry = (appContext, config) => {
88
69
  const {
89
70
  appDirectory
@@ -93,8 +74,7 @@ const getFileSystemEntry = (appContext, config) => {
93
74
  entriesDir
94
75
  }
95
76
  } = config;
96
- const src = (0, _utils.ensureAbsolutePath)(appDirectory, entriesDir);
97
-
77
+ const src = (0, _utils.ensureAbsolutePath)(appDirectory, entriesDir || '');
98
78
  if (_fs.default.existsSync(src)) {
99
79
  if (_fs.default.statSync(src).isDirectory()) {
100
80
  return scanDir(isBundleEntry(src) ? [src] : _fs.default.readdirSync(src).map(file => _path.default.join(src, file)).filter(file => _fs.default.statSync(file).isDirectory() && isBundleEntry(file)));
@@ -105,5 +85,4 @@ const getFileSystemEntry = (appContext, config) => {
105
85
  throw Error(`src dir ${entriesDir} not found.`);
106
86
  }
107
87
  };
108
-
109
88
  exports.getFileSystemEntry = getFileSystemEntry;
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getHtmlTemplate = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _utils = require("@modern-js/utils");
11
-
12
9
  var _constants = require("./constants");
13
-
14
10
  var templates = _interopRequireWildcard(require("./templates"));
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  var PartialPosition;
23
-
24
15
  (function (PartialPosition) {
25
16
  PartialPosition["TOP"] = "top";
26
17
  PartialPosition["HEAD"] = "head";
@@ -28,7 +19,6 @@ var PartialPosition;
28
19
  PartialPosition["BOTTOM"] = "bottom";
29
20
  PartialPosition["INDEX"] = "index";
30
21
  })(PartialPosition || (PartialPosition = {}));
31
-
32
22
  const findPartials = (dir, entryName, position) => {
33
23
  if (_utils.fs.existsSync(dir)) {
34
24
  const base = (0, _utils.findExists)(_constants.HTML_PARTIALS_EXTENSIONS.map(ext => _path.default.resolve(dir, `${position}${ext}`)));
@@ -38,11 +28,10 @@ const findPartials = (dir, entryName, position) => {
38
28
  content: _utils.fs.readFileSync(file, 'utf8')
39
29
  } : null;
40
30
  }
41
-
42
31
  return null;
43
- }; // generate html template for
44
-
32
+ };
45
33
 
34
+ // generate html template for
46
35
  const getHtmlTemplate = async (entrypoints, api, {
47
36
  appContext,
48
37
  config
@@ -56,18 +45,14 @@ const getHtmlTemplate = async (entrypoints, api, {
56
45
  configDir
57
46
  }
58
47
  } = config;
59
-
60
- const htmlDir = _path.default.resolve(appDirectory, configDir, _constants.HTML_PARTIALS_FOLDER);
61
-
48
+ const htmlDir = _path.default.resolve(appDirectory, configDir || '', _constants.HTML_PARTIALS_FOLDER);
62
49
  const htmlTemplates = {};
63
-
64
50
  for (const entrypoint of entrypoints) {
65
51
  const {
66
52
  entryName
67
53
  } = entrypoint;
68
54
  const name = entrypoints.length === 1 && entryName === _utils.MAIN_ENTRY_NAME ? '' : entryName;
69
55
  const customIndexTemplate = findPartials(htmlDir, name, PartialPosition.INDEX);
70
-
71
56
  if (customIndexTemplate) {
72
57
  htmlTemplates[entryName] = customIndexTemplate.file;
73
58
  } else {
@@ -86,21 +71,15 @@ const getHtmlTemplate = async (entrypoints, api, {
86
71
  body: []
87
72
  })
88
73
  });
89
-
90
74
  const templatePath = _path.default.resolve(internalDirectory, entryName, 'index.html');
91
-
92
75
  _utils.fs.outputFileSync(templatePath, templates.html(partials), 'utf8');
93
-
94
76
  htmlTemplates[entryName] = templatePath;
95
77
  const bottomTemplate = findPartials(htmlDir, name, PartialPosition.BOTTOM);
96
-
97
78
  if (bottomTemplate) {
98
79
  htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
99
80
  }
100
81
  }
101
82
  }
102
-
103
83
  return htmlTemplates;
104
84
  };
105
-
106
85
  exports.getHtmlTemplate = getHtmlTemplate;
@@ -4,30 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getServerRoutes = void 0;
7
-
8
7
  var _path = _interopRequireDefault(require("path"));
9
-
10
8
  var _fs = _interopRequireDefault(require("fs"));
11
-
12
9
  var _utils = require("@modern-js/utils");
13
-
14
10
  var _utils2 = require("./utils");
15
-
16
11
  const _excluded = ["path"],
17
- _excluded2 = ["path"];
18
-
12
+ _excluded2 = ["path"];
19
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
-
23
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
24
-
25
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
-
27
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
-
29
18
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
-
31
19
  /**
32
20
  * Add base url for each server route.
33
21
  * @param baseUrl - Base url from server.baseUrl
@@ -47,37 +35,34 @@ const applyBaseUrl = (baseUrl, routes) => {
47
35
  });
48
36
  }
49
37
  }
50
-
51
38
  return routes;
52
39
  };
40
+
53
41
  /**
54
42
  *
55
43
  * @param original - Original entrypoint route info.
56
44
  * @param routeOptions - Custom entrypoint route config from server.routes.
57
45
  * @returns
58
46
  */
59
-
60
-
61
47
  const applyRouteOptions = (original, routeOptions) => {
62
48
  const {
63
49
  route,
64
50
  disableSpa
65
51
  } = routeOptions;
66
- original.isSPA = !disableSpa; // set entryPath as dir
52
+ original.isSPA = !disableSpa;
67
53
 
54
+ // set entryPath as dir
68
55
  !original.isSPA && (original.entryPath = _path.default.dirname(original.entryPath));
69
56
  let routes;
70
-
71
57
  if (route) {
72
58
  if (Array.isArray(route)) {
73
59
  routes = route.map(url => {
74
60
  if ((0, _utils.isPlainObject)(url)) {
75
61
  const _ref = url,
76
- {
77
- path: urlPath
78
- } = _ref,
79
- other = _objectWithoutProperties(_ref, _excluded);
80
-
62
+ {
63
+ path: urlPath
64
+ } = _ref,
65
+ other = _objectWithoutProperties(_ref, _excluded);
81
66
  return _objectSpread(_objectSpread(_objectSpread({}, original), other), {}, {
82
67
  urlPath
83
68
  });
@@ -89,11 +74,10 @@ const applyRouteOptions = (original, routeOptions) => {
89
74
  });
90
75
  } else if ((0, _utils.isPlainObject)(route)) {
91
76
  const _ref2 = route,
92
- {
93
- path: urlPath
94
- } = _ref2,
95
- other = _objectWithoutProperties(_ref2, _excluded2);
96
-
77
+ {
78
+ path: urlPath
79
+ } = _ref2,
80
+ other = _objectWithoutProperties(_ref2, _excluded2);
97
81
  routes = [_objectSpread(_objectSpread(_objectSpread({}, original), other), {}, {
98
82
  urlPath
99
83
  })];
@@ -105,23 +89,24 @@ const applyRouteOptions = (original, routeOptions) => {
105
89
  } else {
106
90
  routes = [original];
107
91
  }
108
-
109
92
  return routes;
110
93
  };
94
+
111
95
  /**
112
96
  * Collect routes from entrypoints.
113
97
  * @param entrypoints - Bundle entrypoints.
114
98
  * @param config - Normalized user config.
115
99
  * @returns entrypoint Routes
116
100
  */
117
-
118
-
119
101
  const collectHtmlRoutes = (entrypoints, appContext, config) => {
120
102
  const {
103
+ html: {
104
+ disableHtmlFolder
105
+ },
121
106
  output: {
122
- htmlPath,
123
- disableHtmlFolder,
124
- enableModernMode
107
+ distPath: {
108
+ html: htmlPath
109
+ } = {}
125
110
  },
126
111
  server: {
127
112
  baseUrl,
@@ -148,30 +133,28 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
148
133
  isSPA: true,
149
134
  isSSR,
150
135
  responseHeaders: resHeaders,
151
- enableModernMode: Boolean(enableModernMode),
136
+ // FIXME: remove the config.enableModernMode
137
+ // enableModernMode: Boolean(enableModernMode),
152
138
  bundle: isSSR ? `${_utils.SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : undefined
153
139
  };
154
-
155
140
  if (routes !== null && routes !== void 0 && routes.hasOwnProperty(entryName)) {
156
141
  const routeOptions = (0, _utils.isPlainObject)(routes[entryName]) ? routes[entryName] : {
157
142
  route: routes[entryName]
158
143
  };
159
144
  route = applyRouteOptions(route, routeOptions);
160
145
  }
161
-
162
146
  return Array.isArray(route) ? [...previous, ...route] : [...previous, route];
163
147
  }, []);
164
148
  htmlRoutes = applyBaseUrl(baseUrl, htmlRoutes);
165
149
  return htmlRoutes;
166
150
  };
151
+
167
152
  /**
168
153
  * Collect static public file routes from config/public folder.
169
154
  * @param appContext - App context info.
170
155
  * @param config - normalized user config.
171
156
  * @returns Static public file routes.
172
157
  */
173
-
174
-
175
158
  const collectStaticRoutes = (appContext, config) => {
176
159
  const {
177
160
  appDirectory
@@ -184,25 +167,20 @@ const collectStaticRoutes = (appContext, config) => {
184
167
  publicRoutes = {}
185
168
  }
186
169
  } = config;
187
-
188
- const publicFolder = _path.default.resolve(appDirectory, configDir, 'public');
189
-
170
+ const publicFolder = _path.default.resolve(appDirectory, configDir || '', 'public');
190
171
  return _fs.default.existsSync(publicFolder) ? (0, _utils2.walkDirectory)(publicFolder).map(filePath => {
191
172
  const urlPath = `${(0, _utils.urlJoin)(toPosix(filePath).slice(toPosix(publicFolder).length))}`;
192
173
  return {
193
174
  urlPath: publicRoutes[(0, _utils.removeLeadingSlash)(urlPath)] || urlPath,
194
175
  isSPA: true,
195
176
  isSSR: false,
196
- entryPath: toPosix(_path.default.relative(_path.default.resolve(appDirectory, configDir), filePath))
177
+ entryPath: toPosix(_path.default.relative(_path.default.resolve(appDirectory, configDir || ''), filePath))
197
178
  };
198
179
  }) : [];
199
180
  };
200
-
201
181
  const getServerRoutes = (entrypoints, {
202
182
  appContext,
203
183
  config
204
184
  }) => [...collectHtmlRoutes(entrypoints, appContext, config), ...collectStaticRoutes(appContext, config)];
205
-
206
185
  exports.getServerRoutes = getServerRoutes;
207
-
208
186
  const toPosix = pathStr => pathStr.split(_path.default.sep).join(_path.default.posix.sep);