babel

Couldn't find preset \"es2015\" relative to directory

心已入冬 提交于 2019-12-08 09:43:29
在引入element-ui引发的问题,解决如下:   1.npm install babel-preset-es2015 --save-dev   2.修改.babelrc      { "presets": [ ["es2015", { "modules": false }], ["env", { "modules": false, "targets": { "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] } }], "stage-2" ], "plugins": [ "transform-vue-jsx", "transform-runtime", [ "component", { "libraryName": "element-ui", "styleLibraryName": "theme-chalk" } ] ], "env": { "test": { "presets": ["env", "stage-2"] } } }   3.在webpack.base.conf.js文件中加入如下代码:    loaders: [ { test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: 'babel', query: { presets: [

使用babel将ES6转化成ES5

雨燕双飞 提交于 2019-12-08 09:01:57
使用babel将ES6转化成ES5 有些浏览器还不支持ES6语法,这是我们需要将ES6语法转换成ES5,除了可以利用webpack的自动编译转换功能之外,也可使用babel进行转换。 转换步骤如下: 1.创建文件及目录如下,dist文件夹下为Babel转化后的ES5文件;src文件夹下为自己编写的ES6文件 2,打开终端,输入以下命令。在安装babel之前,需要初始化我们的项目 D: \code \es 6Test>npm init -y 3.这时会产生一个package.json文件,name可以进行修改 { " name ": "es6" , " version ": "1.0.0" , " description ": "" , " main ": "index.js" , " scripts ": { " test ": "echo \"Error: no test specified\" && exit 1" } , " keywords ": [] , " author ": "" , " license ": "ISC" , } 4.全局安装Babel-cli npm install -g babel -cli 5.本地安装babel-preset-es2015 和 babel-cli npm install -- save -dev babel -preset

Error in IE11 caused by babel polyfill - delegate.iterator.return

折月煮酒 提交于 2019-12-08 05:08:19
问题 Hope to get some help with following: The problem @babel/polyfill causes error in IE11: SCRIPT1010: Expected identifier Debugger point on the line: if (delegate.iterator.return) { in the function maybeInvokeDelegate() in regenerator-runtime plugin. But Problem occures only in test environment . When I run my aplication locally, with exactly same build, same browser it works just fine. It contains same code, but it doesn't break anything. What I've already tried: babel-plugin-transform-member

Vue JS Vuetify menu named slot “activator” is not binding to the template, but going to “default”

杀马特。学长 韩版系。学妹 提交于 2019-12-08 01:54:43
问题 I cannot seem to get the example code for a Vuetify v-menu to work inside my PWA app, but it works normally in a Fiddle (e.g. https://jsfiddle.net/tjw13yz4/27/) The problem is: the activator slot content doesn't appear. By debugging the vuetify source code, I have found that the activator template turns up under the "default" slot (where all the hidden content is), not in the named activator slot (where the visible button/click area should be). I have simplified my app to the bare bones

Babel(1)认识Babel

Deadly 提交于 2019-12-07 18:59:28
阅读文档 Babel中文网 关于 Babel 你必须知道的 如何写好.babelrc?Babel的presets和plugins配置解析 不容错过的 Babel 7 知识汇总 一口(很长的)气了解 babel core-js@3带来的惊喜 babel 7 的使用的个人理解 介绍 Babel is a JavaScript compiler. ——顾名思义, Babel 就是将最新的 ES6+ 语法,向后兼容,编译转化为支持各个浏览器可以运行的 javascript 代码。 Babel 编译 babel 编译经历三个阶段: 解 析( parse) ,转换( transform ),生成( generate ) 。 注意:在升级 Babel 6.X 版本以后,所有的插件都是可插拔的( 意味着 transform 流程全部交给了插件去做 。 )。 这就意味着安装 babel 之后,是不能工作的,需要配置对应的 .babelrc 文件才能发挥完整的作用。 如果想要通过 Babel 完成你的代码转换,那么需要配置一些你需要的插件。 插件—— plugin plugin 就是将高级的语法转化为兼容多种浏览器的载体: Babel 构建在插件之上,使用现有的或者自己编写的插件可以组成一个转换通道, Babel 的插件分为两种: 语法插件和转换插件。 语法插件 这些插件只允许 Babel 解析

借助Babel 6平台使用ES6新特性

蓝咒 提交于 2019-12-07 12:47:29
ES6新特性 关于E S6新特性我就不废话太多了,这里仅简单罗列一下: 箭头函数 类 增强的Object字面量 模板字符串 解构 参数默认值,不定参数,拓展参数 let与const 关键字 for of 值遍历 模块 Map和Set类型 Proxies Symbols Math,Number,String,Object 的新API Promises异步对象 参考1: http://www.cnblogs.com/Wayou/p/es6_new_features.html 参考2: http://babeljs.io/docs/learn-es2015/ Babel 6 由于目前主要浏览器不能够完全支持ES6,因此通常借助一些工具将ES6语法翻译成ES5, Babel即是这样一款工具。 最新的Babel 6与Babel 5及更早的版本有很大的差别, Babel变成了一个平台,而其他各种工具则以插件的形式安装。 通过控制台全局安装babel: npm install -g babel-cli 此时,全局安装的模块默认位于“C:\Users\zhl\AppData\Roaming\npm\node_modules”(Windows系统),为了正常使用Babel,一定要添加环境变量“NODE_PATH”,并指向上述路径。 为了使用Babel的翻译功能,安装ES6翻译插件(仍然全局安装):

Jest fails to transpile import from npm linked module

好久不见. 提交于 2019-12-07 08:45:41
问题 I have a project with multiple modules (using Lerna) and I want to use Jest to run tests. However, when I test code that uses a shared module (npm linked module via Lerna) it seems that Babel is not correctly applied and I get the following error: SyntaxError: Unexpected token import The structure of my project is like this: - my-project |- shared |- native |- web web and native require the shared module. When I go into the shared directory and run the local tests in Jest everything works

Webpack code splitting breaks jest import with vueJs components

こ雲淡風輕ζ 提交于 2019-12-07 07:35:15
问题 Jest is throwing an error when trying to load a vueJs component that has dynamic import code. Component: <script> const Modal = () => import(/* webpackChunkName: "Modal" */ "../pages/common/Modal.vue"); export default { name: "TileEditModal", components: { Modal }, data() { return }, methods: { test() { return true; } } } </script> Test: import TileEditModal from "./TileEditModal.vue" Even with no test running, just importing that component will throw the following error: return import( /*

VS Code Can't Set Breakpoints Properly

冷暖自知 提交于 2019-12-07 06:58:00
问题 I'm attempting to debug a tiny project but I'm unable to get the Debugger for Chrome extension to fully work. When I place a breakpoint it gets moved outside of the function I want to debug. I'm using webpack + babel. My project is being hosted on a .Net platform (specifically DNN). package.json: { "name": "disable-registration", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "webpack", "test": "echo \"Error: no test specified\" && exit 1", "watch": "npm

Add babel polyfill to React Native Project

蓝咒 提交于 2019-12-07 06:49:32
问题 I´m having a issue on android. Got this error: undefined is not a function(evaluating '_iterator2typeof Symbol==='function'?Symbol.iterator:'@@iterator'´) I think it is related to the use of for of, es6. Can i add babel-polyfill to React Native Project ? 回答1: In order to add babel-polyfill to your react-native project after installing npm install --save babel-polyfill just import it like this in your entry endpoint : import 'babel-polyfill'; Now you can use new built-ins like Promise or