@zohodesk/react-cli 0.0.1-beta.98 → 0.0.1-betaa.138.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +149 -0
  3. package/bin/cli.js +34 -29
  4. package/files/eslintrc.js +57 -0
  5. package/files/prettierrc.js +3 -0
  6. package/lib/babel/cmjs-plugins-presets.js +16 -9
  7. package/lib/babel/es-plugins-presets.js +26 -14
  8. package/lib/common/getEntries.js +31 -22
  9. package/lib/common/getPublicPathConfig.js +27 -13
  10. package/lib/common/index.js +21 -25
  11. package/lib/common/splitChunks.js +62 -53
  12. package/lib/common/templateParameters.js +10 -8
  13. package/lib/configs/jest.config.js +15 -25
  14. package/lib/configs/webpack.component.umd.config.js +31 -37
  15. package/lib/configs/webpack.css.umd.config.js +44 -47
  16. package/lib/configs/webpack.dev.config.js +70 -52
  17. package/lib/configs/webpack.docs.config.js +106 -106
  18. package/lib/configs/webpack.prod.config.js +95 -75
  19. package/lib/hooks/docsProptypeHook.js +32 -38
  20. package/lib/jest/commitedFilesResult.js +103 -74
  21. package/lib/jest/coverageCollector.js +41 -21
  22. package/lib/jest/jsonMaker.js +15 -16
  23. package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
  24. package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
  25. package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
  26. package/lib/jest/result.js +90 -45
  27. package/lib/jest/run.js +43 -43
  28. package/lib/jest/setup.js +102 -95
  29. package/lib/loaderUtils/getCSSLoaders.js +21 -22
  30. package/lib/loaderUtils/getDevJsLoaders.js +25 -23
  31. package/lib/loaderUtils/index.js +11 -13
  32. package/lib/loaders/docsLoader.js +15 -15
  33. package/lib/loaders/docsPropsLoader.js +14 -17
  34. package/lib/loaders/fileLoader.js +33 -35
  35. package/lib/loaders/scriptInstrumentLoader.js +21 -20
  36. package/lib/loaders/workerLoader.js +136 -0
  37. package/lib/middlewares/HMRMiddleware.js +54 -45
  38. package/lib/middlewares/SSTMiddleware.js +8 -5
  39. package/lib/pluginUtils/getDevPlugins.js +114 -52
  40. package/lib/pluginUtils/getDocsPlugins.js +25 -29
  41. package/lib/pluginUtils/getLibraryPlugins.js +8 -10
  42. package/lib/pluginUtils/getProdPlugins.js +163 -74
  43. package/lib/pluginUtils/getServerPlugins.js +8 -11
  44. package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
  45. package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
  46. package/lib/pluginUtils/index.js +36 -43
  47. package/lib/plugins/CdnChangePlugin.js +63 -0
  48. package/lib/plugins/CleanupStatsPlugin.js +18 -32
  49. package/lib/plugins/CustomAttributePlugin.js +79 -0
  50. package/lib/plugins/CustomAttributePlugin.md +35 -0
  51. package/lib/plugins/EFCPlugin.js +185 -0
  52. package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
  53. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
  54. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
  55. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
  56. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
  57. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
  58. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
  59. package/lib/plugins/I18nSplitPlugin/README.md +25 -0
  60. package/lib/plugins/I18nSplitPlugin/index.js +185 -0
  61. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
  62. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
  63. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
  64. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
  65. package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
  66. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
  67. package/lib/plugins/ManifestPlugin.js +52 -63
  68. package/lib/plugins/ModuleStatsPlugin.js +83 -173
  69. package/lib/plugins/OptimizeJSPlugin.js +24 -41
  70. package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
  71. package/lib/plugins/PublicPathChangePlugin.js +175 -284
  72. package/lib/plugins/ReportGeneratePlugin.js +150 -151
  73. package/lib/plugins/ResourceHintsPlugin.js +53 -35
  74. package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
  75. package/lib/plugins/ServiceWorkerPlugin.js +81 -57
  76. package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
  77. package/lib/plugins/SourceMapHookPlugin.js +21 -33
  78. package/lib/plugins/TPHashMappingPlugin.js +67 -0
  79. package/lib/plugins/UglifyCSSPlugin.js +23 -30
  80. package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
  81. package/lib/plugins/index.js +100 -91
  82. package/lib/plugins/webpackwatchrunplugin.js +18 -30
  83. package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
  84. package/lib/schemas/index.js +336 -81
  85. package/lib/servers/clusterHubServer.js +22 -26
  86. package/lib/servers/docsServer.js +3 -5
  87. package/lib/servers/docsServerCore.js +84 -91
  88. package/lib/servers/helpServer.js +19 -21
  89. package/lib/servers/impactServer.js +99 -92
  90. package/lib/servers/mockserver.js +24 -24
  91. package/lib/servers/scrServer.js +78 -98
  92. package/lib/servers/server.js +101 -122
  93. package/lib/servers/ssServer.js +63 -61
  94. package/lib/sh/reportPublish.sh +1 -2
  95. package/lib/templates/CoverageScriptTemplate.js +45 -18
  96. package/lib/templates/WMSTemplate.js +17 -18
  97. package/lib/templates/linterConstant.js +6 -4
  98. package/lib/utils/babelPresets.js +12 -5
  99. package/lib/utils/clean.js +12 -11
  100. package/lib/utils/copy.js +12 -34
  101. package/lib/utils/copyTimezones.js +9 -16
  102. package/lib/utils/createEventStream.js +24 -19
  103. package/lib/utils/cssClassNameGenerate.js +44 -73
  104. package/lib/utils/cssURLReplacer.js +62 -56
  105. package/lib/utils/dependencyPostPublish.js +20 -19
  106. package/lib/utils/fileUtils.js +66 -54
  107. package/lib/utils/folderIterator.js +20 -21
  108. package/lib/utils/getComponents.js +70 -27
  109. package/lib/utils/getCurrentBranch.js +11 -17
  110. package/lib/utils/getDependenciesImpactList.js +114 -187
  111. package/lib/utils/getHash.js +9 -13
  112. package/lib/utils/getIp.js +9 -9
  113. package/lib/utils/getOptions.js +26 -29
  114. package/lib/utils/getServerURL.js +19 -10
  115. package/lib/utils/index.js +147 -126
  116. package/lib/utils/init.js +2 -2
  117. package/lib/utils/initPreCommitHook.js +40 -32
  118. package/lib/utils/jsonHelper.js +37 -21
  119. package/lib/utils/lint/addScripts.js +27 -0
  120. package/lib/utils/lint/checkExistingConfig.js +67 -0
  121. package/lib/utils/lint/copyConfigs.js +24 -0
  122. package/lib/utils/lint/index.js +54 -0
  123. package/lib/utils/lint/lintScripts.js +11 -0
  124. package/lib/utils/lint/lintSetup.js +31 -0
  125. package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
  126. package/lib/utils/lint/question.js +30 -0
  127. package/lib/utils/lintReporter.js +70 -56
  128. package/lib/utils/mailSender.js +12 -27
  129. package/lib/utils/pullOrigin.js +21 -18
  130. package/lib/utils/reinstallDependencies.js +76 -85
  131. package/lib/utils/removeAttributes.js +25 -23
  132. package/lib/utils/repoClone.js +47 -45
  133. package/lib/utils/request.js +64 -77
  134. package/lib/utils/rtl.js +22 -29
  135. package/lib/utils/setEnvVariables.js +5 -6
  136. package/lib/utils/ssTestHack.js +21 -19
  137. package/lib/utils/switchBranch.js +21 -20
  138. package/lib/utils/urlConcat.js +22 -0
  139. package/package.json +72 -67
