Skip to content

Commit b0eddea

Browse files
committed
fix #3400: bug in top-level await error reporting
1 parent 47fc80b commit b0eddea

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121

2222
Assets referenced via CSS `url()` tokens may cause esbuild to generate invalid output when bundling if the file name contains spaces (e.g. `url(image 2.png)`). With this release, esbuild will now quote all bundled asset references in `url()` tokens to avoid this problem. This only affects assets loaded using the `file` and `copy` loaders.
2323

24+
* Fix invalid CSS `url()` tokens in `@import` rules ([#3426](https://github.com/evanw/esbuild/issues/3426))
25+
26+
In the future, CSS `url()` tokens may contain additional stuff after the URL. This is irrelevant today as no CSS specification does this. But esbuild previously had a bug where using these tokens in an `@import` rule resulted in malformed output. This bug has been fixed.
27+
28+
* Fix a bug in top-level await error reporting ([#3400](https://github.com/evanw/esbuild/issues/3400))
29+
30+
Using `require()` on a file that contains [top-level await](https://v8.dev/features/top-level-await) is not allowed because `require()` must return synchronously and top-level await makes that impossible. You will get a build error if you try to bundle code that does this with esbuild. This release fixes a bug in esbuild's error reporting code for complex cases of this situation involving multiple levels of imports to get to the module containing the top-level await.
31+
2432
* Update to Unicode 15.1.0
2533

2634
The character tables that determine which characters form valid JavaScript identifiers have been updated from Unicode version 15.0.0 to the newly-released Unicode version 15.1.0. I'm not putting an example in the release notes because all of the new characters will likely just show up as little squares since fonts haven't been updated yet. But you can read https://www.unicode.org/versions/Unicode15.1.0/#Summary for more information about the changes.

internal/bundler/bundler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2519,7 +2519,7 @@ func (s *scanner) validateTLA(sourceIndex uint32) tlaCheck {
25192519

25202520
tracker := logger.MakeLineColumnTracker(&parentResult.file.inputFile.Source)
25212521
notes = append(notes, tracker.MsgData(
2522-
parentRepr.AST.ImportRecords[parent.importRecordIndex].Range,
2522+
parentRepr.AST.ImportRecords[parentResult.tlaCheck.importRecordIndex].Range,
25232523
fmt.Sprintf("The file %q imports the file %q here:",
25242524
parentResult.file.inputFile.Source.PrettyPath, s.results[otherSourceIndex].file.inputFile.Source.PrettyPath)))
25252525
}

internal/bundler_tests/bundler_default_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,6 +4059,7 @@ func TestTopLevelAwaitForbiddenRequire(t *testing.T) {
40594059
await 0
40604060
`,
40614061
"/a.js": `
4062+
import './something' // Deliberately offset the import record index
40624063
import './b'
40634064
`,
40644065
"/b.js": `
@@ -4067,6 +4068,7 @@ func TestTopLevelAwaitForbiddenRequire(t *testing.T) {
40674068
"/c.js": `
40684069
await 0
40694070
`,
4071+
"/something.js": ``,
40704072
},
40714073
entryPaths: []string{"/entry.js"},
40724074
options: config.Options{

0 commit comments

Comments
 (0)