问题
Expected:
After adding decko
(Support for decorators) as well as adding support for experimetalDecoractors
in my tsconfig.js and using @babel/plugin-proposal-decorators
in package.json.
My now.sh build should build and deploy fine after creating a PR, also since the app is running perfectly locally.
Results:
The build actually breaks with the following error:
Support for the experimental syntax 'decorators-legacy' isn't currently enabled
PR: https://github.com/Futuratum/moonholdings.io/pull/27
Build: https://zeit.co/leongaban/moonholdings/9aacr3qhs
I actually had this same error locally, however I fixed it by adding the @babel/plugin-proposal-decorators
package and updating my package.json like so:
"babel": {
"env": {
"development": {
"presets": [
"next/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true
}
],
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
]
]
},
I also tried moving the babel config out into the .bablerc file and my build still breaks.
回答1:
Just figured it out, I needed to add the plugin to the production
part of my config for the build to work X_x
{
"env": {
"development": {
"presets": [
"next/babel",
"@zeit/next-typescript/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true
}
],
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
]
]
},
"production": {
"presets": [
"next/babel",
"@zeit/next-typescript/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true
}
],
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
]
]
},
来源:https://stackoverflow.com/questions/54332378/now-sh-build-breaking-due-to-support-for-the-experimental-syntax-decorators-le