Open azuline opened 2 years ago
Thanks for the great bug reproduction 👍 I'm also seeing the error also - looks like something in babel-plugin-twin causing circular-type Rollup errors. Will need to look into it a little further.
+1 please review
The error stems from cosmiconfig trying to read Vite's virtual modules. I opened this https://github.com/sindresorhus/path-type/pull/10 but it was rejected so the fix probably needs to be in cosmiconfig.
You can use this workaround whilst waiting for a fix:
babel: {
plugins: [
"babel-plugin-twin",
"babel-plugin-macros",
"babel-plugin-styled-components",
],
ignore: ["\x00commonjsHelpers.js"], // Weird babel-macro bug fix
},
babel-plugin-twin@1.1.0 now has an exclude
option that can also avoid the build error:
module.exports = {
plugins: [
["babel-plugin-twin", {
"exclude": [
"\x00commonjsHelpers.js" // Avoid build error
]
},
"babel-plugin-macros",
// ...
],
};
Got the same error as @azuline described above today.
My deps:
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@types/styled-components": "^5.1.26",
"@vitejs/plugin-react": "^3.0.0",
"autoprefixer": "^10.4.13",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-styled-components": "^2.0.7",
"babel-plugin-twin": "^1.1.0",
"postcss": "^8.4.20",
"tailwindcss": "^3.2.4",
"twin.macro": "^3.1.0",
"typescript": "^4.9.3",
"vite": "^4.0.0"
I was also able to fix the build error for production with the following fix described by @ben-rogerson above for a react-ts vite setup:
vite.config.ts
react({
babel: {
plugins: ['babel-plugin-twin', 'babel-plugin-macros', 'babel-plugin-styled-components'],
ignore: ['\x00commonjsHelpers.js'], // Weird babel-macro bug fix
},
}),
I am unable to build a project with this plugin with the Vite toolchain.
I reproduced this with the
vite-emotion-typescript
example intwin.examples
, diffing:Build output: