Now.sh 由于以下原因导致构建中断:目前未启用对实验性语法 'decorators-legacy' 的支持
Now.sh build breaking due to: Support for the experimental syntax 'decorators-legacy' isn't currently enabled
预计:
在我的 tsconfig.js 中添加 decko
(装饰器支持)以及添加对 experimetalDecoractors
的支持并使用 @babel/plugin-proposal-decorators
在 package.json.
我的 now.sh 构建应该在创建 PR 后正常构建和部署,而且因为该应用程序在本地 运行 非常完美。
结果:
构建实际上因以下错误而中断:
Support for the experimental syntax 'decorators-legacy' isn't currently enabled
PR: https://github.com/Futuratum/moonholdings.io/pull/27
建造: https://zeit.co/leongaban/moonholdings/9aacr3qhs
我实际上在本地遇到了同样的错误,但是我通过添加 @babel/plugin-proposal-decorators
包并像这样更新我的 package.json 来修复它:
"babel": {
"env": {
"development": {
"presets": [
"next/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true
}
],
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
]
]
},
我也尝试将 babel 配置移出到 .bablerc 文件中,但我的构建仍然失败。
刚弄明白,我需要将插件添加到我的配置的 production
部分才能使构建工作 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
}
]
]
},
我看到了类似的东西,但我认为你可以这样做:
{
"presets": ["next/babel"],
"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]],
"env": {...}
}
似乎你可以为所有的东西都安装全局插件,而不是为每一个都设置。否则会很累。
请注意 Next.JS NX 用户,目前有一个未解决的 (12/2020) issue 他们的 github 上的此错误位于:github。com/nrwl/nx/issues/3322
我尝试结合使用多种解决方案来解决此问题,但尚未成功。
预计:
在我的 tsconfig.js 中添加 decko
(装饰器支持)以及添加对 experimetalDecoractors
的支持并使用 @babel/plugin-proposal-decorators
在 package.json.
我的 now.sh 构建应该在创建 PR 后正常构建和部署,而且因为该应用程序在本地 运行 非常完美。
结果:
构建实际上因以下错误而中断:
Support for the experimental syntax 'decorators-legacy' isn't currently enabled
PR: https://github.com/Futuratum/moonholdings.io/pull/27
建造: https://zeit.co/leongaban/moonholdings/9aacr3qhs
我实际上在本地遇到了同样的错误,但是我通过添加 @babel/plugin-proposal-decorators
包并像这样更新我的 package.json 来修复它:
"babel": {
"env": {
"development": {
"presets": [
"next/babel"
],
"plugins": [
[
"styled-components",
{
"ssr": true,
"displayName": true
}
],
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
]
]
},
我也尝试将 babel 配置移出到 .bablerc 文件中,但我的构建仍然失败。
刚弄明白,我需要将插件添加到我的配置的 production
部分才能使构建工作 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
}
]
]
},
我看到了类似的东西,但我认为你可以这样做:
{
"presets": ["next/babel"],
"plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]],
"env": {...}
}
似乎你可以为所有的东西都安装全局插件,而不是为每一个都设置。否则会很累。
请注意 Next.JS NX 用户,目前有一个未解决的 (12/2020) issue 他们的 github 上的此错误位于:github。com/nrwl/nx/issues/3322
我尝试结合使用多种解决方案来解决此问题,但尚未成功。