@@ -1,350 +1,269 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ShadowDOMSupportPlugin;
7
7
 
8
- var _Template = require('webpack/lib/Template');
8
+ var _Template = _interopRequireDefault(require("webpack/lib/Template"));
9
9
 
10
- var _Template2 = _interopRequireDefault(_Template);
10
+ var _JsonpMainTemplatePlugin = _interopRequireDefault(require("webpack/lib/web/JsonpMainTemplatePlugin"));
11
11
 
12
- var _JsonpMainTemplatePlugin = require('webpack/lib/web/JsonpMainTemplatePlugin');
13
-
14
- var _JsonpMainTemplatePlugin2 = _interopRequireDefault(_JsonpMainTemplatePlugin);
15
-
16
- var _tapable = require('tapable');
12
+ var _tapable = require("tapable");
17
13
 
18
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
15
 
16
+ /* eslint-disable no-unused-vars */
20
17
  //eslint-disable-next-line
21
- function ShadowDOMSupportPlugin() {} /* eslint-disable no-unused-vars */
18
+ function ShadowDOMSupportPlugin() {}
22
19
 
23
20
  ShadowDOMSupportPlugin.prototype.apply = function () {
24
21
  this.patchJsonpMainTemplatePlugin();
25
22
  };
26
23
 
27
24
  ShadowDOMSupportPlugin.prototype.patchJsonpMainTemplatePlugin = function () {
28
- _JsonpMainTemplatePlugin2.default.prototype.apply = this._apply;
25
+ _JsonpMainTemplatePlugin.default.prototype.apply = this._apply;
29
26
  };
30
27
 
