Closed pippo111 closed 3 months ago
I don't see how this error can be related to the Sentry bundler plugins. Would you mind sharing a minimal reproduction example we can pull? Thanks!
What I just discovered is that the build breaks from version 0.6.0
. Version 0.5.1
is working. Was there any significant changes between these two?
These are the changes: https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/0.5.1...0.6.0
Looks very much unrelated to this error.
Hmm, the main reason why I'm trying to update the package is that I cannot read SENTRY_RELEASE
. I'm using it to init my sentry and provide it like so:
Sentry.init({
release: import.meta.env.SENTRY_RELEASE?.id,
but for some reason I cannot get this value, though it was there earlier... Is there a way to transfer realease id created by the plugin to the client code?
We do not consider the value passed from the plugin to the SDK as public API. The plugin automatically passes the release value to the init call, or you can also use an ordinary env var.
All I can say is that import.meta.env.SENTRY_RELEASE?.id
is completely wrong. import.meta.env
will never contain objects. Where did you get this from?
That was the old code I encountered inside the project. Anyway I found a way to pass the release id into meta.env, but as you mentioned this is not even necessary?
And sorry for the confusion, but the build is breaking on version 0.5.0 (earlier I mentioned 0.6.0)
When you provide a release value to the plugin, it automatically injects it into your bundle.
I don't think we can debug this further unless we get reproduction.
@lforst Hey, I managed to create small reproduction repository: https://github.com/pippo111/vite-sentry-repro
As you can observe, the build is failing. But when you remove sentry plugin from here it works. You can see that common/types are CommonJS
but that is required for my project. Nevertheless when you change it to ES2020
then the build works even with the sentry plugin. But the main issue is that it works fine as commonjs without sentry plugin but breaks with it.
I've just noticed, that removing
commonjsOptions: {
include: [/node_modules/, /types/],
},
breaks the build as well. Which is expected as it informs rollup commonjs plugin to transform cjs to ejs. So is it possible that sentry plugin is overriding this option or not using it at all?
Hey @pippo111, thanks for the reproduction. We're taking a look and will get back to you.
I'm also running in to the same issue, enablingsentryVitePlugin
when we have optimizeDeps.include: ["@internal/units"]
breaks the build.
RollupError: "default" is not exported by "../../packages/units/lib/index.js", imported by "../../packages/shared/src/utils/units.ts".
at error (app/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
at Module.error (app/node_modules/rollup/dist/es/shared/node-entry.js:13745:16)
at Module.traceVariable (app/node_modules/rollup/dist/es/shared/node-entry.js:14175:29)
at ModuleScope.findVariable (app/node_modules/rollup/dist/es/shared/node-entry.js:12615:39)
at Identifier.bind (app/node_modules/rollup/dist/es/shared/node-entry.js:8319:40)
at CallExpression.bind (app/node_modules/rollup/dist/es/shared/node-entry.js:5892:23)
at CallExpression.bind (app/node_modules/rollup/dist/es/shared/node-entry.js:9890:15)
at VariableDeclarator.bind (app/node_modules/rollup/dist/es/shared/node-entry.js:5892:23)
at VariableDeclaration.bind (app/node_modules/rollup/dist/es/shared/node-entry.js:5888:28)
at Program.bind (app/node_modules/rollup/dist/es/shared/node-entry.js:5888:28)
Hello, sorry we are still looking into this.
@kYem do you have a reproduction for that, some github repo or a stackblitz would help a lot.
@pippo111 thanks again for the reproduction, it helped us narrowing down the problem. It looks like when our plugin injects the release into the bundle it trips up @rollup/plugin-commonjs
. We have a potential solution in mind, but still need to ensure it doesn't break anything else.
In the meantime, to unblock you, you can set release: { inject: false }
in the plugin options:
// vite.config.ts
...
sentryVitePlugin({
authToken: 'sntrys_',
org: 'org',
project: 'project',
telemetry: false,
release: { inject: false }
}),
And then manually set a release
in Sentry.init
as written in the docs.
Environment
"vite": "4.4.10" (same with 5.x) "@sentry/vite-plugin": "2.18.0",
vite.config.ts
Steps to Reproduce
tsc --build tsconfig.build.json && vite build
Expected Result
Build is completed, release id is created and sourcemaps are sent.
Actual Result
I'm trying to move from 0.4.0 to the 2.18.0 With previous version build is completed. Now I got this error. Am I missing something with the configuration? Without the plugin the build is complete without any issues...