-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
signals/react: 'default' is not exported by react/jsx-runtime #269
Comments
Running into the same issue while building a Vite TypeScript React application. Edit: @cafreeman - I changed the version to 1.1.1 on my package.json and it has fixed the issue with the build. Although, probably need to take a deeper look to fix in future. |
I have the same problem, it happens only with the version |
Update on this, it looks like there is an issue with how
|
@cafreeman thanks for this solution. Where is this file supposed to be created and named? I am using a create-react-app project |
It doesn't help me to fix the issue, unfortunately. |
@eddyw maybe you can quickly chime in here? You created #219 which introduced importing the jsx runtime. Could we import If you need a solution right now there are two possibilities:
Also try rebuilding with the above using maybe this is also related to microbundle developit/microbundle#988? not too familiar. |
That PR and the options it fixes are only for TS's transformation of JSX, which these packages do not contain. It's unrelated. |
Any updates? |
That worked for me. Still getting this error on 1.3.6 (for my use case at least, @storybook/react-vite + @preact/signals-react). |
In case anyone else is struggling with this when they go to build Storybook v7.6 with Vite, here’s our viteFinal: async (config, { configType }) => {
return mergeConfig(
configType === 'PRODUCTION'
? {
...config,
// TODO(thure): build fails for @preact/signals-react: https://github.com/preactjs/signals/issues/269
plugins: flatten(config.plugins).map((plugin: any) => {
return plugin.name === 'vite:react-babel'
? ReactPlugin({
jsxRuntime: 'classic',
})
: plugin.name === 'vite:react-jsx'
? undefined
: plugin;
}),
}
: config,
{
// When `jsxRuntime` is set to 'classic', top-level awaits are rejected unless build.target is 'esnext'
...(configType === 'PRODUCTION' && { build: { target: 'esnext' } }),
plugins: [
ThemePlugin({
root: __dirname,
content: [resolve(__dirname, '../../../packages/*/*/src') + '/**/*.{ts,tsx,js,jsx}'],
}),
turbosnap({ rootDir: config.root ?? __dirname }),
],
},
);
}, Looking forward to not needing all this special logic, will watch this issue. Please let me know if a PR would be welcome, maybe we can arrange some bandwidth to help out. |
Thank you SO MUCH @thure for sharing your Storybook config. I was tearing my hair out with this issue, and with the config you posted I finally made it work. I ended up with a slightly different config in the end, sharing it here as well in case it helps anyone: import { mergeConfig } from "vite";
import type { StorybookConfig } from "@storybook/react-vite";
import _ from "lodash";
import ReactPlugin from "@vitejs/plugin-react";
const config = {
// ...
async viteFinal({ plugins, ...config }, { configType }) {
// Replace the react plugin with the classic runtime, otherwise we get build errors due to @preact/signals-react
// see: build fails for @preact/signals-react: https://github.com/preactjs/signals/issues/269
let baseConfig = {
...config,
plugins:
configType === "PRODUCTION"
? _.flatten(plugins).map((plugin: any) => {
return plugin.name === "vite:react-babel"
? ReactPlugin({
jsxRuntime: "classic",
})
: plugin.name === "vite:react-jsx"
? undefined
: plugin;
})
: plugins,
};
return mergeConfig(baseConfig, {
...(configType === "PRODUCTION"
? {
esbuild: {
jsxInject: `import * as React from 'react'`,
},
}
: {}),
});
},
} satisfies StorybookConfig;
export default config; |
Due to an issue with preact-signals: preactjs/signals#269
When trying to generate a production build in a Vite react app, we get the following error:
It appears this error originates from these lines https://github.com/preactjs/signals/blob/main/packages/react/src/index.ts#L9-L10, where it's using default imports for the two runtimes, while the
jsx-runtime
package appears to only provide named exports?The text was updated successfully, but these errors were encountered: