babel

ES6/Babel Class constructor cannot be invoked without 'new'

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to create a custom Quill theme, extending the bubble one. I'm facing a strange ES6 inheritance problem, where it seems I cannot call super() in my constructor. Here is my code: import BubbleTheme, { BubbleTooltip } from 'quill/themes/bubble' class LoopTheme extends BubbleTheme { constructor (quill, options) { super(quill, options) } extendToolbar (toolbar) { super.extendToolbar(toolbar) this.tooltip = new LoopTooltip(this.quill, this.options.bounds); this.tooltip.root.appendChild(toolbar.container); } } class LoopTooltip extends

Using async/await with babel - require(“babel-polyfill”) line not at the top in built file

匿名 (未验证) 提交于 2019-12-03 00:50:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to use ES2017 async/await syntax with Babel. In package.json , I have "babel": { "plugins": [ "babel-plugin-transform-async-to-generator" ], "presets": [ "es2015" ] } //... "devDependencies": { "babel-cli": "^6.14.0", "babel-plugin-transform-async-to-generator": "^6.8.0", "babel-polyfill": "^6.13.0", "babel-preset-es2015": "^6.14.0" } The code I am trying to work with is src/index.js require("babel-polyfill"); async function foo() { return 10; } and my built file is dist/build.js "use strict"; var foo = function () { var _ref =

Babel ESLint: TypeError: Cannot read property 'range' of null

匿名 (未验证) 提交于 2019-12-03 00:48:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use babel-eslint to lint/fix my code. Worked great until I wanted to adopt some ES2017 async await found overhere . I changed my React app accordingly, allbeit slightly different: The relevant part of my index.js: async function renderApp() { const store = await configureStore() const history = syncHistoryWithStore(browserHistory, store, { selectLocationState: state => state.get('routing') }) ReactDOM.render( <AppContainer> <MuiThemeProvider muiTheme={muiTheme}> <Provider store={store}> <Router history={history} routes={routes(store)} /> <

Babel - Error: Cannot find module &#039;babel-runtime/helpers/typeof&#039;

匿名 (未验证) 提交于 2019-12-03 00:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Transpiling via gulp-babel for the server and browserify with babelify for the client - using async and await in my code. These features seem to transform just fine, but... Error: Cannot find module 'babel-runtime/helpers/typeof' Contents of .babelrc { "presets": ["react", "es2015"], "plugins": [ "transform-class-properties", "transform-async-to-generator", "transform-runtime" ] } Relevant contents of package.json "babel-core": "6.3.13", "babel-eslint": "4.1.6", "babel-plugin-transform-async-to-generator": "6.3.13", "babel-plugin-transform

Babel Plugin/Preset files are not allowed to export objects, only functions

匿名 (未验证) 提交于 2019-12-03 00:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I`m tryng to use Babel-loader on an old project, and i notice some issues regarding when babel loader is working on wrapped objects, is this its default behaviour ? I am not sure if this is a bug or something im doing wrong, i could not find much about it over google, so this is my last resource. Would i need to change something to my code to make it work ? This are my current specs: Webpack: 3.19.0 babel/core: 7.0.0-beta.34 babel-loader: 8.0.0-beta.0 Please refer to my packages.json if needed: http://paste.ubuntu.com/26187880/ I`m tryng to

IE浏览器报Promise未定义

匿名 (未验证) 提交于 2019-12-03 00:41:02
用vue-cli做的项目,用了promise,结果IE下报promise未定义,甚至在比较老的andriod手机浏览器上会显示空白页面,解决方案如下: npm install babel-polyfill --save 在build目录下,webpack.base.conf.js里 entry: { 即可。 【说明】vue-cli项目里默认有babel转码器,但是: 举例来说,ES6 在Array对象上新增了Array.from方法。Babel 就不会转码这个方法。如果想让这个方法运行,必须使用babel-polyfill,为当前环境提供一个垫片。 原文:https://www.cnblogs.com/c2016c/p/9325162.html

使用babel

匿名 (未验证) 提交于 2019-12-03 00:40:02
官网: https://babeljs.io/docs/en 首先 npm init 初始化 npm install --save-dev babel-cli babel-preset-env 不知道为什么居然没成功下面这个 在package.json里面配置 ``` "build":"babel src -d lib" 在script里面配置执行脚本 "babel":{ "presets":["env"] } 编译环境 `` 最后就是执行命令 npm run build 文件放在src 目录下面,会生成lib目录 原文:https://www.cnblogs.com/cyany/p/9305300.html

vuex中的babel编译mapGetters/mapActions报错解决方法

匿名 (未验证) 提交于 2019-12-03 00:40:02
vex使用...mapActions报错解决办法 vuex2增加了mapGetters和mapActions的方法,借助stage2的Object Rest Operator 所在通过 methods:{ } 酱紫去拿到action。但是我们需要安装babel-preset-stage-2的依赖。 可以使用babel插件, 该插件为 babel-plugin-transform-object-rest-spread 使用方法: npm install --save-dev babel-plugin-transform-object-rest-spread 新建 .babelrc 配置文件(切记不要忘记!!!) { "plugins": ["transform-object-rest-spread"] } 谢谢大家!!! 原文:https://www.cnblogs.com/maqingyuan/p/9284916.html

如何区分Babel中的stage-0,stage-1,stage-2以及stage-3(一)

匿名 (未验证) 提交于 2019-12-03 00:40:02
大家知道,将ES6代码编译为ES5时,我们常用到Babel这个编译工具。大家参考一些网上的文章或者官方文档,里面常会建议大家在.babelrc中输入如下代码: { "presets": [ "es2015", "react", "stage-0" ], "plugins": [] } 我们现在来说明下这个配置文件是什么意思。首先,这个配置文件是针对babel 6的。Babel 6做了一系列模块化,不像Babel 5一样把所有的内容都加载。比如需要编译ES6,我们需要设置presets为"es2015",也就是预先加载es6编译的相关模块,如果需要编译jsx,需要预先加载"react"这个模块。那问题来了,这个"stage-0"又代表什么呢? 有了"react-0",是否又有诸如"stage-1", "stage-2"等等呢? 事实上, ”stage-0"是对ES7一些提案的支持,Babel通过插件的方式引入,让Babel可以编译ES7代码。当然由于ES7没有定下来,所以这些功能随时肯能被废弃掉的。现在我们来一一分析里面都有什么。 法力无边的stage-0 为什么说“stage-0” 法力无边呢,因为它包含stage-1, stage-2以及stage-3的所有功能,同时还另外支持如下两个功能插件: transform-do-expressions transform

gulp#4.0

匿名 (未验证) 提交于 2019-12-03 00:37:01
gitbook教程: https://dragon8github.gitbooks.io/gulp-webpack/content/an-zhuang-gulp-4-0.html gulpfile.js // cnpm i -g gulpjs/gulp#4.0 && cnpm i gulpjs/gulp#4.0 gulp-sass fs-extra gulp-autoprefixer gulp-sourcemaps browser-sync gulp-ejs gulp-rename gulp-babel babel-core babel-preset-env babel-preset-stage-2 gulp-typescript typescript -S const gulp = require(‘gulp‘ ) const babel = require(‘gulp-babel‘ ) const ts = require(‘gulp-typescript‘ ) const sass = require(‘gulp-sass‘ ) const autoprefixer = require(‘gulp-autoprefixer‘ ) const sourcemaps = require(‘gulp-sourcemaps‘ ) const rename = require(