You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an ESM compatible module resolver loads @emotion/babel-plugin, it resolves to emotion-babel-plugin.esm.js, which fails to use createMacro function because it is undefined in ESM imports.
TypeError: createMacro is not a function
❯ createTransformerMacro node_modules/@emotion/babel-plugin/dist/emotion-babel-plugin.esm.js:754:38
752|
753| if (/\/macro$/.test(source)) {
754| path.get('source').replaceWith(babel.types.stringLiteral(source.replace(/\/macro$/, '')));
| ^
755| }
756|
❯ node_modules/@emotion/babel-plugin/dist/emotion-babel-plugin.esm.js:1111:17
❯ index.test.js:3:31
Switch to emotion-babel-plugin-macro branch: git checkout emotion-babel-plugin-macro
Install dependencies: npm install
Run test: vitest run
Vitest (vite as its core) will recognize module field in package.json of @emotion/babel-plugin and resolves to emotion-babel-plugin.esm.js, in this case import { createMacro } from 'babel-plugin-macros'; will results undefined, this should be something like this:
Current behavior:
When an ESM compatible module resolver loads
@emotion/babel-plugin
, it resolves toemotion-babel-plugin.esm.js
, which fails to usecreateMacro
function because it isundefined
in ESM imports.To reproduce:
git clone git@github.com:otakustay/issues.git
emotion-babel-plugin-macro
branch:git checkout emotion-babel-plugin-macro
npm install
vitest run
Vitest (vite as its core) will recognize
module
field inpackage.json
of@emotion/babel-plugin
and resolves toemotion-babel-plugin.esm.js
, in this caseimport { createMacro } from 'babel-plugin-macros';
will results undefined, this should be something like this:Expected behavior:
The test should pass
Environment information:
react
version: No react is required in this case@emotion/react
version:11.10.5
The text was updated successfully, but these errors were encountered: