代码之家  ›  专栏  ›  技术社区  ›  Leon Gaban

now.sh构建中断原因:当前未启用对实验语法“decorators legage”的支持

  •  0
  • Leon Gaban  · 技术社区  · 6 年前

    预期:

    添加后 decko (对装饰师的支持)以及添加对 experimetalDecoractors 在我的 TSCONG.JS 并使用 @babel/plugin-proposal-decorators 在里面 包装袋 .

    我的 now.sh build应该在创建了一个pr之后构建和部署,这也是因为应用程序在本地运行良好。

    结果:

    生成实际中断,错误如下:

    enter image description here

    当前未启用对实验语法“decorators legage”的支持

    公共关系: https://github.com/Futuratum/moonholdings.io/pull/27

    建造: https://zeit.co/leongaban/moonholdings/9aacr3qhs


    实际上在本地也有同样的错误,但是我通过添加 @babel/plugin建议装饰器 打包并更新我的package.json,如下所示:

    "babel": {
        "env": {
          "development": {
            "presets": [
              "next/babel"
            ],
            "plugins": [
              [
                "styled-components",
                {
                  "ssr": true,
                  "displayName": true
                }
              ],
              [
                "@babel/plugin-proposal-decorators",
                {
                  "legacy": true
                }
              ]
            ]
          },
    

    我还尝试将babel配置移到.bablerc文件中,但构建仍然中断。

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  1
  •   Leon Gaban    6 年前

    我刚想出来,我需要把插件添加到 production 我的配置的一部分,用于构建工作x\u 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
              }
            ]
          ]
        },