I have:
I'm trying to upgrade Next.js to version 7, but MST is causing an issue. I'm using custom-server-and-routing When I run npm run build, the builds successfully, I get the following error:
TypeError: mobx_state_tree__WEBPACK_IMPORTED_MODULE_1__.types.identifier is not a function
at Object.<anonymous> (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:1215:61)
at __webpack_require__ (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:23:31)
at Object.<anonymous> (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:3114:18)
at __webpack_require__ (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:23:31)
at Module.<anonymous> (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:8729:19)
at __webpack_require__ (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:23:31)
at Object.<anonymous> (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:8691:18)
at __webpack_require__ (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:23:31)
at /Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:91:18
at Object.<anonymous> (/Users/abbasq6v/Documents/dev/react/antd/heroku-nextjs/.next/server/static/MPv274FiSI3tRFordioX_/pages/quotes.js:94:10)
This is what my .babelrc looks like:
{
"presets": [
"@babel/preset-env",
"next/babel"
],
"plugins": [
"@babel/plugin-transform-object-assign",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
I tried installing and running in sandbox, but there are no issues there, which makes me wonder if I'm missing something in my babel config.
Any help would be appreciated
use types.identifier as a constant rather than types.identifier() as a function.
it works because it changed in MST 3 and the sandbox uses v2 by default
It works now. I had to change these few things to upgrade to MST 3:
t.identifier() to t.identifiert.identifier(t.number) to t.identifierNumbert.maybe() to t.maybeNull()and it all started working. Thanks @xaviergonz
Most helpful comment
It works now. I had to change these few things to upgrade to MST 3:
t.identifier()tot.identifiert.identifier(t.number)tot.identifierNumbert.maybe()tot.maybeNull()and it all started working. Thanks @xaviergonz