webpack 5.69.1 → 5.72.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (84) hide show
  1. package/hot/poll.js +1 -1
  2. package/hot/signal.js +1 -1
  3. package/lib/BannerPlugin.js +12 -4
  4. package/lib/Chunk.js +1 -1
  5. package/lib/ChunkGraph.js +93 -6
  6. package/lib/ChunkGroup.js +1 -1
  7. package/lib/CleanPlugin.js +64 -18
  8. package/lib/Compilation.js +51 -25
  9. package/lib/Compiler.js +16 -3
  10. package/lib/ConstPlugin.js +2 -2
  11. package/lib/ContextModule.js +121 -34
  12. package/lib/ContextModuleFactory.js +65 -25
  13. package/lib/DelegatedModuleFactoryPlugin.js +1 -1
  14. package/lib/Dependency.js +7 -0
  15. package/lib/EntryOptionPlugin.js +1 -0
  16. package/lib/ErrorHelpers.js +2 -2
  17. package/lib/ExportsInfo.js +1 -1
  18. package/lib/ExternalModuleFactoryPlugin.js +4 -4
  19. package/lib/FileSystemInfo.js +8 -0
  20. package/lib/Generator.js +1 -0
  21. package/lib/LoaderOptionsPlugin.js +1 -1
  22. package/lib/Module.js +3 -0
  23. package/lib/ModuleFilenameHelpers.js +3 -3
  24. package/lib/ModuleHashingError.js +29 -0
  25. package/lib/NodeStuffPlugin.js +10 -0
  26. package/lib/NormalModule.js +26 -20
  27. package/lib/NormalModuleFactory.js +17 -10
  28. package/lib/ProgressPlugin.js +3 -4
  29. package/lib/RuntimePlugin.js +18 -0
  30. package/lib/RuntimeTemplate.js +1 -0
  31. package/lib/WebpackOptionsApply.js +2 -0
  32. package/lib/asset/AssetGenerator.js +155 -40
  33. package/lib/asset/AssetParser.js +1 -0
  34. package/lib/asset/AssetSourceGenerator.js +31 -6
  35. package/lib/asset/AssetSourceParser.js +1 -0
  36. package/lib/cache/PackFileCacheStrategy.js +8 -4
  37. package/lib/cache/ResolverCachePlugin.js +89 -28
  38. package/lib/config/browserslistTargetHandler.js +3 -5
  39. package/lib/config/defaults.js +9 -1
  40. package/lib/config/normalization.js +1 -0
  41. package/lib/container/RemoteRuntimeModule.js +8 -7
  42. package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -2
  43. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  44. package/lib/dependencies/ContextElementDependency.js +33 -1
  45. package/lib/dependencies/HarmonyAcceptImportDependency.js +5 -3
  46. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +95 -0
  47. package/lib/dependencies/HarmonyExportInitFragment.js +4 -1
  48. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +127 -43
  49. package/lib/dependencies/HarmonyImportSpecifierDependency.js +22 -8
  50. package/lib/dependencies/HarmonyModulesPlugin.js +10 -0
  51. package/lib/dependencies/ImportContextDependency.js +0 -2
  52. package/lib/dependencies/ImportMetaContextDependency.js +35 -0
  53. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +252 -0
  54. package/lib/dependencies/ImportMetaContextPlugin.js +59 -0
  55. package/lib/dependencies/LoaderPlugin.js +2 -0
  56. package/lib/dependencies/RequireContextDependency.js +0 -16
  57. package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
  58. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +24 -8
  59. package/lib/hmr/HotModuleReplacement.runtime.js +29 -14
  60. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +4 -3
  61. package/lib/ids/HashedModuleIdsPlugin.js +2 -2
  62. package/lib/ids/IdHelpers.js +1 -1
  63. package/lib/javascript/BasicEvaluatedExpression.js +5 -2
  64. package/lib/javascript/JavascriptParser.js +66 -40
  65. package/lib/library/UmdLibraryPlugin.js +5 -3
  66. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -7
  67. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -7
  68. package/lib/optimize/ConcatenatedModule.js +2 -1
  69. package/lib/optimize/ModuleConcatenationPlugin.js +20 -1
  70. package/lib/runtime/BaseUriRuntimeModule.js +31 -0
  71. package/lib/schemes/HttpUriPlugin.js +44 -3
  72. package/lib/stats/DefaultStatsFactoryPlugin.js +1 -1
  73. package/lib/util/internalSerializables.js +4 -0
  74. package/lib/web/JsonpChunkLoadingRuntimeModule.js +17 -6
  75. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +30 -20
  76. package/module.d.ts +15 -0
  77. package/package.json +2 -2
  78. package/schemas/WebpackOptions.check.js +1 -1
  79. package/schemas/WebpackOptions.json +17 -1
  80. package/schemas/plugins/BannerPlugin.check.js +1 -1
  81. package/schemas/plugins/BannerPlugin.json +4 -0
  82. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  83. package/schemas/plugins/schemes/HttpUriPlugin.json +4 -0
  84. package/types.d.ts +202 -84
