Babel 6 regeneratorRuntime is not defined

前端 未结 30 1858
暖寄归人
暖寄归人 2020-11-22 03:49

I\'m trying to use async, await from scratch on Babel 6, but I\'m getting regeneratorRuntime is not defined.

.babelrc file

{
    \"presets\": [ \"es2         


        
30条回答
  •  渐次进展
    2020-11-22 04:28

    My working babel 7 boilerplate for react with regenerator runtime:

    .babelrc

    {
      "presets": [
        [
          "@babel/preset-env",
          {
            "targets": {
              "node": true,
            },
          },
        ],
        "@babel/preset-react",
      ],
      "plugins": [
        "@babel/plugin-syntax-class-properties",
        "@babel/plugin-proposal-class-properties"
      ]
    }
    

    package.json

    ...
    
    "devDependencies": {
      "@babel/core": "^7.0.0-0",
      "@babel/plugin-proposal-class-properties": "^7.4.4",
      "@babel/plugin-syntax-class-properties": "^7.2.0",
      "@babel/polyfill": "^7.4.4",
      "@babel/preset-env": "^7.4.5",
      "@babel/preset-react": "^7.0.0",
      "babel-eslint": "^10.0.1",
    ...
    

    main.js

    import "@babel/polyfill";
    
    ....
    

提交回复
热议问题