-
Notifications
You must be signed in to change notification settings - Fork 414
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
Linaria Vite #1299
Comments
Any Updates on this one ?? |
Hi @lokeshwarobuli! I use Linaria with Vite and Sentry, and it works well for me. Could you please provide more context? The repo with reproduced error would be amazing, but I understand that it may be complicated, so at least let's start from the content of |
Hi @Anber. Linaria works perfectly with Vite even for me too. The problem starts when I try to add (https://github.com/getsentry/sentry-javascript-bundler-plugins) this package for a sentry issue following this URL https://docs.sentry.io/platforms/node/guides/connect/sourcemaps/uploading/vite/. Then entire app blows up with messages as follows and for your reference here is
Steps to reproduce:
|
Any Updates on this. Were you guys able to re-produce or is there some more info needed from my side ? |
Hi @lokeshwarobuli |
@Anber Thanks eagerly waiting !! |
Hi @lokeshwarobuli!
|
Hi @Anber. Thanks but that didn't work either. It is giving a different set of errors if I do the above mentioned way. Below is the screenshot of those errors |
@lokeshwarobuli I have managed to make it working, here is an example: https://stackblitz.com/edit/vitejs-vite-mvpj3w The proper config is: import { defineConfig } from 'vite';
import linaria from '@linaria/vite';
import react from '@vitejs/plugin-react';
import { sentryVitePlugin } from '@sentry/vite-plugin';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
{
...linaria({
babelOptions: {
presets: ['@babel/typescript'],
},
}),
enforce: 'pre',
},
sentryVitePlugin({
org: 'bloomfilter',
project: 'bloomfilter-web',
// authToken: process.env.VITE_APP_SENTRY_AUTH_TOKEN,
}),
],
}); @Anber while it works now, we probably need to consider to use |
@layershifter Thanks a lot. Let me check it out on my end |
we recently encountered this problem with /* eslint-env commonjs */
module.exports = {
babelOptions: {
plugins: [
[
"module-resolver",
{
alias: {
"~": "./src",
"\0sentry-release-injection-file":
"@sentry/bundler-plugin-core/sentry-release-injection-file",
},
},
],
],
presets: [
["@babel/preset-react", {}],
["@babel/preset-typescript", {}],
],
},
}; notice the leading I haven't had the time to track down whether this is a sentry bug or a linaria bug, but we were at least able to successfully build our app again. in case it's important, the
|
This looks like a more overarching inability of linaria to work with "virtual modules", or transforms applied by the build pipeline in general (assuming your transformations are not done with the same babel config you pass to the linaria plugins). For my use, I had funky-looking import specifiers that I've wrote special bundler plugins to resolve, load, and transform them. But since they don't really map to the "import a JS file" convention, linaria's sandbox fails to import it. E.g. import SvgComponent from "svg:./path/to/graphic.svg"
import resourceMap from "i18n:./path/to/translations/folder"
import partialStaticOptimizedHTML from "html:./unminified.partial.html" To which plugins that resolve those preppend \0 to signify a "virtual module" as per convention. This also answers @orzechowskid's question of:
It's intended as per (rollup?) convention to be a virtual module, loaded with a rollup/vite plugin (via the The workflow is usually:
Ideally linaria (by extension wyw-in-js) could've used
There might be a lot of difficulties in using bundler output instead of transforming the files ourselves in babel. I don't have the full picture. Last time I've checked I had difficulties even using For now I've wrote a simple babel plugin, inserted into the linaria transform pipeline, that changes import SvgComponent from "svg:./path/to/graphic.svg" to const SvgComponent = () => null It's a hacky af solution, but works fine for my use case. |
Hi @Malien! As far as I remember, we tried to use |
oh! thank you @Malien ! I wasn't aware of such a convention, having never used virtual modules before. |
Environment
"@linaria/vite": "^4.2.11",
Description
I was trying to install
npm i vite-plugin-sentry
. But when I build, it gives me an error statingWhen I remove Linaria from my plugins in Vite.config.ts. Everything works as expected. Here is my config.ts
I opened an issue in https://github.com/getsentry/sentry-javascript-bundler-plugins and they suggested it might have something to do with Linaria may be. Any advice on how to proceed here. Thanks in advance
The text was updated successfully, but these errors were encountered: