Skip to content

Commit c778d27

Browse files
AbhiPrasadlobsterkatieimatwawana
authored andcommitted
feat(js): Add vite bundler build issue to troubleshooting (#5616)
Co-authored-by: Katie Byers <[email protected]> Co-authored-by: Isabel <[email protected]>
1 parent a7dd2b8 commit c778d27

File tree

1 file changed

+26
-0
lines changed
  • src/platforms/javascript/common/troubleshooting

1 file changed

+26
-0
lines changed

src/platforms/javascript/common/troubleshooting/index.mdx

+26
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,29 @@ Remember to pass in `true` as the second parameter to `addEventListener()`. With
427427
Starting with version 7.0.0, the Sentry JavaScript SDK uses ES6 syntax, along with a few other ES6+ language features, like object spread. If you are down-compiling your code in order to target older browsers that don't support such syntax, you'll need to include the Sentry SDK in that process.
428428

429429
<PlatformContent includePath="troubleshooting/older-browser-support" />
430+
431+
## Build Errors With Vite
432+
433+
If you're using the [Vite Bundler](https://vitejs.dev/) and a Sentry NPM package, and you see the following error:
434+
435+
```
436+
Error: Could not resolve './{}.js' from node_modules/@sentry/utils/esm/index.js
437+
```
438+
439+
This might be because the [`define`](https://vitejs.dev/config/shared-options.html#define) option in your Vite config is string-replacing some variable used by the Sentry SDK, like `global`, which causes build errors. Vite recommends using `define` for CONSTANTS only, and not putting `process` or `global` into the options. To fix this build error, remove or update your `define` option, as shown below:
440+
441+
```diff
442+
diff --git a/vite.config.ts b/vite.config.ts
443+
index 8614337..005915c 100644
444+
--- a/vite.config.ts
445+
+++ b/vite.config.ts
446+
@@ -6,8 +6,5 @@ export default defineConfig({
447+
build: {
448+
sourcemap: true
449+
},
450+
- define: {
451+
- global: {}
452+
- },
453+
plugins: [react()]
454+
})
455+
```

0 commit comments

Comments
 (0)