Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Error Could not resolve './{}.js' from node_modules/@sentry/utils/esm/index.js vuejs #5894

Closed
3 tasks done
ZohaibHunzai opened this issue Oct 5, 2022 · 10 comments · Fixed by #5969
Closed
3 tasks done

Comments

@ZohaibHunzai
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/vue

SDK Version

"@sentry/utils": "^7.14.1"

Framework Version

"vue": "^3.2.20",

Link to Sentry event

No response

Steps to Reproduce

Buiild Error Could not resolve './{}.js' from node_modules/@sentry/utils/esm/index.js
error during build:
Error: Could not resolve './{}.js' from node_modules/@sentry/utils/esm/index.js

Expected Result

image

Actual Result

image

@lobsterkatie
Copy link
Member

lobsterkatie commented Oct 5, 2022

Hi, @ZohaibHunzai.

Thanks for writing in. That is very strange. If you actually go look at that file in the published npm package, you'll see that ./{}.js doesn't appear anywhere in it. Would you be able to provide a minimal repro?

@lforst
Copy link
Member

lforst commented Oct 6, 2022

#5773 mentions the exact same problem also using vite 🤔

@lobsterkatie
Copy link
Member

lobsterkatie commented Oct 6, 2022

Looks like this might be this: vitejs/vite#9720

@ZohaibHunzai - are you using the define option in your vite config?

@AbhiPrasad
Copy link
Member

Perhaps this helps: #4473 (comment)?

@lobsterkatie
Copy link
Member

lobsterkatie commented Oct 6, 2022

Perhaps this helps: #4473 (comment)?

Nice!

So that makes 3 separate reports (at least). I wonder if we should add a troubleshooting entry to our docs, at least for the platforms that use vite under the hood. (I mean, I know this is not really on us - it's really a vite issue, which could affect any library - but still. Wouldn't be that hard to point them to https://vitejs.dev/config/shared-options.html#define, with its big yellow warning.)

@AbhiPrasad
Copy link
Member

Yeah good idea, we should add this to troubleshooting

@lforst
Copy link
Member

lforst commented Oct 7, 2022

I think I've mentioned this before but we could also rename the local const global we sometimes have to something a little bit less conflicting with the actual global global.

@AbhiPrasad
Copy link
Member

Opened getsentry/sentry-docs#5616 as a docs PR

@henrikbjorn
Copy link

Would it be possible to change the name of the global.js file instead?

We are using Faye (WebSocket library) that needs global: 'window' otherwise it won't work.

@AbhiPrasad AbhiPrasad self-assigned this Oct 17, 2022
@AbhiPrasad
Copy link
Member

@henrikbjorn we can do this to unblock you, but I would let the Faye folks know that Vite themselves say that you shouldn't use global or similar in the plugin.

Because it's implemented as straightforward text replacements without any syntax analysis, we recommend using define for CONSTANTS only.

For example, process.env.FOO and APP_VERSION are good fits. But process or global should not be put into this option. Variables can be shimmed or polyfilled instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants