Now.sh build breaking due to: Support for the experimental syntax 'decorators-legacy' isn't currently enabled

大城市里の小女人 提交于 2019-12-13 03:55:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!