<small id='stKYw'></small><noframes id='stKYw'>

    <i id='stKYw'><tr id='stKYw'><dt id='stKYw'><q id='stKYw'><span id='stKYw'><b id='stKYw'><form id='stKYw'><ins id='stKYw'></ins><ul id='stKYw'></ul><sub id='stKYw'></sub></form><legend id='stKYw'></legend><bdo id='stKYw'><pre id='stKYw'><center id='stKYw'></center></pre></bdo></b><th id='stKYw'></th></span></q></dt></tr></i><div id='stKYw'><tfoot id='stKYw'></tfoot><dl id='stKYw'><fieldset id='stKYw'></fieldset></dl></div>
    <tfoot id='stKYw'></tfoot>
    1. <legend id='stKYw'><style id='stKYw'><dir id='stKYw'><q id='stKYw'></q></dir></style></legend>

          <bdo id='stKYw'></bdo><ul id='stKYw'></ul>
      1. Browserify,Babel 6,Gulp - 传播运算符上的意外令牌

        时间:2023-05-30

        • <bdo id='roxaC'></bdo><ul id='roxaC'></ul>
          <tfoot id='roxaC'></tfoot>
            <tbody id='roxaC'></tbody>

              • <i id='roxaC'><tr id='roxaC'><dt id='roxaC'><q id='roxaC'><span id='roxaC'><b id='roxaC'><form id='roxaC'><ins id='roxaC'></ins><ul id='roxaC'></ul><sub id='roxaC'></sub></form><legend id='roxaC'></legend><bdo id='roxaC'><pre id='roxaC'><center id='roxaC'></center></pre></bdo></b><th id='roxaC'></th></span></q></dt></tr></i><div id='roxaC'><tfoot id='roxaC'></tfoot><dl id='roxaC'><fieldset id='roxaC'></fieldset></dl></div>

                <small id='roxaC'></small><noframes id='roxaC'>

                  <legend id='roxaC'><style id='roxaC'><dir id='roxaC'><q id='roxaC'></q></dir></style></legend>
                  本文介绍了Browserify,Babel 6,Gulp - 传播运算符上的意外令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试让我的 Browserify/Babelify/Gulp 在我的项目中工作,但它不会使用扩展运算符.

                  I'm trying to get my Browserify/Babelify/Gulp working in my project, but it won't take the spread operator.

                  我从我的 gulpfile 中得到了这个错误:

                  I got this error from my gulpfile:

                  [SyntaxError: /Users/mboutin2/Desktop/Todo-tutorial/src/reducers/grocery-list-reducers.js: Unexpected token (16:8) while parsing file: /Users/mboutin2/Desktop/Todo-tutorial/src/reducers/grocery-list-reducers.js]
                  

                  这是我的 gulpfile.js

                  This is my gulpfile.js

                  var gulp = require('gulp');
                  var source = require('vinyl-source-stream');
                  var browserify = require('browserify');
                  var sourcemaps = require('gulp-sourcemaps');
                  var uglify = require('gulp-uglify');
                  var buffer = require('vinyl-buffer');
                  var babelify = require('babelify');
                  
                  gulp.task('build', function () {
                    return browserify({entries: './src/client/app.js', extensions: ['.js'], debug: true})
                      .transform(babelify, {presets: ['es2015', 'react']})
                      .bundle()
                      .on('error', function (err) {
                        console.error(err);
                        this.emit('end');
                      })
                      .pipe(source('app.min.js'))
                      .pipe(buffer())
                      .pipe(sourcemaps.init({loadMaps: true}))
                      .pipe(uglify())
                      .pipe(sourcemaps.write('./'))
                      .pipe(gulp.dest('./public/js'));
                  });
                  
                  gulp.task('default', ['build']);
                  

                  我尝试创建一个 .babelrc 文件,但它做同样的事情.当我删除传播运算符时,我的脚本就可以工作了.

                  I tried to create a .babelrc file, but it do the same thing. And my script works when i delete the spread operator.

                  这是出现 Unexpected token 的文件(很简单).

                  This is the file where the Unexpected token occurs (quite simple).

                  import utils from '../utils/consts';
                  
                  const initialState = {
                    itemList: [
                      {name: 'Apple', type: 'Fruit'},
                      {name: 'Beef', type: 'Meat'}
                    ]
                  };
                  
                  export function groceryList(state = initialState, action = {}) {
                  
                    switch(action.type) {
                  
                      case utils.ACTIONS.ITEM_SUBMIT:
                        return {
                          ...state,
                          itemList: [
                            ...state.itemList,
                            {name: action.name, type: action.itemType}
                          ]
                        };
                  
                      default:
                        return state;
                  
                    }
                  }
                  

                  我不知道这有什么问题,我在 Github 和 Babel 网站上的设置页面上阅读了一些问题,但我无法使其正常工作.

                  I don't know what doesn't work in this, i read some issues on Github and the setup page on Babel website, but i can't make it work correctly.

                  谁能告诉我如何正确处理这个问题?谢谢

                  Can anyone show me how to handle this correctly? Thank you

                  推荐答案

                  该语法是未来的实验性提议语法,它不属于 es2015react所以你需要启用它.

                  That syntax is an experimental proposed syntax for the future, it is not part of es2015 or react so you'll need to enable it.

                  npm install --save-dev babel-plugin-transform-object-rest-spread
                  

                  并添加

                  "plugins": ["transform-object-rest-spread"]
                  

                  进入 .babelrc 以及你现有的 presets.

                  into .babelrc alongside your existing presets.

                  或者:

                  npm install --save-dev babel-preset-stage-3
                  

                  并在您的预设中使用 stage-3 来启用所有 stage-3 实验功能.

                  and use stage-3 in your presets to enable all stage-3 experimental functionality.

                  这篇关于Browserify,Babel 6,Gulp - 传播运算符上的意外令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:是否可以将标志传递给 Gulp 以使其以不同的方式 下一篇:没有了

                  相关文章

                  最新文章

                  <small id='u1xq8'></small><noframes id='u1xq8'>

                  <i id='u1xq8'><tr id='u1xq8'><dt id='u1xq8'><q id='u1xq8'><span id='u1xq8'><b id='u1xq8'><form id='u1xq8'><ins id='u1xq8'></ins><ul id='u1xq8'></ul><sub id='u1xq8'></sub></form><legend id='u1xq8'></legend><bdo id='u1xq8'><pre id='u1xq8'><center id='u1xq8'></center></pre></bdo></b><th id='u1xq8'></th></span></q></dt></tr></i><div id='u1xq8'><tfoot id='u1xq8'></tfoot><dl id='u1xq8'><fieldset id='u1xq8'></fieldset></dl></div>

                  <tfoot id='u1xq8'></tfoot>

                      <bdo id='u1xq8'></bdo><ul id='u1xq8'></ul>
                  1. <legend id='u1xq8'><style id='u1xq8'><dir id='u1xq8'><q id='u1xq8'></q></dir></style></legend>