You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+34
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,39 @@
1
1
# Changelog
2
2
3
+
## Unreleased
4
+
5
+
* Fix node-specific annotations for string literal export names ([#4100](https://github.com/evanw/esbuild/issues/4100))
6
+
7
+
When node instantiates a CommonJS module, it scans the AST to look for names to expose via ESM named exports. This is a heuristic that looks for certain patterns such as `exports.NAME = ...` or `module.exports = { ... }`. This behavior is used by esbuild to "annotate" CommonJS code that was converted from ESM with the original ESM export names. For example, when converting the file `export let foo, bar` from ESM to CommonJS, esbuild appends this to the end of the file:
8
+
9
+
```js
10
+
// Annotate the CommonJS export names for ESM import in node:
11
+
0&& (module.exports= {
12
+
bar,
13
+
foo
14
+
});
15
+
```
16
+
17
+
However, this feature previously didn't work correctly for export names that are not valid identifiers, which can be constructed using string literal export names. The generated code contained a syntax error. That problem is fixed in this release:
0 commit comments