@modern-js/app-tools 2.15.0 → 2.16.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 (268) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/cjs/analyze/constants.js +37 -61
  3. package/dist/cjs/analyze/generateCode.js +102 -127
  4. package/dist/cjs/analyze/getBundleEntry.js +33 -66
  5. package/dist/cjs/analyze/getClientRoutes/getRoutes.js +61 -117
  6. package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +61 -115
  7. package/dist/cjs/analyze/getClientRoutes/index.js +15 -28
  8. package/dist/cjs/analyze/getClientRoutes/utils.js +24 -48
  9. package/dist/cjs/analyze/getFileSystemEntry.js +39 -79
  10. package/dist/cjs/analyze/getHtmlTemplate.js +88 -98
  11. package/dist/cjs/analyze/getServerRoutes.js +67 -110
  12. package/dist/cjs/analyze/index.js +265 -257
  13. package/dist/cjs/analyze/isDefaultExportFunction.js +66 -44
  14. package/dist/cjs/analyze/makeLegalIdentifier.js +7 -25
  15. package/dist/cjs/analyze/nestedRoutes.js +99 -104
  16. package/dist/cjs/analyze/templates.js +49 -110
  17. package/dist/cjs/analyze/utils.js +98 -102
  18. package/dist/cjs/builder/builder-rspack/adapterCopy.js +58 -100
  19. package/dist/cjs/builder/builder-rspack/index.js +14 -30
  20. package/dist/cjs/builder/builder-webpack/adapterModern.js +33 -50
  21. package/dist/cjs/builder/builder-webpack/createCopyPattern.js +16 -32
  22. package/dist/cjs/builder/builder-webpack/index.js +65 -46
  23. package/dist/cjs/builder/generator/createBuilderOptions.js +10 -26
  24. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +11 -27
  25. package/dist/cjs/builder/generator/getBuilderTargets.js +13 -29
  26. package/dist/cjs/builder/generator/index.js +61 -55
  27. package/dist/cjs/builder/index.js +53 -43
  28. package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +13 -36
  29. package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +90 -90
  30. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +108 -111
  31. package/dist/cjs/builder/shared/builderPlugins/index.js +20 -19
  32. package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -30
  33. package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +32 -38
  34. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +86 -116
  35. package/dist/cjs/builder/shared/bundlerPlugins/index.js +20 -19
  36. package/dist/cjs/builder/shared/createCopyInfo.js +16 -42
  37. package/dist/cjs/builder/shared/index.js +20 -19
  38. package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +8 -24
  39. package/dist/cjs/builder/shared/types.js +4 -15
  40. package/dist/cjs/commands/build.js +23 -40
  41. package/dist/cjs/commands/deploy.js +7 -25
  42. package/dist/cjs/commands/dev.js +38 -57
  43. package/dist/cjs/commands/index.js +20 -19
  44. package/dist/cjs/commands/inspect.js +10 -30
  45. package/dist/cjs/commands/serve.js +28 -66
  46. package/dist/cjs/config/default.js +34 -34
  47. package/dist/cjs/config/index.js +20 -19
  48. package/dist/cjs/config/initialize/index.js +11 -29
  49. package/dist/cjs/config/initialize/inits.js +103 -82
  50. package/dist/cjs/config/legacy/createHtmlConfig.js +8 -40
  51. package/dist/cjs/config/legacy/createOutputConfig.js +8 -51
  52. package/dist/cjs/config/legacy/createSourceConfig.js +8 -38
  53. package/dist/cjs/config/legacy/createToolsConfig.js +8 -43
  54. package/dist/cjs/config/legacy/index.js +22 -46
  55. package/dist/cjs/defineConfig.js +16 -31
  56. package/dist/cjs/exports/server.js +7 -25
  57. package/dist/cjs/hooks.js +33 -51
  58. package/dist/cjs/index.js +185 -166
  59. package/dist/cjs/initialize/index.js +84 -100
  60. package/dist/cjs/locale/en.js +13 -27
  61. package/dist/cjs/locale/index.js +18 -28
  62. package/dist/cjs/locale/zh.js +13 -27
  63. package/dist/cjs/schema/Schema.js +27 -31
  64. package/dist/cjs/schema/index.js +141 -71
  65. package/dist/cjs/schema/legacy.js +273 -96
  66. package/dist/cjs/types/config/deploy.js +4 -15
  67. package/dist/cjs/types/config/dev.js +4 -15
  68. package/dist/cjs/types/config/experiments.js +4 -15
  69. package/dist/cjs/types/config/html.js +4 -15
  70. package/dist/cjs/types/config/index.js +18 -17
  71. package/dist/cjs/types/config/output.js +4 -15
  72. package/dist/cjs/types/config/performance.js +4 -15
  73. package/dist/cjs/types/config/security.js +4 -15
  74. package/dist/cjs/types/config/source.js +4 -15
  75. package/dist/cjs/types/config/tools.js +4 -15
  76. package/dist/cjs/types/hooks.js +4 -15
  77. package/dist/cjs/types/index.js +20 -19
  78. package/dist/cjs/types/legacyConfig/deploy.js +4 -15
  79. package/dist/cjs/types/legacyConfig/dev.js +4 -15
  80. package/dist/cjs/types/legacyConfig/index.js +4 -15
  81. package/dist/cjs/types/legacyConfig/output.js +4 -15
  82. package/dist/cjs/types/legacyConfig/source.js +4 -15
  83. package/dist/cjs/types/legacyConfig/tools.js +4 -15
  84. package/dist/cjs/types/utils.js +4 -15
  85. package/dist/cjs/utils/config.js +74 -79
  86. package/dist/cjs/utils/createServer.js +16 -42
  87. package/dist/cjs/utils/env.js +7 -25
  88. package/dist/cjs/utils/generateWatchFiles.js +31 -52
  89. package/dist/cjs/utils/getSelectedEntries.js +13 -35
  90. package/dist/cjs/utils/getServerInternalPlugins.js +8 -29
  91. package/dist/cjs/utils/printInstructions.js +10 -28
  92. package/dist/cjs/utils/restart.js +13 -31
  93. package/dist/cjs/utils/routes.js +18 -39
  94. package/dist/cjs/utils/types.js +4 -15
  95. package/dist/esm/analyze/constants.js +40 -41
  96. package/dist/esm/analyze/generateCode.js +477 -455
  97. package/dist/esm/analyze/getBundleEntry.js +53 -54
  98. package/dist/esm/analyze/getClientRoutes/getRoutes.js +201 -202
  99. package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +199 -200
  100. package/dist/esm/analyze/getClientRoutes/index.js +2 -3
  101. package/dist/esm/analyze/getClientRoutes/utils.js +15 -15
  102. package/dist/esm/analyze/getFileSystemEntry.js +86 -87
  103. package/dist/esm/analyze/getHtmlTemplate.js +289 -278
  104. package/dist/esm/analyze/getServerRoutes.js +203 -190
  105. package/dist/esm/analyze/index.js +679 -651
  106. package/dist/esm/analyze/isDefaultExportFunction.js +38 -39
  107. package/dist/esm/analyze/makeLegalIdentifier.js +8 -9
  108. package/dist/esm/analyze/nestedRoutes.js +400 -392
  109. package/dist/esm/analyze/templates.js +536 -509
  110. package/dist/esm/analyze/utils.js +357 -336
  111. package/dist/esm/builder/builder-rspack/adapterCopy.js +347 -330
  112. package/dist/esm/builder/builder-rspack/index.js +8 -9
  113. package/dist/esm/builder/builder-webpack/adapterModern.js +51 -43
  114. package/dist/esm/builder/builder-webpack/createCopyPattern.js +31 -32
  115. package/dist/esm/builder/builder-webpack/index.js +266 -249
  116. package/dist/esm/builder/generator/createBuilderOptions.js +37 -38
  117. package/dist/esm/builder/generator/createBuilderProviderConfig.js +62 -63
  118. package/dist/esm/builder/generator/getBuilderTargets.js +13 -14
  119. package/dist/esm/builder/generator/index.js +203 -196
  120. package/dist/esm/builder/index.js +183 -176
  121. package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +90 -91
  122. package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +300 -291
  123. package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +337 -329
  124. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +108 -97
  125. package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +66 -64
  126. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +364 -337
  127. package/dist/esm/builder/shared/createCopyInfo.js +9 -10
  128. package/dist/esm/builder/shared/loaders/serverModuleLoader.js +2 -3
  129. package/dist/esm/builder/shared/types.js +1 -1
  130. package/dist/esm/commands/build.js +279 -272
  131. package/dist/esm/commands/deploy.js +150 -144
  132. package/dist/esm/commands/dev.js +296 -289
  133. package/dist/esm/commands/inspect.js +144 -138
  134. package/dist/esm/commands/serve.js +241 -235
  135. package/dist/esm/config/default.js +202 -203
  136. package/dist/esm/config/initialize/index.js +7 -8
  137. package/dist/esm/config/initialize/inits.js +189 -181
  138. package/dist/esm/config/legacy/createHtmlConfig.js +17 -18
  139. package/dist/esm/config/legacy/createOutputConfig.js +41 -42
  140. package/dist/esm/config/legacy/createSourceConfig.js +38 -39
  141. package/dist/esm/config/legacy/createToolsConfig.js +24 -25
  142. package/dist/esm/config/legacy/index.js +31 -32
  143. package/dist/esm/defineConfig.js +52 -53
  144. package/dist/esm/exports/server.js +1 -2
  145. package/dist/esm/hooks.js +26 -27
  146. package/dist/esm/index.js +685 -671
  147. package/dist/esm/initialize/index.js +276 -269
  148. package/dist/esm/locale/en.js +36 -37
  149. package/dist/esm/locale/index.js +2 -2
  150. package/dist/esm/locale/zh.js +36 -37
  151. package/dist/esm/schema/Schema.js +255 -244
  152. package/dist/esm/schema/index.js +165 -165
  153. package/dist/esm/schema/legacy.js +316 -317
  154. package/dist/esm/types/config/deploy.js +1 -1
  155. package/dist/esm/types/config/dev.js +1 -1
  156. package/dist/esm/types/config/experiments.js +1 -1
  157. package/dist/esm/types/config/html.js +1 -1
  158. package/dist/esm/types/config/output.js +1 -1
  159. package/dist/esm/types/config/performance.js +1 -1
  160. package/dist/esm/types/config/security.js +1 -1
  161. package/dist/esm/types/config/source.js +1 -1
  162. package/dist/esm/types/config/tools.js +1 -1
  163. package/dist/esm/types/hooks.js +1 -1
  164. package/dist/esm/types/legacyConfig/deploy.js +1 -1
  165. package/dist/esm/types/legacyConfig/dev.js +1 -1
  166. package/dist/esm/types/legacyConfig/index.js +1 -1
  167. package/dist/esm/types/legacyConfig/output.js +1 -1
  168. package/dist/esm/types/legacyConfig/source.js +1 -1
  169. package/dist/esm/types/legacyConfig/tools.js +1 -1
  170. package/dist/esm/types/utils.js +1 -1
  171. package/dist/esm/utils/config.js +285 -278
  172. package/dist/esm/utils/createServer.js +242 -234
  173. package/dist/esm/utils/env.js +11 -12
  174. package/dist/esm/utils/generateWatchFiles.js +205 -190
  175. package/dist/esm/utils/getSelectedEntries.js +180 -173
  176. package/dist/esm/utils/getServerInternalPlugins.js +197 -191
  177. package/dist/esm/utils/printInstructions.js +147 -141
  178. package/dist/esm/utils/restart.js +179 -173
  179. package/dist/esm/utils/routes.js +146 -139
  180. package/dist/esm/utils/types.js +1 -1
  181. package/dist/esm-node/analyze/constants.js +31 -46
  182. package/dist/esm-node/analyze/generateCode.js +28 -94
  183. package/dist/esm-node/analyze/getBundleEntry.js +8 -27
  184. package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +24 -65
  185. package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +24 -63
  186. package/dist/esm-node/analyze/getClientRoutes/index.js +2 -6
  187. package/dist/esm-node/analyze/getClientRoutes/utils.js +5 -19
  188. package/dist/esm-node/analyze/getFileSystemEntry.js +10 -37
  189. package/dist/esm-node/analyze/getHtmlTemplate.js +29 -59
  190. package/dist/esm-node/analyze/getServerRoutes.js +43 -75
  191. package/dist/esm-node/analyze/index.js +208 -230
  192. package/dist/esm-node/analyze/isDefaultExportFunction.js +7 -5
  193. package/dist/esm-node/analyze/makeLegalIdentifier.js +1 -4
  194. package/dist/esm-node/analyze/nestedRoutes.js +23 -43
  195. package/dist/esm-node/analyze/templates.js +22 -69
  196. package/dist/esm-node/analyze/utils.js +66 -60
  197. package/dist/esm-node/builder/builder-rspack/adapterCopy.js +40 -62
  198. package/dist/esm-node/builder/builder-rspack/index.js +4 -5
  199. package/dist/esm-node/builder/builder-webpack/adapterModern.js +24 -26
  200. package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +3 -10
  201. package/dist/esm-node/builder/builder-webpack/index.js +13 -11
  202. package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -5
  203. package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +5 -6
  204. package/dist/esm-node/builder/generator/getBuilderTargets.js +5 -11
  205. package/dist/esm-node/builder/generator/index.js +7 -16
  206. package/dist/esm-node/builder/index.js +2 -7
  207. package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -6
  208. package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +34 -60
  209. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +54 -74
  210. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +23 -8
  211. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +25 -16
  212. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +66 -76
  213. package/dist/esm-node/builder/shared/createCopyInfo.js +2 -8
  214. package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +1 -4
  215. package/dist/esm-node/builder/shared/types.js +1 -0
  216. package/dist/esm-node/commands/build.js +7 -9
  217. package/dist/esm-node/commands/deploy.js +1 -4
  218. package/dist/esm-node/commands/dev.js +19 -27
  219. package/dist/esm-node/commands/inspect.js +3 -8
  220. package/dist/esm-node/commands/serve.js +7 -25
  221. package/dist/esm-node/config/default.js +20 -11
  222. package/dist/esm-node/config/initialize/index.js +1 -4
  223. package/dist/esm-node/config/initialize/inits.js +48 -54
  224. package/dist/esm-node/config/legacy/createHtmlConfig.js +2 -19
  225. package/dist/esm-node/config/legacy/createOutputConfig.js +2 -30
  226. package/dist/esm-node/config/legacy/createSourceConfig.js +2 -17
  227. package/dist/esm-node/config/legacy/createToolsConfig.js +2 -22
  228. package/dist/esm-node/config/legacy/index.js +3 -18
  229. package/dist/esm-node/defineConfig.js +7 -13
  230. package/dist/esm-node/exports/server.js +1 -4
  231. package/dist/esm-node/hooks.js +2 -9
  232. package/dist/esm-node/index.js +95 -120
  233. package/dist/esm-node/initialize/index.js +74 -87
  234. package/dist/esm-node/locale/en.js +7 -6
  235. package/dist/esm-node/locale/index.js +5 -5
  236. package/dist/esm-node/locale/zh.js +7 -6
  237. package/dist/esm-node/schema/Schema.js +19 -8
  238. package/dist/esm-node/schema/index.js +121 -36
  239. package/dist/esm-node/schema/legacy.js +262 -72
  240. package/dist/esm-node/types/config/deploy.js +1 -0
  241. package/dist/esm-node/types/config/dev.js +1 -0
  242. package/dist/esm-node/types/config/experiments.js +1 -0
  243. package/dist/esm-node/types/config/html.js +1 -0
  244. package/dist/esm-node/types/config/output.js +1 -0
  245. package/dist/esm-node/types/config/performance.js +1 -0
  246. package/dist/esm-node/types/config/security.js +1 -0
  247. package/dist/esm-node/types/config/source.js +1 -0
  248. package/dist/esm-node/types/config/tools.js +1 -0
  249. package/dist/esm-node/types/hooks.js +1 -0
  250. package/dist/esm-node/types/legacyConfig/deploy.js +1 -0
  251. package/dist/esm-node/types/legacyConfig/dev.js +1 -0
  252. package/dist/esm-node/types/legacyConfig/index.js +1 -0
  253. package/dist/esm-node/types/legacyConfig/output.js +1 -0
  254. package/dist/esm-node/types/legacyConfig/source.js +1 -0
  255. package/dist/esm-node/types/legacyConfig/tools.js +1 -0
  256. package/dist/esm-node/types/utils.js +1 -0
  257. package/dist/esm-node/utils/config.js +16 -47
  258. package/dist/esm-node/utils/createServer.js +5 -12
  259. package/dist/esm-node/utils/env.js +1 -4
  260. package/dist/esm-node/utils/generateWatchFiles.js +13 -20
  261. package/dist/esm-node/utils/getSelectedEntries.js +2 -9
  262. package/dist/esm-node/utils/getServerInternalPlugins.js +2 -8
  263. package/dist/esm-node/utils/printInstructions.js +1 -4
  264. package/dist/esm-node/utils/restart.js +2 -11
  265. package/dist/esm-node/utils/routes.js +4 -4
  266. package/dist/esm-node/utils/types.js +1 -0
  267. package/dist/types/index.d.ts +2 -2
  268. package/package.json +29 -25
