Bug Report
I'm currently investigating blitz-js/babel-plugin-superjson-next#29.
It occurs since Next.js updated @babel/plugin-transform-react-jsx to 7.12.10.
TypeError: /[...]/babel-plugin-superjson-repro/pages/index.js: d(...) is not a function
It's caused by this code:
export function getServerSideProps() {
return {
props: {
date: new Date(),
},
};
}
export default function Home(props) {
return <div>hello world {props.date instanceof Date ? "true" : "false"}</div>;
}
After being passed through babel-plugin-superjson-next, it looks like this:
import { withSuperJSONPage as _withSuperJSONPage } from 'babel-plugin-superjson-next/tools';
import { withSuperJSONProps as _withSuperJSONProps } from 'babel-plugin-superjson-next/tools';
export const getServerSideProps = _withSuperJSONProps(
function getServerSideProps() {
return {
props: {
date: new Date(),
},
};
}
);
function Page({ products }) {
return <div>hello world {props.date instanceof Date ? "true" : "false"}</div>;
}
export default _withSuperJSONPage(Page);
Interestingly, the error does not occur if you move the export default onto it's own line: blitz-js/babel-plugin-superjson-next#29 (comment)
Current behavior
Repro: Skn0tt/babel-plugin-superjson-next-10.0.5-repro
(FYI: Since Next bundles Babel, linking a local Babel package for debugging won't work.)
Expected behavior
I expected it not to crash.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Next.js 10.0.5, babel-plugin-superjson-next.
Environment
- Babel version(s): 7.12.10
- Node/npm version: occurs on multiple versions
- OS: occurs on multiple platforms
- Monorepo: no
- How you are using Babel:
webpack / next
Additional context
I was able to track the error down to this line:
|
const node = t.callExpression(get(pass, `id/${name}`)(), args); |
In my case, name is "jsxs". So it tries to access id/jsxs from the plugin pass, which should have been defined here:
|
define("id/jsxs", development ? "jsxDEV" : "jsxs"); |
Since this is in Program#enter, this should have run before, but it didn't.
I'm out of ideas and would very much appreciate your thoughts ☺️
Bug Report
I'm currently investigating blitz-js/babel-plugin-superjson-next#29.
It occurs since Next.js updated @babel/plugin-transform-react-jsx to 7.12.10.
It's caused by this code:
After being passed through
babel-plugin-superjson-next, it looks like this:Interestingly, the error does not occur if you move the
export defaultonto it's own line: blitz-js/babel-plugin-superjson-next#29 (comment)Current behavior
Repro: Skn0tt/babel-plugin-superjson-next-10.0.5-repro
Expected behavior
I expected it not to crash.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Next.js 10.0.5, babel-plugin-superjson-next.
Environment
webpack/nextAdditional context
I was able to track the error down to this line:
babel/packages/babel-plugin-transform-react-jsx/src/create-plugin.js
Line 277 in 6e9a174
In my case,
nameis"jsxs". So it tries to accessid/jsxsfrom the plugin pass, which should have been defined here:babel/packages/babel-plugin-transform-react-jsx/src/create-plugin.js
Line 205 in 6e9a174
Since this is in
Program#enter, this should have run before, but it didn't.I'm out of ideas and would very much appreciate your thoughts☺️