@@ -128,6 +128,13 @@ class ResolverCachePlugin {
128
128
  fileDependencies: new LazySet(),
129
129
  contextDependencies: new LazySet()
130
130
  };
131
+ let yieldResult;
132
+ let withYield = false;
133
+ if (typeof newResolveContext.yield === "function") {
134
+ yieldResult = [];
135
+ withYield = true;
136
+ newResolveContext.yield = obj => yieldResult.push(obj);
137
+ }
131
138
  const propagate = key => {
132
139
  if (resolveContext[key]) {
133
140
  addAllToSet(resolveContext[key], newResolveContext[key]);
@@ -155,15 +162,22 @@ class ResolverCachePlugin {
155
162
  snapshotOptions,
156
163
  (err, snapshot) => {
157
164
  if (err) return callback(err);
165
+ const resolveResult = withYield ? yieldResult : result;
166
+ // since we intercept resolve hook
167
+ // we still can get result in callback
168
+ if (withYield && result) yieldResult.push(result);
158
169
  if (!snapshot) {
159
- if (result) return callback(null, result);
170
+ if (resolveResult) return callback(null, resolveResult);
160
171
  return callback();
161
172
  }
162
- itemCache.store(new CacheEntry(result, snapshot), storeErr => {
163
- if (storeErr) return callback(storeErr);
164
- if (result) return callback(null, result);
165
- callback();
166
- });
173
+ itemCache.store(
174
+ new CacheEntry(resolveResult, snapshot),
175
+ storeErr => {
176
+ if (storeErr) return callback(storeErr);
177
+ if (resolveResult) return callback(null, resolveResult);
178
+ callback();
179
+ }
180
+ );
167
181
  }
168
182
  );
169
183
  }
@@ -173,6 +187,8 @@ class ResolverCachePlugin {
173
187
  factory(type, hook) {
174
188
  /** @type {Map<string, (function(Error=, Object=): void)[]>} */
175
189
  const activeRequests = new Map();
190
+ /** @type {Map<string, [function(Error=, Object=): void, function(Error=, Object=): void][]>} */
191
+ const activeRequestsWithYield = new Map();
176
192
  hook.tap(
177
193
  "ResolverCachePlugin",
178
194
  /**
@@ -197,29 +213,67 @@ class ResolverCachePlugin {
197
213
  if (request._ResolverCachePluginCacheMiss || !fileSystemInfo) {
198
214
  return callback();
199
215
  }
200
- const identifier = `${type}${optionsIdent}${objectToString(
201
- request,
202
- !cacheWithContext
203
- )}`;
204
- const activeRequest = activeRequests.get(identifier);
205
- if (activeRequest) {
206
- activeRequest.push(callback);
207
- return;
216
+ const withYield = typeof resolveContext.yield === "function";
217
+ const identifier = `${type}${
218
+ withYield ? "|yield" : "|default"
219
+ }${optionsIdent}${objectToString(request, !cacheWithContext)}`;
220
+
221
+ if (withYield) {
222
+ const activeRequest = activeRequestsWithYield.get(identifier);
223
+ if (activeRequest) {
224
+ activeRequest[0].push(callback);
225
+ activeRequest[1].push(resolveContext.yield);
226
+ return;
227
+ }
228
+ } else {
229
+ const activeRequest = activeRequests.get(identifier);
230
+ if (activeRequest) {
231
+ activeRequest.push(callback);
232
+ return;
233
+ }
208
234
  }
209
235
  const itemCache = cache.getItemCache(identifier, null);
210
- let callbacks;
211
- const done = (err, result) => {
212
- if (callbacks === undefined) {
213
- callback(err, result);
214
- callbacks = false;
215
- } else {
216
- for (const callback of callbacks) {
217
- callback(err, result);
218
- }
219
- activeRequests.delete(identifier);
220
- callbacks = false;
221
- }
222
- };
236
+ let callbacks, yields;
237
+ const done = withYield
238
+ ? (err, result) => {
239
+ if (callbacks === undefined) {
240
+ if (err) {
241
+ callback(err);
242
+ } else {
243
+ if (result)
244
+ for (const r of result) resolveContext.yield(r);
245
+ callback(null, null);
246
+ }
247
+ yields = undefined;
248
+ callbacks = false;
249
+ } else {
250
+ if (err) {
251
+ for (const cb of callbacks) cb(err);
252
+ } else {
253
+ for (let i = 0; i < callbacks.length; i++) {
254
+ const cb = callbacks[i];
255
+ const yield_ = yields[i];
256
+ if (result) for (const r of result) yield_(r);
257
+ cb(null, null);
258
+ }
259
+ }
260
+ activeRequestsWithYield.delete(identifier);
261
+ yields = undefined;
262
+ callbacks = false;
263
+ }
264
+ }
265
+ : (err, result) => {
266
+ if (callbacks === undefined) {
267
+ callback(err, result);
268
+ callbacks = false;
269
+ } else {
270
+ for (const callback of callbacks) {
271
+ callback(err, result);
272
+ }
273
+ activeRequests.delete(identifier);
274
+ callbacks = false;
275
+ }
276
+ };
223
277
  /**
224
278
  * @param {Error=} err error if any
225
279
  * @param {CacheEntry=} cacheEntry cache entry
@@ -276,7 +330,14 @@ class ResolverCachePlugin {
276
330
  }
277
331
  };
278
332
  itemCache.get(processCacheResult);
279
- if (callbacks === undefined) {
333
+ if (withYield && callbacks === undefined) {
334
+ callbacks = [callback];
335
+ yields = [resolveContext.yield];
336
+ activeRequestsWithYield.set(
337
+ identifier,
338
+ /** @type {[any, any]} */ ([callbacks, yields])
339
+ );
340
+ } else if (callbacks === undefined) {
280
341
  callbacks = [callback];
281
342
  activeRequests.set(identifier, callbacks);
282
343
  }
@@ -121,8 +121,7 @@ const resolve = browsers => {
121
121
  // baidu: Not supported
122
122
  // and_uc: Not supported
123
123
  // kaios: Not supported
124
- // Since Node.js 13.14.0 no warning about usage, but it was added 8.5.0 with some limitations and it was improved in 12.0.0 and 13.2.0
125
- node: [13, 14]
124
+ node: [12, 17]
126
125
  });
127
126
 
128
127
  return {
@@ -248,8 +247,7 @@ const resolve = browsers => {
248
247
  // baidu: Not supported
249
248
  // and_uc: Not supported
250
249
  // kaios: Not supported
251
- // Since Node.js 13.14.0 no warning about usage, but it was added 8.5.0 with some limitations and it was improved in 12.0.0 and 13.2.0
252
- node: [13, 14]
250
+ node: [12, 17]
253
251
  }),
254
252
  dynamicImport: es6DynamicImport,
255
253
  dynamicImportInWorker: es6DynamicImport && !anyNode,
@@ -272,7 +270,7 @@ const resolve = browsers => {
272
270
  // baidu: Unknown support
273
271
  // and_uc: Unknown support
274
272
  // kaios: Unknown support
275
- node: [12, 0]
273
+ node: 12
276
274
  }),