@@ -1,110 +1,121 @@
1
- function _arrayLikeToArray(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length)
3
+ len = arr.length;
4
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
5
+ arr2[i] = arr[i];
6
+ return arr2;
5
7
  }
6
- function _arrayWithoutHoles(arr) {
7
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ function _array_without_holes(arr) {
9
+ if (Array.isArray(arr))
10
+ return _array_like_to_array(arr);
8
11
  }
9
- function _classCallCheck(instance, Constructor) {
10
- if (!(instance instanceof Constructor)) {
11
- throw new TypeError("Cannot call a class as a function");
12
- }
12
+ function _class_call_check(instance, Constructor) {
13
+ if (!(instance instanceof Constructor)) {
14
+ throw new TypeError("Cannot call a class as a function");
15
+ }
13
16
  }
14
17
  function _defineProperties(target, props) {
15
- for(var i = 0; i < props.length; i++){
16
- var descriptor = props[i];
17
- descriptor.enumerable = descriptor.enumerable || false;
18
- descriptor.configurable = true;
19
- if ("value" in descriptor) descriptor.writable = true;
20
- Object.defineProperty(target, descriptor.key, descriptor);
21
- }
18
+ for (var i = 0; i < props.length; i++) {
19
+ var descriptor = props[i];
20
+ descriptor.enumerable = descriptor.enumerable || false;
21
+ descriptor.configurable = true;
22
+ if ("value" in descriptor)
23
+ descriptor.writable = true;
24
+ Object.defineProperty(target, descriptor.key, descriptor);
25
+ }
22
26
  }
23
- function _createClass(Constructor, protoProps, staticProps) {
24
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
- if (staticProps) _defineProperties(Constructor, staticProps);
26
- return Constructor;
27
+ function _create_class(Constructor, protoProps, staticProps) {
28
+ if (protoProps)
29
+ _defineProperties(Constructor.prototype, protoProps);
30
+ if (staticProps)
31
+ _defineProperties(Constructor, staticProps);
32
+ return Constructor;
27
33
  }
28
- function _defineProperty(obj, key, value) {
29
- if (key in obj) {
30
- Object.defineProperty(obj, key, {
31
- value: value,
32
- enumerable: true,
33
- configurable: true,
34
- writable: true
35
- });
36
- } else {
37
- obj[key] = value;
38
- }
39
- return obj;
34
+ function _define_property(obj, key, value) {
35
+ if (key in obj) {
36
+ Object.defineProperty(obj, key, {
37
+ value,
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true
41
+ });
42
+ } else {
43
+ obj[key] = value;
44
+ }
45
+ return obj;
40
46
  }
41
- function _iterableToArray(iter) {
42
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
47
+ function _iterable_to_array(iter) {
48
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
49
+ return Array.from(iter);
43
50
  }
44
- function _nonIterableSpread() {
45
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
51
+ function _non_iterable_spread() {
52
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
46
53
  }
47
- function _toConsumableArray(arr) {
48
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
54
+ function _to_consumable_array(arr) {
55
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
49
56
  }
50
- function _unsupportedIterableToArray(o, minLen) {
51
- if (!o) return;
52
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
53
- var n = Object.prototype.toString.call(o).slice(8, -1);
54
- if (n === "Object" && o.constructor) n = o.constructor.name;
55
- if (n === "Map" || n === "Set") return Array.from(n);
56
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
57
+ function _unsupported_iterable_to_array(o, minLen) {
58
+ if (!o)
59
+ return;
60
+ if (typeof o === "string")
61
+ return _array_like_to_array(o, minLen);
62
+ var n = Object.prototype.toString.call(o).slice(8, -1);
63
+ if (n === "Object" && o.constructor)
64
+ n = o.constructor.name;
65
+ if (n === "Map" || n === "Set")
66
+ return Array.from(n);
67
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
68
+ return _array_like_to_array(o, minLen);
57
69
  }
58
- var HtmlAsyncChunkPlugin = /*#__PURE__*/ function() {
59
- "use strict";
60
- function HtmlAsyncChunkPlugin(htmlWebpackPlugin) {
61
- _classCallCheck(this, HtmlAsyncChunkPlugin);
62
- _defineProperty(this, "name", void 0);
63
- _defineProperty(this, "htmlWebpackPlugin", void 0);
64
- this.name = "HtmlAsyncChunkPlugin";
65
- this.htmlWebpackPlugin = htmlWebpackPlugin;
66
- }
67
- _createClass(HtmlAsyncChunkPlugin, [
68
- {
69
- key: "apply",
70
- value: function apply(compiler) {
71
- var _this = this;
72
- compiler.hooks.compilation.tap(this.name, function(compilation) {
73
- var hooks = _this.htmlWebpackPlugin.getHooks(compilation);
74
- hooks.alterAssetTagGroups.tap(_this.name, function(assets) {
75
- var tags = _toConsumableArray(assets.headTags).concat(_toConsumableArray(assets.bodyTags));
76
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
77
- try {
78
- for(var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
79
- var tag = _step.value;
80
- if (tag.tagName === "script") {
81
- var attributes = tag.attributes;
82
- if (attributes && attributes.defer === true) {
83
- attributes.async = true;
84
- delete attributes.defer;
85
- }
86
- }
87
- }
88
- } catch (err) {
89
- _didIteratorError = true;
90
- _iteratorError = err;
91
- } finally{
92
- try {
93
- if (!_iteratorNormalCompletion && _iterator.return != null) {
94
- _iterator.return();
95
- }
96
- } finally{
97
- if (_didIteratorError) {
98
- throw _iteratorError;
99
- }
100
- }
101
- }
102
- return assets;
103
- });
104
- });
70
+ export var HtmlAsyncChunkPlugin = /* @__PURE__ */ function() {
71
+ "use strict";
72
+ function HtmlAsyncChunkPlugin2(htmlWebpackPlugin) {
73
+ _class_call_check(this, HtmlAsyncChunkPlugin2);
74
+ _define_property(this, "name", void 0);
75
+ _define_property(this, "htmlWebpackPlugin", void 0);
76
+ this.name = "HtmlAsyncChunkPlugin";
77
+ this.htmlWebpackPlugin = htmlWebpackPlugin;
78
+ }
79
+ _create_class(HtmlAsyncChunkPlugin2, [
80
+ {
81
+ key: "apply",
82
+ value: function apply(compiler) {
83
+ var _this = this;
84
+ compiler.hooks.compilation.tap(this.name, function(compilation) {
85
+ var hooks = _this.htmlWebpackPlugin.getHooks(compilation);
86
+ hooks.alterAssetTagGroups.tap(_this.name, function(assets) {
87
+ var tags = _to_consumable_array(assets.headTags).concat(_to_consumable_array(assets.bodyTags));
88
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
89
+ try {
90
+ for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
91
+ var tag = _step.value;
92
+ if (tag.tagName === "script") {
93
+ var attributes = tag.attributes;
94
+ if (attributes && attributes.defer === true) {
95
+ attributes.async = true;
96
+ delete attributes.defer;
97
+ }
98
+ }
99
+ }
100
+ } catch (err) {
101
+ _didIteratorError = true;
102
+ _iteratorError = err;
103
+ } finally {
104
+ try {
105
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
106
+ _iterator.return();
107
+ }
108
+ } finally {
109
+ if (_didIteratorError) {
110
+ throw _iteratorError;
111
+ }
112
+ }
105
113
  }
106
- }
107
- ]);
108
- return HtmlAsyncChunkPlugin;
114
+ return assets;
115
+ });
116
+ });
117
+ }
118
+ }
119
+ ]);
120
+ return HtmlAsyncChunkPlugin2;
109
121
  }();
110
- export { HtmlAsyncChunkPlugin };
@@ -1,72 +1,74 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
1
+ function _class_call_check(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
5
  }
6
6
  function _defineProperties(target, props) {
7
- for(var i = 0; i < props.length; i++){
8
- var descriptor = props[i];
9
- descriptor.enumerable = descriptor.enumerable || false;
10
- descriptor.configurable = true;
11
- if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
13
- }
7
+ for (var i = 0; i < props.length; i++) {
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor)
12
+ descriptor.writable = true;
13
+ Object.defineProperty(target, descriptor.key, descriptor);
14
+ }
14
15
  }
15
- function _createClass(Constructor, protoProps, staticProps) {
16
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
- if (staticProps) _defineProperties(Constructor, staticProps);
18
- return Constructor;
16
+ function _create_class(Constructor, protoProps, staticProps) {
17
+ if (protoProps)
18
+ _defineProperties(Constructor.prototype, protoProps);
19
+ if (staticProps)
20
+ _defineProperties(Constructor, staticProps);
21
+ return Constructor;
19
22
  }
20
- function _defineProperty(obj, key, value) {
21
- if (key in obj) {
22
- Object.defineProperty(obj, key, {
23
- value: value,
24
- enumerable: true,
25
- configurable: true,
26
- writable: true
27
- });
28
- } else {
29
- obj[key] = value;
30
- }
31
- return obj;
23
+ function _define_property(obj, key, value) {
24
+ if (key in obj) {
25
+ Object.defineProperty(obj, key, {
26
+ value,
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true
30
+ });
31
+ } else {
32
+ obj[key] = value;
33
+ }
34
+ return obj;
32
35
  }
33
- var BottomTemplatePlugin = /*#__PURE__*/ function() {
34
- "use strict";
35
- function BottomTemplatePlugin(htmlWebpackPlugin) {
36
- _classCallCheck(this, BottomTemplatePlugin);
37
- _defineProperty(this, "htmlWebpackPlugin", void 0);
38
- _defineProperty(this, "bottomTemplateReg", /<!--<\?-\s*bottomTemplate\s*\?>-->/);
39
- _defineProperty(this, "bodyRegExp", /(<\/\s*body\s*>)/i);
40
- _defineProperty(this, "name", void 0);
41
- this.htmlWebpackPlugin = htmlWebpackPlugin;
42
- this.name = "bottom-template";
43
- }
44
- _createClass(BottomTemplatePlugin, [
45
- {
46
- key: "apply",
47
- value: function apply(compiler) {
48
- var _this = this;
49
- compiler.hooks.compilation.tap(this.name, function(compilation) {
50
- _this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(_this.name, function(data) {
51
- var _data_plugin_options;
52
- if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
53
- return data;
54
- }
55
- if (_this.bottomTemplateReg.test(data.html)) {
56
- data.html = data.html.replace(_this.bottomTemplateReg, "");
57
- var bottomTemplate = data.plugin.options.bottomTemplate;
58
- if (bottomTemplate) {
59
- data.html = data.html.replace(_this.bodyRegExp, function(match) {
60
- return "\n".concat(bottomTemplate, "\n").concat(match);
61
- });
62
- }
63
- }
64
- return data;
65
- });
36
+ export var BottomTemplatePlugin = /* @__PURE__ */ function() {
37
+ "use strict";
38
+ function BottomTemplatePlugin2(htmlWebpackPlugin) {
39
+ _class_call_check(this, BottomTemplatePlugin2);
40
+ _define_property(this, "htmlWebpackPlugin", void 0);
41
+ _define_property(this, "bottomTemplateReg", /<!--<\?-\s*bottomTemplate\s*\?>-->/);
42
+ _define_property(this, "bodyRegExp", /(<\/\s*body\s*>)/i);
43
+ _define_property(this, "name", void 0);
44
+ this.htmlWebpackPlugin = htmlWebpackPlugin;
45
+ this.name = "bottom-template";
46
+ }
47
+ _create_class(BottomTemplatePlugin2, [
48
+ {
49
+ key: "apply",
50
+ value: function apply(compiler) {
51
+ var _this = this;
52
+ compiler.hooks.compilation.tap(this.name, function(compilation) {
53
+ _this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(_this.name, function(data) {
54
+ var _data_plugin_options;
55
+ if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
56
+ return data;
57
+ }
58
+ if (_this.bottomTemplateReg.test(data.html)) {
59
+ data.html = data.html.replace(_this.bottomTemplateReg, "");
60
+ var bottomTemplate = data.plugin.options.bottomTemplate;
61
+ if (bottomTemplate) {
62
+ data.html = data.html.replace(_this.bodyRegExp, function(match) {
63
+ return "\n".concat(bottomTemplate, "\n").concat(match);
66
64
  });
65
+ }
67
66
  }
68
- }
69
- ]);
70
- return BottomTemplatePlugin;
67
+ return data;
68
+ });
69
+ });
70
+ }
71
+ }
72
+ ]);
73
+ return BottomTemplatePlugin2;
71
74
  }();
72
- export { BottomTemplatePlugin };