webpack 4.8.2 → 4.9.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 (57) hide show
  1. package/README.md +95 -52
  2. package/bin/webpack.js +128 -43
  3. package/lib/AmdMainTemplatePlugin.js +10 -0
  4. package/lib/AsyncDependencyToInitialChunkError.js +12 -2
  5. package/lib/BannerPlugin.js +115 -101
  6. package/lib/CaseSensitiveModulesWarning.js +20 -2
  7. package/lib/Chunk.js +1 -0
  8. package/lib/ChunkGroup.js +465 -465
  9. package/lib/ChunkRenderError.js +8 -0
  10. package/lib/ChunkTemplate.js +71 -71
  11. package/lib/Compilation.js +1 -1
  12. package/lib/Compiler.js +2 -1
  13. package/lib/ContextModule.js +8 -8
  14. package/lib/DllPlugin.js +3 -1
  15. package/lib/DllReferencePlugin.js +2 -1
  16. package/lib/Entrypoint.js +54 -54
  17. package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +115 -115
  18. package/lib/ExportPropertyMainTemplatePlugin.js +13 -0
  19. package/lib/Generator.js +52 -52
  20. package/lib/HotModuleReplacement.runtime.js +633 -633
  21. package/lib/JsonParser.js +2 -1
  22. package/lib/LibManifestPlugin.js +9 -0
  23. package/lib/LibraryTemplatePlugin.js +66 -33
  24. package/lib/MainTemplate.js +468 -468
  25. package/lib/Module.js +3 -3
  26. package/lib/ModuleDependencyError.js +12 -2
  27. package/lib/NormalModuleFactory.js +5 -3
  28. package/lib/Parser.js +27 -23
  29. package/lib/ProgressPlugin.js +1 -1
  30. package/lib/RecordIdsPlugin.js +3 -1
  31. package/lib/RuntimeTemplate.js +1 -1
  32. package/lib/SetVarMainTemplatePlugin.js +12 -0
  33. package/lib/SourceMapDevToolPlugin.js +11 -13
  34. package/lib/Template.js +289 -290
  35. package/lib/UmdMainTemplatePlugin.js +67 -32
  36. package/lib/WebpackError.js +8 -2
  37. package/lib/compareLocations.js +20 -0
  38. package/lib/debug/ProfilingPlugin.js +416 -416
  39. package/lib/dependencies/ContextDependencyHelpers.js +142 -142
  40. package/lib/dependencies/WebpackMissingModule.js +2 -2
  41. package/lib/optimize/RemoveEmptyChunksPlugin.js +42 -40
  42. package/lib/optimize/RuntimeChunkPlugin.js +9 -5
  43. package/lib/optimize/SplitChunksPlugin.js +195 -124
  44. package/lib/util/Queue.js +46 -46
  45. package/lib/util/SetHelpers.js +48 -48
  46. package/lib/util/SortableSet.js +106 -106
  47. package/lib/util/StackedSetMap.js +128 -128
  48. package/lib/util/cachedMerge.js +13 -0
  49. package/lib/util/identifier.js +5 -0
  50. package/lib/util/objectToMap.js +16 -16
  51. package/lib/wasm/WebAssemblyGenerator.js +280 -280
  52. package/lib/wasm/WebAssemblyParser.js +79 -79
  53. package/lib/web/JsonpMainTemplatePlugin.js +2 -2
  54. package/package.json +21 -17
  55. package/schemas/WebpackOptions.json +12 -1
  56. package/schemas/plugins/BannerPlugin.json +96 -85
  57. package/schemas/plugins/DllPlugin.json +4 -0