277
275
  optionalChaining: rawChecker({
278
276
  chrome: 80,
@@ -715,7 +715,15 @@ const applyOutputDefaults = (
715
715
  };
716
716
 
717
717
  F(output, "uniqueName", () => {
718
- const libraryName = getLibraryName(output.library);
718
+ const libraryName = getLibraryName(output.library).replace(
719
+ /^\[(\\*[\w:]+\\*)\](\.)|(\.)\[(\\*[\w:]+\\*)\](?=\.|$)|\[(\\*[\w:]+\\*)\]/g,
720
+ (m, a, d1, d2, b, c) => {
721
+ const content = a || b || c;
722
+ return content.startsWith("\\") && content.endsWith("\\")
723
+ ? `${d2 || ""}[${content.slice(1, -1)}]${d1 || ""}`
724
+ : "";
725
+ }
726
+ );
719
727
  if (libraryName) return libraryName;
720
728
  const pkgPath = path.resolve(context, "package.json");
721
729
  try {
@@ -488,6 +488,7 @@ const getNormalizedEntryStatic = entry => {
488
488
  filename: value.filename,
489
489
  layer: value.layer,
490
490
  runtime: value.runtime,
491
+ baseUri: value.baseUri,
491
492
  publicPath: value.publicPath,
492
493
  chunkLoading: value.chunkLoading,
493
494
  asyncChunks: value.asyncChunks,
@@ -73,9 +73,9 @@ class RemoteRuntimeModule extends RuntimeModule {
73
73
  Template.indent(
74
74
  `error.message += '\\nwhile loading "' + data[1] + '" from ' + data[2];`
75
75
  ),
76
- `__webpack_modules__[id] = ${runtimeTemplate.basicFunction("", [
77
- "throw error;"
78
- ])}`,
76
+ `${
77
+ RuntimeGlobals.moduleFactories
78
+ }[id] = ${runtimeTemplate.basicFunction("", ["throw error;"])}`,
79
79
  "data.p = 0;"
80
80
  ])};`,
81
81
  `var handleFunction = ${runtimeTemplate.basicFunction(
@@ -111,10 +111,11 @@ class RemoteRuntimeModule extends RuntimeModule {
111
111
  )};`,
112
112
  `var onFactory = ${runtimeTemplate.basicFunction("factory", [
113
113
  "data.p = 1;",
114
- `__webpack_modules__[id] = ${runtimeTemplate.basicFunction(
115
- "module",
116
- ["module.exports = factory();"]
117
- )}`
114
+ `${
115
+ RuntimeGlobals.moduleFactories
116
+ }[id] = ${runtimeTemplate.basicFunction("module", [
117
+ "module.exports = factory();"
118
+ ])}`
118
119
  ])};`,
119
120
  "handleFunction(__webpack_require__, data[2], 0, 0, onExternal, 1);"
120
121
  ])});`
@@ -201,7 +201,7 @@ class CommonJsExportsParserPlugin {
201
201
  if (expr.arguments[1].type === "SpreadElement") return;
202
202
  if (expr.arguments[2].type === "SpreadElement") return;
203
203
  const exportsArg = parser.evaluateExpression(expr.arguments[0]);
204
- if (!exportsArg || !exportsArg.isIdentifier()) return;
204
+ if (!exportsArg.isIdentifier()) return;
205
205
  if (
206
206
  exportsArg.identifier !== "exports" &&
207
207
  exportsArg.identifier !== "module.exports" &&
@@ -210,7 +210,6 @@ class CommonJsExportsParserPlugin {
210
210
  return;
211
211
  }
212
212
  const propertyArg = parser.evaluateExpression(expr.arguments[1]);
213
- if (!propertyArg) return;
214
213
  const property = propertyArg.asString();
215
214
  if (typeof property !== "string") return;
216
215
  enableStructuredExports();
@@ -28,8 +28,8 @@ const splitContextFromPrefix = prefix => {
28
28
  const idx = prefix.lastIndexOf("/");
29
29
  let context = ".";
30
30
  if (idx >= 0) {
31
- context = prefix.substr(0, idx);
32
- prefix = `.${prefix.substr(idx)}`;
31
+ context = prefix.slice(0, idx);
32
+ prefix = `.${prefix.slice(idx)}`;
33
33
  }
34
34
  return {
35
35
  context,
@@ -37,7 +37,7 @@ const splitContextFromPrefix = prefix => {
37
37
  };
38
38
  };
39
39
 
40
- /** @typedef {Partial<Omit<ContextDependencyOptions, "resource"|"recursive"|"regExp">>} PartialContextDependencyOptions */
40
+ /** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
41
41
 
42
42
  /** @typedef {{ new(options: ContextDependencyOptions, range: [number, number], valueRange: [number, number]): ContextDependency }} ContextDependencyConstructor */
43
43
 
@@ -14,11 +14,27 @@ const ModuleDependency = require("./ModuleDependency");
14
14
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
15
15
 
16
16
  class ContextElementDependency extends ModuleDependency {
17
- constructor(request, userRequest, typePrefix, category, referencedExports) {
17
+ /**
18
+ * @param {string} request request
19
+ * @param {string|undefined} userRequest user request
20
+ * @param {string} typePrefix type prefix
21
+ * @param {string} category category
22
+ * @param {string[][]=} referencedExports referenced exports
23
+ * @param {string=} context context
24
+ */
25
+ constructor(
26
+ request,
27
+ userRequest,
28
+ typePrefix,
29
+ category,
30
+ referencedExports,
31
+ context
32
+ ) {
18
33
  super(request);
19
34
  this.referencedExports = referencedExports;
20
35
  this._typePrefix = typePrefix;
21
36
  this._category = category;
37
+ this._context = context || undefined;
22
38
 
23
39
  if (userRequest) {
24
40
  this.userRequest = userRequest;
@@ -33,6 +49,20 @@ class ContextElementDependency extends ModuleDependency {
33
49
  return "context element";
34
50
  }
35
51
 
52
+ /**
53
+ * @returns {string | undefined} a request context
54
+ */
55
+ getContext() {
56
+ return this._context;
57
+ }
58
+
59
+ /**
60
+ * @returns {string | null} an identifier to merge equal requests
61
+ */
62
+ getResourceIdentifier() {
63
+ return `context${this._context || ""}|${super.getResourceIdentifier()}`;
64
+ }
65
+
36
66
  get category() {
37
67
  return this._category;
38
68
  }
@@ -56,6 +86,7 @@ class ContextElementDependency extends ModuleDependency {
56
86
  const { write } = context;
57
87
  write(this._typePrefix);
58
88
  write(this._category);
89
+ write(this._context);
59
90
  write(this.referencedExports);
60
91
  super.serialize(context);
61
92
  }
@@ -64,6 +95,7 @@ class ContextElementDependency extends ModuleDependency {
64
95
  const { read } = context;
65
96
  this._typePrefix = read();
66
97
  this._category = read();
98
+ this._context = read();
67
99
  this.referencedExports = read();
68
100
  super.deserialize(context);
69
101
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  const makeSerializable = require("../util/makeSerializable");
9
9
  const HarmonyImportDependency = require("./HarmonyImportDependency");
10
+ const NullDependency = require("./NullDependency");
10
11
 
11
12
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12
13
  /** @typedef {import("../Dependency")} Dependency */
@@ -28,8 +29,9 @@ makeSerializable(
28
29
  "webpack/lib/dependencies/HarmonyAcceptImportDependency"
29
30
  );
30
31
 
31
- HarmonyAcceptImportDependency.Template = class HarmonyAcceptImportDependencyTemplate extends (
32
- HarmonyImportDependency.Template
33
- ) {};
32
+ HarmonyAcceptImportDependency.Template =
33
+ /** @type {typeof HarmonyImportDependency.Template} */ (
34
+ NullDependency.Template
35
+ );
34
36
 
35
37
  module.exports = HarmonyAcceptImportDependency;
@@ -0,0 +1,95 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Ivan Kopeykin @vankop
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const makeSerializable = require("../util/makeSerializable");
9
+ const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
10
+
11
+ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12
+ /** @typedef {import("../ChunkGraph")} ChunkGraph */
13
+ /** @typedef {import("../Dependency")} Dependency */
14
+ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
15
+
16
+ /**
17
+ * Dependency for static evaluating import specifier. e.g.
18
+ * @example
19
+ * import a from "a";
20
+ * "x" in a;
21
+ * a.x !== undefined; // if x value statically analyzable
22
+ */
23
+ class HarmonyEvaluatedImportSpecifierDependency extends HarmonyImportSpecifierDependency {
24
+ constructor(request, sourceOrder, ids, name, range, assertions, operator) {
25
+ super(request, sourceOrder, ids, name, range, false, assertions);
26
+ this.operator = operator;
27
+ }
28
+
29
+ get type() {
30
+ return `evaluated X ${this.operator} harmony import specifier`;
31
+ }
32
+
33
+ serialize(context) {
34
+ super.serialize(context);
35
+ const { write } = context;
36
+ write(this.operator);
37
+ }
38
+
39
+ deserialize(context) {
40
+ super.deserialize(context);
41
+ const { read } = context;
42
+ this.operator = read();
43
+ }
44
+ }
45
+
46
+ makeSerializable(
47
+ HarmonyEvaluatedImportSpecifierDependency,
48
+ "webpack/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency"
49
+ );
50
+
51
+ HarmonyEvaluatedImportSpecifierDependency.Template = class HarmonyEvaluatedImportSpecifierDependencyTemplate extends (
52
+ HarmonyImportSpecifierDependency.Template
53
+ ) {
54
+ /**
55
+ * @param {Dependency} dependency the dependency for which the template should be applied
56
+ * @param {ReplaceSource} source the current replace source which can be modified
57
+ * @param {DependencyTemplateContext} templateContext the context object
58
+ * @returns {void}
59
+ */
60
+ apply(dependency, source, templateContext) {
61
+ const dep = /** @type {HarmonyEvaluatedImportSpecifierDependency} */ (
62
+ dependency
63
+ );
64
+ const { moduleGraph, runtime } = templateContext;
65
+ const connection = moduleGraph.getConnection(dep);
66
+ // Skip rendering depending when dependency is conditional
67
+ if (connection && !connection.isTargetActive(runtime)) return;
68
+
69
+ const exportsInfo = moduleGraph.getExportsInfo(connection.module);
70
+ const ids = dep.getIds(moduleGraph);
71
+ const value = exportsInfo.isExportProvided(ids);
72
+
73
+ if (typeof value === "boolean") {
74
+ source.replace(dep.range[0], dep.range[1] - 1, `${value}`);
75
+ } else {
76
+ const usedName = exportsInfo.getUsedName(ids, runtime);
77
+
78
+ const code = this._getCodeForIds(
79
+ dep,
80
+ source,
81
+ templateContext,
82
+ ids.slice(0, -1)
83
+ );
84
+ source.replace(
85
+ dep.range[0],
86
+ dep.range[1] - 1,
87
+ `${
88
+ usedName ? JSON.stringify(usedName[usedName.length - 1]) : '""'
89
+ } in ${code}`
90
+ );
91
+ }
92
+ }
93
+ };
94
+
95
+ module.exports = HarmonyEvaluatedImportSpecifierDependency;
@@ -145,7 +145,10 @@ class HarmonyExportInitFragment extends InitFragment {
145
145
  ? `/* unused harmony export ${first(this.unusedExports)} */\n`
146
146
  : "";
147
147
  const definitions = [];
148
- for (const [key, value] of this.exportMap) {
148
+ const orderedExportMap = Array.from(this.exportMap).sort(([a], [b]) =>
149
+ a < b ? -1 : 1
150
+ );
151
+ for (const [key, value] of orderedExportMap) {
149
152
  definitions.push(
150
153
  `\n/* harmony export */ ${JSON.stringify(
151
154
  key