31
28
  ShadowDOMSupportPlugin.prototype._apply = function (mainTemplate) {
32
- var needChunkOnDemandLoadingCode = function needChunkOnDemandLoadingCode(chunk) {
33
- var _iteratorNormalCompletion = true;
34
- var _didIteratorError = false;
35
- var _iteratorError = undefined;
36
-
37
- try {
38
- for (var _iterator = chunk.groupsIterable[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
39
- var chunkGroup = _step.value;
40
-
41
- if (chunkGroup.getNumberOfChildren() > 0) {
42
- return true;
43
- }
44
- }
45
- } catch (err) {
46
- _didIteratorError = true;
47
- _iteratorError = err;
48
- } finally {
49
- try {
50
- if (!_iteratorNormalCompletion && _iterator.return) {
51
- _iterator.return();
52
- }
53
- } finally {
54
- if (_didIteratorError) {
55
- throw _iteratorError;
56
- }
29
+ const needChunkOnDemandLoadingCode = chunk => {
30
+ for (const chunkGroup of chunk.groupsIterable) {
31
+ if (chunkGroup.getNumberOfChildren() > 0) {
32
+ return true;
57
33
  }
58
34
  }
59
35
 
60
36
  return false;
61
37
  };
62
- var needChunkLoadingCode = function needChunkLoadingCode(chunk) {
63
- var _iteratorNormalCompletion2 = true;
64
- var _didIteratorError2 = false;
65
- var _iteratorError2 = undefined;
66
-
67
- try {
68
- for (var _iterator2 = chunk.groupsIterable[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
69
- var chunkGroup = _step2.value;
70
38
 
71
- if (chunkGroup.chunks.length > 1) {
72
- return true;
73
- }
74
- if (chunkGroup.getNumberOfChildren() > 0) {
75
- return true;
76
- }
39
+ const needChunkLoadingCode = chunk => {
40
+ for (const chunkGroup of chunk.groupsIterable) {
41
+ if (chunkGroup.chunks.length > 1) {
42
+ return true;
77
43
  }
78
- } catch (err) {
79
- _didIteratorError2 = true;
80
- _iteratorError2 = err;
81
- } finally {
82
- try {
83
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
84
- _iterator2.return();
85
- }
86
- } finally {
87
- if (_didIteratorError2) {
88
- throw _iteratorError2;
89
- }
44
+
45
+ if (chunkGroup.getNumberOfChildren() > 0) {
46
+ return true;
90
47
  }
91
48
  }
92
49
 
93
50
  return false;
94
51
  };
95
- var needEntryDeferringCode = function needEntryDeferringCode(chunk) {
96
- var _iteratorNormalCompletion3 = true;
97
- var _didIteratorError3 = false;
98
- var _iteratorError3 = undefined;
99
52
 
100
- try {
101
- for (var _iterator3 = chunk.groupsIterable[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
102
- var chunkGroup = _step3.value;
103
-
104
- if (chunkGroup.chunks.length > 1) {
105
- return true;
106
- }
107
- }
108
- } catch (err) {
109
- _didIteratorError3 = true;
110
- _iteratorError3 = err;
111
- } finally {
112
- try {
113
- if (!_iteratorNormalCompletion3 && _iterator3.return) {
114
- _iterator3.return();
115
- }
116
- } finally {
117
- if (_didIteratorError3) {
118
- throw _iteratorError3;
119
- }
53
+ const needEntryDeferringCode = chunk => {
54
+ for (const chunkGroup of chunk.groupsIterable) {
55
+ if (chunkGroup.chunks.length > 1) {
56
+ return true;
120
57
  }
121
58
  }
122
59
 
123
60
  return false;
124
61
  };
125
- var needPrefetchingCode = function needPrefetchingCode(chunk) {
126
- var allPrefetchChunks = chunk.getChildIdsByOrdersMap(true).prefetch;
62
+
63
+ const needPrefetchingCode = chunk => {
64
+ const allPrefetchChunks = chunk.getChildIdsByOrdersMap(true).prefetch;
127
65
  return allPrefetchChunks && Object.keys(allPrefetchChunks).length;
128
- };
66
+ }; // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
129
67
 
130
- // TODO webpack 5, no adding to .hooks, use WeakMap and static methods
131
- ['jsonpScript', 'linkPreload', 'linkPrefetch'].forEach(function (hook) {
68
+
69
+ ['jsonpScript', 'linkPreload', 'linkPrefetch'].forEach(hook => {
132
70
  if (!mainTemplate.hooks[hook]) {
133
71
  mainTemplate.hooks[hook] = new _tapable.SyncWaterfallHook(['source', 'chunk', 'hash']);
134
72
  }
135
73
  });
136
74
 
137
- var getScriptSrcPath = function getScriptSrcPath(hash, chunk, chunkIdExpression) {
138
- var chunkFilename = mainTemplate.outputOptions.chunkFilename;
139
-
140
- var chunkMaps = chunk.getChunkMaps();
75
+ const getScriptSrcPath = (hash, chunk, chunkIdExpression) => {
76
+ const {
77
+ chunkFilename
78
+ } = mainTemplate.outputOptions;
79
+ const chunkMaps = chunk.getChunkMaps();
141
80
  return mainTemplate.getAssetPath(JSON.stringify(chunkFilename), {
142
- hash: '" + ' + mainTemplate.renderCurrentHashCode(hash) + ' + "',
143
- hashWithLength: function hashWithLength(length) {
144
- return '" + ' + mainTemplate.renderCurrentHashCode(hash, length) + ' + "';
145
- },
81
+ hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
82
+ hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
146
83
  chunk: {
147
- id: '" + ' + chunkIdExpression + ' + "',
148
- hash: '" + ' + JSON.stringify(chunkMaps.hash) + '[' + chunkIdExpression + '] + "',
149
- hashWithLength: function hashWithLength(length) {
150
- var shortChunkHashMap = Object.create(null);
151
- var _iteratorNormalCompletion4 = true;
152
- var _didIteratorError4 = false;
153
- var _iteratorError4 = undefined;
154
-
155
- try {
156
- for (var _iterator4 = Object.keys(chunkMaps.hash)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
157
- var chunkId = _step4.value;
158
-
159
- if (typeof chunkMaps.hash[chunkId] === 'string') {
160
- shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
161
- }
162
- }
163
- } catch (err) {
164
- _didIteratorError4 = true;
165
- _iteratorError4 = err;
166
- } finally {
167
- try {
168
- if (!_iteratorNormalCompletion4 && _iterator4.return) {
169
- _iterator4.return();
170
- }
171
- } finally {
172
- if (_didIteratorError4) {
173
- throw _iteratorError4;
174
- }
84
+ id: `" + ${chunkIdExpression} + "`,
85
+ hash: `" + ${JSON.stringify(chunkMaps.hash)}[${chunkIdExpression}] + "`,
86
+
87
+ hashWithLength(length) {
88
+ const shortChunkHashMap = Object.create(null);
89
+
90
+ for (const chunkId of Object.keys(chunkMaps.hash)) {
91
+ if (typeof chunkMaps.hash[chunkId] === 'string') {
92
+ shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
175
93
  }
176
94
  }
177
95
 
178
- return '" + ' + JSON.stringify(shortChunkHashMap) + '[' + chunkIdExpression + '] + "';
96
+ return `" + ${JSON.stringify(shortChunkHashMap)}[${chunkIdExpression}] + "`;
179
97
  },
180
98
 
181
- name: '" + (' + JSON.stringify(chunkMaps.name) + '[' + chunkIdExpression + ']||' + chunkIdExpression + ') + "',
99
+ name: `" + (${JSON.stringify(chunkMaps.name)}[${chunkIdExpression}]||${chunkIdExpression}) + "`,
182
100
  contentHash: {
183
- javascript: '" + ' + JSON.stringify(chunkMaps.contentHash.javascript) + '[' + chunkIdExpression + '] + "'
101
+ javascript: `" + ${JSON.stringify(chunkMaps.contentHash.javascript)}[${chunkIdExpression}] + "`
184
102
  },
185
103
  contentHashWithLength: {
186
- javascript: function javascript(length) {
187
- var shortContentHashMap = {};
188
- var contentHash = chunkMaps.contentHash.javascript;
189
- var _iteratorNormalCompletion5 = true;
190
- var _didIteratorError5 = false;
191
- var _iteratorError5 = undefined;
192
-
193
- try {
194
- for (var _iterator5 = Object.keys(contentHash)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
195
- var chunkId = _step5.value;
196
-
197
- if (typeof contentHash[chunkId] === 'string') {
198
- shortContentHashMap[chunkId] = contentHash[chunkId].substr(0, length);
199
- }
200
- }
201
- } catch (err) {
202
- _didIteratorError5 = true;
203
- _iteratorError5 = err;
204
- } finally {
205
- try {
206
- if (!_iteratorNormalCompletion5 && _iterator5.return) {
207
- _iterator5.return();
208
- }
209
- } finally {
210
- if (_didIteratorError5) {
211
- throw _iteratorError5;
212
- }
104
+ javascript: length => {
105
+ const shortContentHashMap = {};
106
+ const contentHash = chunkMaps.contentHash.javascript;
107
+
108
+ for (const chunkId of Object.keys(contentHash)) {
109
+ if (typeof contentHash[chunkId] === 'string') {
110
+ shortContentHashMap[chunkId] = contentHash[chunkId].substr(0, length);
213
111
  }
214
112
  }
215
113
 
216
- return '" + ' + JSON.stringify(shortContentHashMap) + '[' + chunkIdExpression + '] + "';
114
+ return `" + ${JSON.stringify(shortContentHashMap)}[${chunkIdExpression}] + "`;
217
115
  }
218
116
  }
219
117
  },
220
118
  contentHashType: 'javascript'
221
119
  });
222
120
  };
223
- mainTemplate.hooks.localVars.tap('JsonpMainTemplatePlugin', function (source, chunk, hash) {
224
- var extraCode = [];
121
+
122
+ mainTemplate.hooks.localVars.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
123
+ const extraCode = [];
124
+
225
125
  if (needChunkLoadingCode(chunk)) {
226
- extraCode.push('', '// object to store loaded and loading chunks', '// undefined = chunk not loaded, null = chunk preloaded/prefetched', '// Promise = chunk loading, 0 = chunk loaded', 'var installedChunks = {', _Template2.default.indent(chunk.ids.map(function (id) {
227
- return JSON.stringify(id) + ': 0';
228
- }).join(',\n')), '};', '', needEntryDeferringCode(chunk) ? 'var deferredModules = [];' : '');
126
+ extraCode.push('', '// object to store loaded and loading chunks', '// undefined = chunk not loaded, null = chunk preloaded/prefetched', '// Promise = chunk loading, 0 = chunk loaded', 'var installedChunks = {', _Template.default.indent(chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};', '', needEntryDeferringCode(chunk) ? 'var deferredModules = [];' : '');
229
127
  }
128
+
230
129
  if (needChunkOnDemandLoadingCode(chunk)) {
231
- extraCode.push('', '// script path function', 'function jsonpScriptSrc(chunkId) {', _Template2.default.indent(['return ' + mainTemplate.requireFn + '.p + ' + getScriptSrcPath(hash, chunk, 'chunkId')]), '}');
130
+ extraCode.push('', '// script path function', 'function jsonpScriptSrc(chunkId) {', _Template.default.indent([`return ${mainTemplate.requireFn}.p + ${getScriptSrcPath(hash, chunk, 'chunkId')}`]), '}');
232
131
  }
132
+
233
133
  if (extraCode.length === 0) {
234
134
  return source;
235
135
  }
236
- return _Template2.default.asString([source].concat(extraCode));
237
- });
238
-
239
- mainTemplate.hooks.jsonpScript.tap('JsonpMainTemplatePlugin', function (_, chunk, hash) {
240
- var crossOriginLoading = mainTemplate.outputOptions.crossOriginLoading;
241
- var chunkLoadTimeout = mainTemplate.outputOptions.chunkLoadTimeout;
242
- var jsonpScriptType = mainTemplate.outputOptions.jsonpScriptType;
243
-
244
136
 
245
- return _Template2.default.asString(['var script = document.createElement(\'script\');', 'var onScriptComplete;', jsonpScriptType ? 'script.type = ' + JSON.stringify(jsonpScriptType) + ';' : '', 'script.charset = \'utf-8\';', 'script.timeout = ' + chunkLoadTimeout / 1000 + ';', 'if (' + mainTemplate.requireFn + '.nc) {', _Template2.default.indent('script.setAttribute("nonce", ' + mainTemplate.requireFn + '.nc);'), '}', 'script.src = jsonpScriptSrc(chunkId);', crossOriginLoading ? _Template2.default.asString(['if (script.src.indexOf(window.location.origin + \'/\') !== 0) {', _Template2.default.indent('script.crossOrigin = ' + JSON.stringify(crossOriginLoading) + ';'), '}']) : '', 'onScriptComplete = function (event) {', _Template2.default.indent(['// avoid mem leaks in IE.', 'script.onerror = script.onload = null;', 'clearTimeout(timeout);', 'var chunk = installedChunks[chunkId];', 'if(chunk !== 0) {', _Template2.default.indent(['if(chunk) {', _Template2.default.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src;', 'var error = new Error(\'Loading chunk \' + chunkId + \' failed.\\n(\' + errorType + \': \' + realSrc + \')\');', 'error.type = errorType;', 'error.request = realSrc;', 'chunk[1](error);']), '}', 'installedChunks[chunkId] = undefined;']), '}']), '};', 'var timeout = setTimeout(function(){', _Template2.default.indent(['onScriptComplete({ type: \'timeout\', target: script });']), '}, ' + chunkLoadTimeout + ');', 'script.onerror = script.onload = onScriptComplete;']);
137
+ return _Template.default.asString([source, ...extraCode]);
246
138
  });
247
- mainTemplate.hooks.linkPreload.tap('JsonpMainTemplatePlugin', function (_, chunk, hash) {
248
- var crossOriginLoading = mainTemplate.outputOptions.crossOriginLoading;
249
- var jsonpScriptType = mainTemplate.outputOptions.jsonpScriptType;
250
-
251
-
252
- return _Template2.default.asString(['var link = document.createElement(\'link\');', jsonpScriptType ? 'link.type = ' + JSON.stringify(jsonpScriptType) + ';' : '', 'link.charset = \'utf-8\';', 'if (' + mainTemplate.requireFn + '.nc) {', _Template2.default.indent('link.setAttribute("nonce", ' + mainTemplate.requireFn + '.nc);'), '}', 'link.rel = "preload";', 'link.as = "script";', 'link.href = jsonpScriptSrc(chunkId);', crossOriginLoading ? _Template2.default.asString(['if (link.href.indexOf(window.location.origin + \'/\') !== 0) {', _Template2.default.indent('link.crossOrigin = ' + JSON.stringify(crossOriginLoading) + ';'), '}']) : '']);
139
+ mainTemplate.hooks.jsonpScript.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
140
+ const {
141
+ crossOriginLoading
142
+ } = mainTemplate.outputOptions;
143
+ const {
144
+ chunkLoadTimeout
145
+ } = mainTemplate.outputOptions;
146
+ const {
147
+ jsonpScriptType
148
+ } = mainTemplate.outputOptions;
149
+ return _Template.default.asString(['var script = document.createElement(\'script\');', 'var onScriptComplete;', jsonpScriptType ? `script.type = ${JSON.stringify(jsonpScriptType)};` : '', 'script.charset = \'utf-8\';', `script.timeout = ${chunkLoadTimeout / 1000};`, `if (${mainTemplate.requireFn}.nc) {`, _Template.default.indent(`script.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`), '}', 'script.src = jsonpScriptSrc(chunkId);', crossOriginLoading ? _Template.default.asString(['if (script.src.indexOf(window.location.origin + \'/\') !== 0) {', _Template.default.indent(`script.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', 'onScriptComplete = function (event) {', _Template.default.indent(['// avoid mem leaks in IE.', 'script.onerror = script.onload = null;', 'clearTimeout(timeout);', 'var chunk = installedChunks[chunkId];', 'if(chunk !== 0) {', _Template.default.indent(['if(chunk) {', _Template.default.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src;', 'var error = new Error(\'Loading chunk \' + chunkId + \' failed.\\n(\' + errorType + \': \' + realSrc + \')\');', 'error.type = errorType;', 'error.request = realSrc;', 'chunk[1](error);']), '}', 'installedChunks[chunkId] = undefined;']), '}']), '};', 'var timeout = setTimeout(function(){', _Template.default.indent(['onScriptComplete({ type: \'timeout\', target: script });']), `}, ${chunkLoadTimeout});`, 'script.onerror = script.onload = onScriptComplete;']);
253
150
  });
254
- mainTemplate.hooks.linkPrefetch.tap('JsonpMainTemplatePlugin', function (_, chunk, hash) {
255
- var crossOriginLoading = mainTemplate.outputOptions.crossOriginLoading;
256
-
257
-
258
- return _Template2.default.asString(['var link = document.createElement(\'link\');', crossOriginLoading ? 'link.crossOrigin = ' + JSON.stringify(crossOriginLoading) + ';' : '', 'if (' + mainTemplate.requireFn + '.nc) {', _Template2.default.indent('link.setAttribute("nonce", ' + mainTemplate.requireFn + '.nc);'), '}', 'link.rel = "prefetch";', 'link.as = "script";', 'link.href = jsonpScriptSrc(chunkId);']);
151
+ mainTemplate.hooks.linkPreload.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
152
+ const {
153
+ crossOriginLoading
154
+ } = mainTemplate.outputOptions;
155
+ const {
156
+ jsonpScriptType
157
+ } = mainTemplate.outputOptions;
158
+ return _Template.default.asString(['var link = document.createElement(\'link\');', jsonpScriptType ? `link.type = ${JSON.stringify(jsonpScriptType)};` : '', 'link.charset = \'utf-8\';', `if (${mainTemplate.requireFn}.nc) {`, _Template.default.indent(`link.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`), '}', 'link.rel = "preload";', 'link.as = "script";', 'link.href = jsonpScriptSrc(chunkId);', crossOriginLoading ? _Template.default.asString(['if (link.href.indexOf(window.location.origin + \'/\') !== 0) {', _Template.default.indent(`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '']);
259
159
  });
260
- mainTemplate.hooks.requireEnsure.tap('JsonpMainTemplatePlugin load', function (source, chunk, hash) {
261
- return _Template2.default.asString([source, '', '// JSONP chunk loading for javascript', '', 'var installedChunkData = installedChunks[chunkId];', 'if(installedChunkData !== 0) { // 0 means "already installed".', _Template2.default.indent(['', '// a Promise means "currently loading".', 'if(installedChunkData) {', _Template2.default.indent(['promises.push(installedChunkData[2]);']), '} else {', _Template2.default.indent(['// setup Promise in chunk cache', 'var promise = new Promise(function(resolve, reject) {', _Template2.default.indent(['installedChunkData = installedChunks[chunkId] = [resolve, reject];']), '});', 'promises.push(installedChunkData[2] = promise);', '', '// start chunk loading', mainTemplate.hooks.jsonpScript.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(script);']), '}']), '}']);
160
+ mainTemplate.hooks.linkPrefetch.tap('JsonpMainTemplatePlugin', (_, chunk, hash) => {
161
+ const {
162
+ crossOriginLoading
163
+ } = mainTemplate.outputOptions;
164
+ return _Template.default.asString(['var link = document.createElement(\'link\');', crossOriginLoading ? `link.crossOrigin = ${JSON.stringify(crossOriginLoading)};` : '', `if (${mainTemplate.requireFn}.nc) {`, _Template.default.indent(`link.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`), '}', 'link.rel = "prefetch";', 'link.as = "script";', 'link.href = jsonpScriptSrc(chunkId);']);
262
165
  });
166
+ mainTemplate.hooks.requireEnsure.tap('JsonpMainTemplatePlugin load', (source, chunk, hash) => _Template.default.asString([source, '', '// JSONP chunk loading for javascript', '', 'var installedChunkData = installedChunks[chunkId];', 'if(installedChunkData !== 0) { // 0 means "already installed".', _Template.default.indent(['', '// a Promise means "currently loading".', 'if(installedChunkData) {', _Template.default.indent(['promises.push(installedChunkData[2]);']), '} else {', _Template.default.indent(['// setup Promise in chunk cache', 'var promise = new Promise(function(resolve, reject) {', _Template.default.indent(['installedChunkData = installedChunks[chunkId] = [resolve, reject];']), '});', 'promises.push(installedChunkData[2] = promise);', '', '// start chunk loading', mainTemplate.hooks.jsonpScript.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(script);']), '}']), '}']));
263
167
  mainTemplate.hooks.requireEnsure.tap({
264
168
  name: 'JsonpMainTemplatePlugin preload',
265
169
  stage: 10
266
- }, function (source, chunk, hash) {
267
- var chunkMap = chunk.getChildIdsByOrdersMap().preload;
170
+ }, (source, chunk, hash) => {
171
+ const chunkMap = chunk.getChildIdsByOrdersMap().preload;
172
+
268
173
  if (!chunkMap || Object.keys(chunkMap).length === 0) {
269
174
  return source;
270
175
  }
271
- return _Template2.default.asString([source, '', '// chunk preloadng for javascript', '', 'var chunkPreloadMap = ' + JSON.stringify(chunkMap, null, '\t') + ';', '', 'var chunkPreloadData = chunkPreloadMap[chunkId];', 'if(chunkPreloadData) {', _Template2.default.indent(['chunkPreloadData.forEach(function(chunkId) {', _Template2.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template2.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']), '}']);
176
+
177
+ return _Template.default.asString([source, '', '// chunk preloadng for javascript', '', `var chunkPreloadMap = ${JSON.stringify(chunkMap, null, '\t')};`, '', 'var chunkPreloadData = chunkPreloadMap[chunkId];', 'if(chunkPreloadData) {', _Template.default.indent(['chunkPreloadData.forEach(function(chunkId) {', _Template.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPreload.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']), '}']);
272
178
  });
273
- mainTemplate.hooks.requireExtensions.tap('JsonpMainTemplatePlugin', function (source, chunk) {
179
+ mainTemplate.hooks.requireExtensions.tap('JsonpMainTemplatePlugin', (source, chunk) => {
274
180
  if (!needChunkOnDemandLoadingCode(chunk)) {
275
181
  return source;
276
182
  }
277
183
 
278
- return _Template2.default.asString([source, '', '// on error function for async loading', mainTemplate.requireFn + '.oe = function(err) { console.error(err); throw err; };']);
184
+ return _Template.default.asString([source, '', '// on error function for async loading', `${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };`]);
279
185
  });
280
- mainTemplate.hooks.bootstrap.tap('JsonpMainTemplatePlugin', function (source, chunk, hash) {
186
+ mainTemplate.hooks.bootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
281
187
  if (needChunkLoadingCode(chunk)) {
282
- var withDefer = needEntryDeferringCode(chunk);
283
- var withPrefetch = needPrefetchingCode(chunk);
284
- return _Template2.default.asString([source, '', '// install a JSONP callback for chunk loading', 'function webpackJsonpCallback(data) {', _Template2.default.indent(['var chunkIds = data[0];', 'var moreModules = data[1];', withDefer ? 'var executeModules = data[2];' : '', withPrefetch ? 'var prefetchChunks = data[3] || [];' : '', '// add "moreModules" to the modules object,', '// then flag all "chunkIds" as loaded and fire callback', 'var moduleId, chunkId, i = 0, resolves = [];', 'for(;i < chunkIds.length; i++) {', _Template2.default.indent(['chunkId = chunkIds[i];', 'if(installedChunks[chunkId]) {', _Template2.default.indent('resolves.push(installedChunks[chunkId][0]);'), '}', 'installedChunks[chunkId] = 0;']), '}', 'for(moduleId in moreModules) {', _Template2.default.indent(['if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {', _Template2.default.indent(mainTemplate.renderAddModule(hash, chunk, 'moduleId', 'moreModules[moduleId]')), '}']), '}', 'if(parentJsonpFunction) parentJsonpFunction(data);', withPrefetch ? _Template2.default.asString(['// chunk prefetching for javascript', 'prefetchChunks.forEach(function(chunkId) {', _Template2.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template2.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPrefetch.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']) : '', 'while(resolves.length) {', _Template2.default.indent('resolves.shift()();'), '}', withDefer ? _Template2.default.asString(['', '// add entry modules from loaded chunk to deferred list', 'deferredModules.push.apply(deferredModules, executeModules || []);', '', '// run deferred modules when all chunks ready', 'return checkDeferredModules();']) : '']), '};', withDefer ? _Template2.default.asString(['function checkDeferredModules() {', _Template2.default.indent(['var result;', 'for(var i = 0; i < deferredModules.length; i++) {', _Template2.default.indent(['var deferredModule = deferredModules[i];', 'var fulfilled = true;', 'for(var j = 1; j < deferredModule.length; j++) {', _Template2.default.indent(['var depId = deferredModule[j];', 'if(installedChunks[depId] !== 0) fulfilled = false;']), '}', 'if(fulfilled) {', _Template2.default.indent(['deferredModules.splice(i--, 1);', 'result = ' + mainTemplate.requireFn + '(' + mainTemplate.requireFn + '.s = deferredModule[0]);']), '}']), '}', 'return result;']), '}']) : '']);
188
+ const withDefer = needEntryDeferringCode(chunk);
189
+ const withPrefetch = needPrefetchingCode(chunk);
190
+ return _Template.default.asString([source, '', '// install a JSONP callback for chunk loading', 'function webpackJsonpCallback(data) {', _Template.default.indent(['var chunkIds = data[0];', 'var moreModules = data[1];', withDefer ? 'var executeModules = data[2];' : '', withPrefetch ? 'var prefetchChunks = data[3] || [];' : '', '// add "moreModules" to the modules object,', '// then flag all "chunkIds" as loaded and fire callback', 'var moduleId, chunkId, i = 0, resolves = [];', 'for(;i < chunkIds.length; i++) {', _Template.default.indent(['chunkId = chunkIds[i];', 'if(installedChunks[chunkId]) {', _Template.default.indent('resolves.push(installedChunks[chunkId][0]);'), '}', 'installedChunks[chunkId] = 0;']), '}', 'for(moduleId in moreModules) {', _Template.default.indent(['if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {', _Template.default.indent(mainTemplate.renderAddModule(hash, chunk, 'moduleId', 'moreModules[moduleId]')), '}']), '}', 'if(parentJsonpFunction) parentJsonpFunction(data);', withPrefetch ? _Template.default.asString(['// chunk prefetching for javascript', 'prefetchChunks.forEach(function(chunkId) {', _Template.default.indent(['if(installedChunks[chunkId] === undefined) {', _Template.default.indent(['installedChunks[chunkId] = null;', mainTemplate.hooks.linkPrefetch.call('', chunk, hash), 'window.ZDShadowRoot.getElementById("head").appendChild(link);']), '}']), '});']) : '', 'while(resolves.length) {', _Template.default.indent('resolves.shift()();'), '}', withDefer ? _Template.default.asString(['', '// add entry modules from loaded chunk to deferred list', 'deferredModules.push.apply(deferredModules, executeModules || []);', '', '// run deferred modules when all chunks ready', 'return checkDeferredModules();']) : '']), '};', withDefer ? _Template.default.asString(['function checkDeferredModules() {', _Template.default.indent(['var result;', 'for(var i = 0; i < deferredModules.length; i++) {', _Template.default.indent(['var deferredModule = deferredModules[i];', 'var fulfilled = true;', 'for(var j = 1; j < deferredModule.length; j++) {', _Template.default.indent(['var depId = deferredModule[j];', 'if(installedChunks[depId] !== 0) fulfilled = false;']), '}', 'if(fulfilled) {', _Template.default.indent(['deferredModules.splice(i--, 1);', `result = ${mainTemplate.requireFn}(${mainTemplate.requireFn}.s = deferredModule[0]);`]), '}']), '}', 'return result;']), '}']) : '']);
285
191
  }
192
+
286
193
  return source;
287
194
  });
288
- mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', function (source, chunk, hash) {
195
+ mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
289
196
  if (needChunkLoadingCode(chunk)) {
290
- var jsonpFunction = mainTemplate.outputOptions.jsonpFunction;
291
- var globalObject = mainTemplate.outputOptions.globalObject;
292
-
293
- return _Template2.default.asString(['var jsonpArray = ' + globalObject + '[' + JSON.stringify(jsonpFunction) + '] = ' + globalObject + '[' + JSON.stringify(jsonpFunction) + '] || [];', 'var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);', 'jsonpArray.push = webpackJsonpCallback;', 'jsonpArray = jsonpArray.slice();', 'for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);', 'var parentJsonpFunction = oldJsonpFunction;', '', source]);
197
+ let {
198
+ jsonpFunction
199
+ } = mainTemplate.outputOptions;
200
+ let {
201
+ globalObject
202
+ } = mainTemplate.outputOptions;
203
+ return _Template.default.asString([`var jsonpArray = ${globalObject}[${JSON.stringify(jsonpFunction)}] = ${globalObject}[${JSON.stringify(jsonpFunction)}] || [];`, 'var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);', 'jsonpArray.push = webpackJsonpCallback;', 'jsonpArray = jsonpArray.slice();', 'for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);', 'var parentJsonpFunction = oldJsonpFunction;', '', source]);
294
204
  }
205
+
295
206
  return source;
296
207
  });
297
- mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', function (source, chunk, hash) {
298
- var prefetchChunks = chunk.getChildIdsByOrders().prefetch;
208
+ mainTemplate.hooks.beforeStartup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
209
+ const prefetchChunks = chunk.getChildIdsByOrders().prefetch;
210
+
299
211
  if (needChunkLoadingCode(chunk) && prefetchChunks && prefetchChunks.length) {
300
- return _Template2.default.asString([source, 'webpackJsonpCallback([[], {}, 0, ' + JSON.stringify(prefetchChunks) + ']);']);
212
+ return _Template.default.asString([source, `webpackJsonpCallback([[], {}, 0, ${JSON.stringify(prefetchChunks)}]);`]);
301
213
  }
214
+
302
215
  return source;
303
216
  });
304
- mainTemplate.hooks.startup.tap('JsonpMainTemplatePlugin', function (source, chunk, hash) {
217
+ mainTemplate.hooks.startup.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
305
218
  if (needEntryDeferringCode(chunk)) {
306
219
  if (chunk.hasEntryModule()) {
307
- var entries = [chunk.entryModule].filter(Boolean).map(function (m) {
308
- return [m.id].concat(Array.from(chunk.groupsIterable)[0].chunks.filter(function (c) {
309
- return c !== chunk;
310
- }).map(function (c) {
311
- return c.id;
312
- }));
313
- });
314
- return _Template2.default.asString(['// add entry module to deferred list', 'deferredModules.push(' + entries.map(function (e) {
315
- return JSON.stringify(e);
316
- }).join(', ') + ');', '// run deferred modules when ready', 'return checkDeferredModules();']);
220
+ const entries = [chunk.entryModule].filter(Boolean).map(m => [m.id].concat(Array.from(chunk.groupsIterable)[0].chunks.filter(c => c !== chunk).map(c => c.id)));
221
+ return _Template.default.asString(['// add entry module to deferred list', `deferredModules.push(${entries.map(e => JSON.stringify(e)).join(', ')});`, '// run deferred modules when ready', 'return checkDeferredModules();']);
317
222
  }
318
- return _Template2.default.asString(['// run deferred modules from other chunks', 'checkDeferredModules();']);
223
+
224
+ return _Template.default.asString(['// run deferred modules from other chunks', 'checkDeferredModules();']);
319
225
  }
226
+
320
227
  return source;
321
228
  });
322
- mainTemplate.hooks.hotBootstrap.tap('JsonpMainTemplatePlugin', function (source, chunk, hash) {
323
- var globalObject = mainTemplate.outputOptions.globalObject;
324
- var hotUpdateChunkFilename = mainTemplate.outputOptions.hotUpdateChunkFilename;
325
- var hotUpdateMainFilename = mainTemplate.outputOptions.hotUpdateMainFilename;
326
- var crossOriginLoading = mainTemplate.outputOptions.crossOriginLoading;
327
- var hotUpdateFunction = mainTemplate.outputOptions.hotUpdateFunction;
328
-
329
- var currentHotUpdateChunkFilename = mainTemplate.getAssetPath(JSON.stringify(hotUpdateChunkFilename), {
330
- hash: '" + ' + mainTemplate.renderCurrentHashCode(hash) + ' + "',
331
- hashWithLength: function hashWithLength(length) {
332
- return '" + ' + mainTemplate.renderCurrentHashCode(hash, length) + ' + "';
333
- },
229
+ mainTemplate.hooks.hotBootstrap.tap('JsonpMainTemplatePlugin', (source, chunk, hash) => {
230
+ const {
231
+ globalObject
232
+ } = mainTemplate.outputOptions;
233
+ const {
234
+ hotUpdateChunkFilename
235
+ } = mainTemplate.outputOptions;
236
+ const {
237
+ hotUpdateMainFilename
238
+ } = mainTemplate.outputOptions;
239
+ const {
240
+ crossOriginLoading
241
+ } = mainTemplate.outputOptions;
242
+ const {
243
+ hotUpdateFunction
244
+ } = mainTemplate.outputOptions;
245
+ const currentHotUpdateChunkFilename = mainTemplate.getAssetPath(JSON.stringify(hotUpdateChunkFilename), {
246
+ hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
247
+ hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
334
248
  chunk: {
335
249
  id: '" + chunkId + "'
336
250
  }
337
251
  });
338
- var currentHotUpdateMainFilename = mainTemplate.getAssetPath(JSON.stringify(hotUpdateMainFilename), {
339
- hash: '" + ' + mainTemplate.renderCurrentHashCode(hash) + ' + "',
340
- hashWithLength: function hashWithLength(length) {
341
- return '" + ' + mainTemplate.renderCurrentHashCode(hash, length) + ' + "';
342
- }
252
+ const currentHotUpdateMainFilename = mainTemplate.getAssetPath(JSON.stringify(hotUpdateMainFilename), {
253
+ hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
254
+ hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
343
255
  });
344
- var runtimeSource = _Template2.default.getFunctionContent(require('./JsonpMainTemplate.runtime')).replace(/\/\/\$semicolon/g, ';').replace(/\$require\$/g, mainTemplate.requireFn).replace(/\$crossOriginLoading\$/g, crossOriginLoading ? JSON.stringify(crossOriginLoading) : 'null').replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename).replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename).replace(/\$hash\$/g, JSON.stringify(hash));
345
- return source + '\nfunction hotDisposeChunk(chunkId) {\n\tdelete installedChunks[chunkId];\n}\nvar parentHotUpdateCallback = ' + globalObject + '[' + JSON.stringify(hotUpdateFunction) + '];\n' + globalObject + '[' + JSON.stringify(hotUpdateFunction) + '] = ' + runtimeSource;
256
+
257
+ const runtimeSource = _Template.default.getFunctionContent(require('./JsonpMainTemplate.runtime')).replace(/\/\/\$semicolon/g, ';').replace(/\$require\$/g, mainTemplate.requireFn).replace(/\$crossOriginLoading\$/g, crossOriginLoading ? JSON.stringify(crossOriginLoading) : 'null').replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename).replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename).replace(/\$hash\$/g, JSON.stringify(hash));
258
+
259
+ return `${source}
260
+ function hotDisposeChunk(chunkId) {
261
+ delete installedChunks[chunkId];
262
+ }
263
+ var parentHotUpdateCallback = ${globalObject}[${JSON.stringify(hotUpdateFunction)}];
264
+ ${globalObject}[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
346
265
  });
347
- mainTemplate.hooks.hash.tap('JsonpMainTemplatePlugin', function (hash) {
266
+ mainTemplate.hooks.hash.tap('JsonpMainTemplatePlugin', hash => {
348
267
  hash.update('jsonp');
349
268
  hash.update('6');
350
269
  });
@@ -1,47 +1,35 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+ var _path = _interopRequireDefault(require("path"));
8
9
 
9
- var _path = require('path');
10
-
11
- var _path2 = _interopRequireDefault(_path);
12
-
13
- var _webpackSources = require('webpack-sources');
10
+ var _webpackSources = require("webpack-sources");
14
11
 
15
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
13
 
17
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
-
19
- var SourceMapHookPlugin = function () {
20
- function SourceMapHookPlugin() {
21
- _classCallCheck(this, SourceMapHookPlugin);
22
- }
14
+ class SourceMapHookPlugin {
15
+ apply(compiler) {
16
+ compiler.hooks.emit.tap('SourceMapHookPlugin', compilation => {
17
+ Object.keys(compilation.assets).forEach(filename => {
18
+ if (/\.js$/g.test(filename)) {
19
+ let source = compilation.assets[filename].source();
23
20
 
24
- _createClass(SourceMapHookPlugin, [{
25
- key: 'apply',
26
- value: function apply(compiler) {
27
- compiler.hooks.emit.tap('SourceMapHookPlugin', function (compilation) {
28
- Object.keys(compilation.assets).forEach(function (filename) {
29
- if (/\.js$/g.test(filename)) {
30
- var source = compilation.assets[filename].source();
21
+ let {
22
+ name
23
+ } = _path.default.parse(filename);
31
24
 
32
- var _path$parse = _path2.default.parse(filename),
33
- name = _path$parse.name;
34
-
35
- var src = source + '\n//# sourceMappingURL=../smap/' + name + '.map';
36
-
37
- compilation.assets[filename.replace(/js\//g, 'js-sm/')] = new _webpackSources.RawSource(src);
38
- }
39
- });
25
+ let src = `${source}\n//# sourceMappingURL=../smap/${name}.map`;
26
+ compilation.assets[filename.replace(/js\//g, 'js-sm/')] = new _webpackSources.RawSource(src);
27
+ }
40
28
  });
41
- }
42
- }]);
29
+ });
30
+ }
43
31
 
44
- return SourceMapHookPlugin;
45
- }();
32
+ }
46
33
 
47
- exports.default = SourceMapHookPlugin;
34
+ var _default = SourceMapHookPlugin;
35
+ exports.default = _default;