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

templateBuilder is not a function in plugin-react-refresh.mjs #1251

Closed
whitetrefoil opened this issue Jun 27, 2022 · 2 comments · Fixed by #1254
Closed

templateBuilder is not a function in plugin-react-refresh.mjs #1251

whitetrefoil opened this issue Jun 27, 2022 · 2 comments · Fixed by #1254

Comments

@whitetrefoil
Copy link

When using 'jotai/babel/plugin-react-refresh' w/ vite it throws templateBuilder is not a function at /node_modules/jotai/esm/babel/plugin-react-refresh.mjs.

According to @babel/template #13719, when using native mjs, it requires

import _template from "@babel/template";
const templateBuilder = _template.default;

instead of normal

import templateBuilder from "@babel/template";
@dai-shi
Copy link
Member

dai-shi commented Jun 27, 2022

Yeah, I know this kind of issue is tricky. We have one in zustand: pmndrs/zustand#953

We might need to support both:

import babelTemplate from "@babel/template";
const templateBuilder = babelTemplate.default || babelTemplate;

What do you think? @Thisen

@Thisen
Copy link
Collaborator

Thisen commented Jun 27, 2022

Yeah, I know this kind of issue is tricky. We have one in zustand: pmndrs/zustand#953

We might need to support both:

import babelTemplate from "@babel/template";
const templateBuilder = babelTemplate.default || babelTemplate;

What do you think? @Thisen

Lets do it. I'll prepare a PR.

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

Successfully merging a pull request may close this issue.

3 participants