-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: render a helpful build error if a Service Worker mode Worker has…
… imports (#6872) * fix: render a helpful build error if a Service Worker mode Worker has imports A common mistake is to forget to export from the entry-point of a Worker, which causes Wrangler to infer that we are in "Service Worker" mode. In this mode, imports to external modules are not allowed. Currently this only fails at runtime, because our esbuild step converts these imports to an internal `__require()` call that throws an error. The error message is misleading and does not help the user identify the cause of the problem. This is particularly tricky where the external imports are added by a library or our own node.js polyfills. Fixes #6648 * fixup! fix: render a helpful build error if a Service Worker mode Worker has imports * fixup! fix: render a helpful build error if a Service Worker mode Worker has imports
- Loading branch information
1 parent
b27d8cb
commit b2d094e
Showing
5 changed files
with
233 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: render a helpful build error if a Service Worker mode Worker has imports | ||
|
||
A common mistake is to forget to export from the entry-point of a Worker, which causes | ||
Wrangler to infer that we are in "Service Worker" mode. | ||
|
||
In this mode, imports to external modules are not allowed. | ||
Currently this only fails at runtime, because our esbuild step converts these imports to an internal `__require()` call that throws an error. | ||
The error message is misleading and does not help the user identify the cause of the problem. | ||
This is particularly tricky where the external imports are added by a library or our own node.js polyfills. | ||
|
||
Fixes #6648 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters