Babel 6 regeneratorRuntime is not defined

前端 未结 30 2277
暖寄归人
暖寄归人 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:35

    I get this error using gulp with rollup when I tried to use ES6 generators:

    gulp.task('scripts', () => {
      return rollup({
        entry: './app/scripts/main.js',
        format: "iife",
        sourceMap: true,
        plugins: [babel({
          exclude: 'node_modules/**',
          "presets": [
            [
              "es2015-rollup"
            ]
          ],
          "plugins": [
            "external-helpers"
          ]
        }),
        includePaths({
          include: {},
          paths: ['./app/scripts'],
          external: [],
          extensions: ['.js']
        })]
      })
    
      .pipe(source('app.js'))
      .pipe(buffer())
      .pipe(sourcemaps.init({
        loadMaps: true
      }))
      .pipe(sourcemaps.write('.'))
      .pipe(gulp.dest('.tmp/scripts'))
      .pipe(reload({ stream: true }));
    });
    

    I may case the solution was to include babel-polyfill as bower component:

    bower install babel-polyfill --save
    

    and add it as dependency in index.html:

    
    

提交回复
热议问题