package/lib/Template.js CHANGED
@@ -1,290 +1,289 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
- /** @typedef {import("./Module")} Module */
6
- /** @typedef {import("./Chunk")} Chunk */
7
- /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
8
- /** @typedef {import("webpack-sources").ConcatSource} ConcatSource */
9
-
10
- const { ConcatSource } = require("webpack-sources");
11
- const HotUpdateChunk = require("./HotUpdateChunk");
12
-
13
- const START_LOWERCASE_ALPHABET_CODE = "a".charCodeAt(0);
14
- const START_UPPERCASE_ALPHABET_CODE = "A".charCodeAt(0);
15
- const DELTA_A_TO_Z = "z".charCodeAt(0) - START_LOWERCASE_ALPHABET_CODE + 1;
16
- const FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g;
17
- const INDENT_MULTILINE_REGEX = /^\t/gm;
18
- const LINE_SEPARATOR_REGEX = /\r?\n/g;
19
- const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/;
20
- const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g;
21
- const COMMENT_END_REGEX = /\*\//g;
22
- const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
23
- const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
24
-
25
- /**
26
- * @typedef {Object} HasId
27
- * @property {number} id
28
- * */
29
-
30
- /**
31
- * @typedef {(m: Module, idx: number) => boolean} ModuleFilterPredicate
32
- */
33
-
34
- /**
35
- * @param {HasId} a first id object to be sorted
36
- * @param {HasId} b second id object to be sorted against
37
- * @returns {-1|0|1} the sort value
38
- */
39
- const stringifyIdSortPredicate = (a, b) => {
40
- var aId = a.id + "";
41
- var bId = b.id + "";
42
- if (aId < bId) return -1;
43
- if (aId > bId) return 1;
44
- return 0;
45
- };
46
-
47
- //TODO: Change type to Module when import works
48
- //https://github.com/Microsoft/TypeScript/issues/23375
49
- /**
50
- * @param {HasId} module the module to compare against
51
- * @returns {boolean} return true if module.id is equal to type "number"
52
- */
53
- const moduleIdIsNumber = module => {
54
- return typeof module.id === "number";
55
- };
56
-
57
- class Template {
58
- /**
59
- *
60
- * @param {Function} fn - a runtime function (.runtime.js) "template"
61
- * @returns {string} the updated and normalized function string
62
- */
63
- static getFunctionContent(fn) {
64
- return fn
65
- .toString()
66
- .replace(FUNCTION_CONTENT_REGEX, "")
67
- .replace(INDENT_MULTILINE_REGEX, "")
68
- .replace(LINE_SEPARATOR_REGEX, "\n");
69
- }
70
- /**
71
- * @param {string} str the string converted to identifier
72
- * @returns {string} created identifier
73
- */
74
- static toIdentifier(str) {
75
- if (typeof str !== "string") return "";
76
- return str
77
- .replace(IDENTIFIER_NAME_REPLACE_REGEX, "_$1")
78
- .replace(IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX, "_");
79
- }
80
- /**
81
- *
82
- * @param {string} str string to be converted to commented in bundle code
83
- * @returns {string} returns a commented version of string
84
- */
85
- static toComment(str) {
86
- if (!str) return "";
87
- return `/*! ${str.replace(COMMENT_END_REGEX, "* /")} */`;
88
- }
89
-
90
- /**
91
- *
92
- * @param {string} str string to be converted to "normal comment"
93
- * @returns {string} returns a commented version of string
94
- */
95
- static toNormalComment(str) {
96
- if (!str) return "";
97
- return `/* ${str.replace(COMMENT_END_REGEX, "* /")} */`;
98
- }
99
-
100
- /**
101
- * @param {string} str string path to be normalized
102
- * @returns {string} normalized bundle-safe path
103
- */
104
- static toPath(str) {
105
- if (typeof str !== "string") return "";
106
- return str
107
- .replace(PATH_NAME_NORMALIZE_REPLACE_REGEX, "-")
108
- .replace(MATCH_PADDED_HYPHENS_REPLACE_REGEX, "");
109
- }
110
-
111
- // map number to a single character a-z, A-Z or <_ + number> if number is too big
112
- /**
113
- *
114
- * @param {number} n number to convert to ident
115
- * @returns {string} returns single character ident
116
- */
117
- static numberToIdentifer(n) {
118
- // lower case
119
- if (n < DELTA_A_TO_Z)
120
- return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
121
-
122
- // upper case
123
- n -= DELTA_A_TO_Z;
124
- if (n < DELTA_A_TO_Z)
125
- return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
126
-
127
- // use multiple letters
128
- return (
129
- Template.numberToIdentifer(n % (2 * DELTA_A_TO_Z)) +
130
- Template.numberToIdentifer(Math.floor(n / (2 * DELTA_A_TO_Z)))
131
- );
132
- }
133
-
134
- /**
135
- *
136
- * @param {string | string[]} str string to convert to identity
137
- * @returns {string} converted identity
138
- */
139
- static indent(str) {
140
- if (Array.isArray(str)) {
141
- return str.map(Template.indent).join("\n");
142
- } else {
143
- str = str.trimRight();
144
- if (!str) return "";
145
- var ind = str[0] === "\n" ? "" : "\t";
146
- return ind + str.replace(/\n([^\n])/g, "\n\t$1");
147
- }
148
- }
149
-
150
- /**
151
- *
152
- * @param {string|string[]} str string to create prefix for
153
- * @param {string} prefix prefix to compose
154
- * @returns {string} returns new prefix string
155
- */
156
- static prefix(str, prefix) {
157
- if (Array.isArray(str)) {
158
- str = str.join("\n");
159
- }
160
- str = str.trim();
161
- if (!str) return "";
162
- const ind = str[0] === "\n" ? "" : prefix;
163
- return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
164
- }
165
-
166
- /**
167
- *
168
- * @param {string|string[]} str string or string collection
169
- * @returns {string} returns a single string from array
170
- */
171
- static asString(str) {
172
- if (Array.isArray(str)) {
173
- return str.join("\n");
174
- }
175
- return str;
176
- }
177
-
178
- /**
179
- *
180
- * @param {HasId[]} modules - a collection of modules to get array bounds for
181
- * @returns {[number, number] | false} returns the upper and lower array bounds
182
- * or false if not every module has a number based id
183
- */
184
- static getModulesArrayBounds(modules) {
185
- if (!modules.every(moduleIdIsNumber)) return false;
186
- var maxId = -Infinity;
187
- var minId = Infinity;
188
- for (const module of modules) {
189
- if (maxId < module.id) maxId = module.id;
190
- if (minId > module.id) minId = module.id;
191
- }
192
- if (minId < 16 + ("" + minId).length) {
193
- // add minId x ',' instead of 'Array(minId).concat(…)'
194
- minId = 0;
195
- }
196
- var objectOverhead = modules
197
- .map(module => {
198
- var idLength = (module.id + "").length;
199
- return idLength + 2;
200
- })
201
- .reduce((a, b) => {
202
- return a + b;
203
- }, -1);
204
- var arrayOverhead = minId === 0 ? maxId : 16 + ("" + minId).length + maxId;
205
- return arrayOverhead < objectOverhead ? [minId, maxId] : false;
206
- }
207
-
208
- /**
209
- *
210
- * @param {Chunk} chunk chunk whose modules will be rendered
211
- * @param {ModuleFilterPredicate} filterFn function used to filter modules from chunk to render
212
- * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance used to render modules
213
- * @param {TODO | TODO[]} dependencyTemplates templates needed for each module to render dependencies
214
- * @param {string=} prefix applying prefix strings
215
- * @returns {ConcatSource} rendered chunk modules in a Source object
216
- */
217
- static renderChunkModules(
218
- chunk,
219
- filterFn,
220
- moduleTemplate,
221
- dependencyTemplates,
222
- prefix
223
- ) {
224
- if (!prefix) prefix = "";
225
- var source = new ConcatSource();
226
- const modules = chunk.getModules().filter(filterFn);
227
- if (chunk instanceof HotUpdateChunk) {
228
- var removedModules = chunk.removedModules;
229
- }
230
- if (
231
- modules.length === 0 &&
232
- (!removedModules || removedModules.length === 0)
233
- ) {
234
- source.add("[]");
235
- return source;
236
- }
237
- var allModules = modules.map(module => {
238
- return {
239
- id: module.id,
240
- source: moduleTemplate.render(module, dependencyTemplates, {
241
- chunk
242
- })
243
- };
244
- });
245
- if (removedModules && removedModules.length > 0) {
246
- for (const id of removedModules) {
247
- allModules.push({
248
- id: id,
249
- source: "false"
250
- });
251
- }
252
- }
253
- var bounds = Template.getModulesArrayBounds(allModules);
254
-
255
- if (bounds) {
256
- // Render a spare array
257
- var minId = bounds[0];
258
- var maxId = bounds[1];
259
- if (minId !== 0) source.add("Array(" + minId + ").concat(");
260
- source.add("[\n");
261
- const modules = new Map();
262
- for (const module of allModules) {
263
- modules.set(module.id, module);
264
- }
265
- for (var idx = minId; idx <= maxId; idx++) {
266
- var module = modules.get(idx);
267
- if (idx !== minId) source.add(",\n");
268
- source.add("/* " + idx + " */");
269
- if (module) {
270
- source.add("\n");
271
- source.add(module.source);
272
- }
273
- }
274
- source.add("\n" + prefix + "]");
275
- if (minId !== 0) source.add(")");
276
- } else {
277
- // Render an object
278
- source.add("{\n");
279
- allModules.sort(stringifyIdSortPredicate).forEach((module, idx) => {
280
- if (idx !== 0) source.add(",\n");
281
- source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`);
282
- source.add(module.source);
283
- });
284
- source.add("\n\n" + prefix + "}");
285
- }
286
- return source;
287
- }
288
- }
289
-
290
- module.exports = Template;
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ /** @typedef {import("./Module")} Module */
6
+ /** @typedef {import("./Chunk")} Chunk */
7
+ /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
8
+ /** @typedef {import("webpack-sources").ConcatSource} ConcatSource */
9
+
10
+ const { ConcatSource } = require("webpack-sources");
11
+ const HotUpdateChunk = require("./HotUpdateChunk");
12
+
13
+ const START_LOWERCASE_ALPHABET_CODE = "a".charCodeAt(0);
14
+ const START_UPPERCASE_ALPHABET_CODE = "A".charCodeAt(0);
15
+ const DELTA_A_TO_Z = "z".charCodeAt(0) - START_LOWERCASE_ALPHABET_CODE + 1;
16
+ const FUNCTION_CONTENT_REGEX = /^function\s?\(\)\s?\{\r?\n?|\r?\n?\}$/g;
17
+ const INDENT_MULTILINE_REGEX = /^\t/gm;
18
+ const LINE_SEPARATOR_REGEX = /\r?\n/g;
19
+ const IDENTIFIER_NAME_REPLACE_REGEX = /^([^a-zA-Z$_])/;
20
+ const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g;
21
+ const COMMENT_END_REGEX = /\*\//g;
22
+ const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
23
+ const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
24
+
25
+ /**
26
+ * @typedef {Object} HasId
27
+ * @property {number} id
28
+ * */
29
+
30
+ /**
31
+ * @typedef {(m: Module, idx: number) => boolean} ModuleFilterPredicate
32
+ */
33
+
34
+ /**
35
+ * @param {HasId} a first id object to be sorted
36
+ * @param {HasId} b second id object to be sorted against
37
+ * @returns {-1|0|1} the sort value
38
+ */
39
+ const stringifyIdSortPredicate = (a, b) => {
40
+ var aId = a.id + "";
41
+ var bId = b.id + "";
42
+ if (aId < bId) return -1;
43
+ if (aId > bId) return 1;
44
+ return 0;
45
+ };
46
+
47
+ /**
48
+ * @param {Module} module the module to compare against
49
+ * @returns {boolean} return true if module.id is equal to type "number"
50
+ */
51
+ const moduleIdIsNumber = module => {
52
+ return typeof module.id === "number";
53
+ };
54
+
55
+ class Template {
56
+ /**
57
+ *
58
+ * @param {Function} fn - a runtime function (.runtime.js) "template"
59
+ * @returns {string} the updated and normalized function string
60
+ */
61
+ static getFunctionContent(fn) {
62
+ return fn
63
+ .toString()
64
+ .replace(FUNCTION_CONTENT_REGEX, "")
65
+ .replace(INDENT_MULTILINE_REGEX, "")
66
+ .replace(LINE_SEPARATOR_REGEX, "\n");
67
+ }
68
+ /**
69
+ * @param {string} str the string converted to identifier
70
+ * @returns {string} created identifier
71
+ */
72
+ static toIdentifier(str) {
73
+ if (typeof str !== "string") return "";
74
+ return str
75
+ .replace(IDENTIFIER_NAME_REPLACE_REGEX, "_$1")
76
+ .replace(IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX, "_");
77
+ }
78
+ /**
79
+ *
80
+ * @param {string} str string to be converted to commented in bundle code
81
+ * @returns {string} returns a commented version of string
82
+ */
83
+ static toComment(str) {
84
+ if (!str) return "";
85
+ return `/*! ${str.replace(COMMENT_END_REGEX, "* /")} */`;
86
+ }
87
+
88
+ /**
89
+ *
90
+ * @param {string} str string to be converted to "normal comment"
91
+ * @returns {string} returns a commented version of string
92
+ */
93
+ static toNormalComment(str) {
94
+ if (!str) return "";
95
+ return `/* ${str.replace(COMMENT_END_REGEX, "* /")} */`;
96
+ }
97
+
98
+ /**
99
+ * @param {string} str string path to be normalized
100
+ * @returns {string} normalized bundle-safe path
101
+ */
102
+ static toPath(str) {
103
+ if (typeof str !== "string") return "";
104
+ return str
105
+ .replace(PATH_NAME_NORMALIZE_REPLACE_REGEX, "-")
106
+ .replace(MATCH_PADDED_HYPHENS_REPLACE_REGEX, "");
107
+ }
108
+
109
+ // map number to a single character a-z, A-Z or <_ + number> if number is too big
110
+ /**
111
+ *
112
+ * @param {number} n number to convert to ident
113
+ * @returns {string} returns single character ident
114
+ */
115
+ static numberToIdentifer(n) {
116
+ // lower case
117
+ if (n < DELTA_A_TO_Z)
118
+ return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
119
+
120
+ // upper case
121
+ n -= DELTA_A_TO_Z;
122
+ if (n < DELTA_A_TO_Z)
123
+ return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
124
+
125
+ // use multiple letters
126
+ return (
127
+ Template.numberToIdentifer(n % (2 * DELTA_A_TO_Z)) +
128
+ Template.numberToIdentifer(Math.floor(n / (2 * DELTA_A_TO_Z)))
129
+ );
130
+ }
131
+
132
+ /**
133
+ *
134
+ * @param {string | string[]} str string to convert to identity
135
+ * @returns {string} converted identity
136
+ */
137
+ static indent(str) {
138
+ if (Array.isArray(str)) {
139
+ return str.map(Template.indent).join("\n");
140
+ } else {
141
+ str = str.trimRight();
142
+ if (!str) return "";
143
+ var ind = str[0] === "\n" ? "" : "\t";
144
+ return ind + str.replace(/\n([^\n])/g, "\n\t$1");
145
+ }
146
+ }
147
+
148
+ /**
149
+ *
150
+ * @param {string|string[]} str string to create prefix for
151
+ * @param {string} prefix prefix to compose
152
+ * @returns {string} returns new prefix string
153
+ */
154
+ static prefix(str, prefix) {
155
+ if (Array.isArray(str)) {
156
+ str = str.join("\n");
157
+ }
158
+ str = str.trim();
159
+ if (!str) return "";
160
+ const ind = str[0] === "\n" ? "" : prefix;
161
+ return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
162
+ }
163
+
164
+ /**
165
+ *
166
+ * @param {string|string[]} str string or string collection
167
+ * @returns {string} returns a single string from array
168
+ */
169
+ static asString(str) {
170
+ if (Array.isArray(str)) {
171
+ return str.join("\n");
172
+ }
173
+ return str;
174
+ }
175
+
176
+ /**
177
+ *
178
+ * @param {Module[]} modules a collection of modules to get array bounds for
179
+ * @returns {[number, number] | false} returns the upper and lower array bounds
180
+ * or false if not every module has a number based id
181
+ */
182
+ static getModulesArrayBounds(modules) {
183
+ // Typeguards don't work for .every() with predicate functions
184
+ // https://github.com/Microsoft/TypeScript/issues/23799
185
+ if (!modules.every(moduleIdIsNumber)) return false;
186
+ var maxId = -Infinity;
187
+ var minId = Infinity;
188
+ for (const module of modules) {
189
+ if (maxId < module.id) maxId = /** @type {number} */ (module.id);
190
+ if (minId > module.id) minId = /** @type {number} */ (module.id);
191
+ }
192
+ if (minId < 16 + ("" + minId).length) {
193
+ // add minId x ',' instead of 'Array(minId).concat(…)'
194
+ minId = 0;
195
+ }
196
+ var objectOverhead = modules
197
+ .map(module => {
198
+ var idLength = (module.id + "").length;
199
+ return idLength + 2;
200
+ })
201
+ .reduce((a, b) => {
202
+ return a + b;
203
+ }, -1);
204
+ var arrayOverhead = minId === 0 ? maxId : 16 + ("" + minId).length + maxId;
205
+ return arrayOverhead < objectOverhead ? [minId, maxId] : false;
206
+ }
207
+
208
+ /**
209
+ * @param {Chunk} chunk chunk whose modules will be rendered
210
+ * @param {ModuleFilterPredicate} filterFn function used to filter modules from chunk to render
211
+ * @param {ModuleTemplate} moduleTemplate ModuleTemplate instance used to render modules
212
+ * @param {TODO | TODO[]} dependencyTemplates templates needed for each module to render dependencies
213
+ * @param {string=} prefix applying prefix strings
214
+ * @returns {ConcatSource} rendered chunk modules in a Source object
215
+ */
216
+ static renderChunkModules(
217
+ chunk,
218
+ filterFn,
219
+ moduleTemplate,
220
+ dependencyTemplates,
221
+ prefix
222
+ ) {
223
+ if (!prefix) prefix = "";
224
+ var source = new ConcatSource();
225
+ const modules = chunk.getModules().filter(filterFn);
226
+ if (chunk instanceof HotUpdateChunk) {
227
+ var removedModules = chunk.removedModules;
228
+ }
229
+ if (
230
+ modules.length === 0 &&
231
+ (!removedModules || removedModules.length === 0)
232
+ ) {
233
+ source.add("[]");
234
+ return source;
235
+ }
236
+ var allModules = modules.map(module => {
237
+ return {
238
+ id: module.id,
239
+ source: moduleTemplate.render(module, dependencyTemplates, {
240
+ chunk
241
+ })
242
+ };
243
+ });
244
+ if (removedModules && removedModules.length > 0) {
245
+ for (const id of removedModules) {
246
+ allModules.push({
247
+ id: id,
248
+ source: "false"
249
+ });
250
+ }
251
+ }
252
+ var bounds = Template.getModulesArrayBounds(allModules);
253
+
254
+ if (bounds) {
255
+ // Render a spare array
256
+ var minId = bounds[0];
257
+ var maxId = bounds[1];
258
+ if (minId !== 0) source.add("Array(" + minId + ").concat(");
259
+ source.add("[\n");
260
+ const modules = new Map();
261
+ for (const module of allModules) {
262
+ modules.set(module.id, module);
263
+ }
264
+ for (var idx = minId; idx <= maxId; idx++) {
265
+ var module = modules.get(idx);
266
+ if (idx !== minId) source.add(",\n");
267
+ source.add("/* " + idx + " */");
268
+ if (module) {
269
+ source.add("\n");
270
+ source.add(module.source);
271
+ }
272
+ }
273
+ source.add("\n" + prefix + "]");
274
+ if (minId !== 0) source.add(")");
275
+ } else {
276
+ // Render an object
277
+ source.add("{\n");
278
+ allModules.sort(stringifyIdSortPredicate).forEach((module, idx) => {
279
+ if (idx !== 0) source.add(",\n");
280
+ source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`);
281
+ source.add(module.source);
282
+ });
283
+ source.add("\n\n" + prefix + "}");
284
+ }
285
+ return source;
286
+ }
287
+ }
288
+
289
+ module.exports = Template;