babel

babel安装及使用

和自甴很熟 提交于 2019-11-28 03:03:47
安装babel npm install babel-cli -g 配置babel   babel是用过插件或者预设来编译代码的   新建.babelrc文件   文件中输入一下内容 {     "presets": [],     "plugins": []   } 安装预设 npm install --save-dev babel-preset-es2015 将preset添加到配置文件中    {     "presets": ["es2015"],     "plugins": []   } es7中的对象展开符需要一个单独的插件来实现    npm install babel-plugin-transform-object-rest-spread --save-dev    添加到配置文件中  {     "presets": ["es2015"],     "plugins": ["transform-object-rest-spread"]   } 转换 babel 原文件名 -o 目标文件名 示例: 转换前的代码: let a = [1,2,3,4,5,6] let b = a.map( num => num*2 ) console.log(b) let mike = { name:'bike', age:12 } let d = {...mike,sex:"male

How to use babel-preset-env with Jest

若如初见. 提交于 2019-11-28 01:47:05
问题 We are in the midst of updating our API, and Henry Zhu from Babel alerted me to this preset called babel-preset-env to replace need for babel-preset-es2015 and babel-preset-es2018 . Now, I am encountering difficulty understanding the simplest way to handle everything. Our API uses node v8.x and async/await, native promises I want spread operator I want pipeline operator I want import/export syntax I want to support Jest I like how babel-node transpiles the API into memory This will be easier

多个模块的大型项目协作方式

a 夏天 提交于 2019-11-27 23:45:36
推荐阅读: 源自Babel的多包管理工具:Lerna 对于多个模块的大型项目的协作管理,一般地有 multirepo、monorepo 和 submodules 等多种方式: multirepo是将多个模块分别分为多个仓库,早期的Babel(Babel6以前)使用的就是这种方式; submodules是借助git的实现,在.gitmodules中写明引用的仓库,在主仓库中只保留必要的索引; monorepo则是将相关的模块用单一的仓库统一管理。 社区偏向: 从目前前端工程的代码管理来看, monorepo 被很多超级repo选中。 Babel、vue-cli、create-react-app 都采用这种模式。 来源: https://www.cnblogs.com/amiezhang/p/11380983.html

Preferred way of using Bootstrap in Webpack

风流意气都作罢 提交于 2019-11-27 22:44:49
Greetings one and all, I have been playing around with Bootstrap for Webpack, but I'm at the point of tearing my hair out. I have literally gone through loads of blog articles and they either use the 7 months outdated 'bootstrap-webpack' plugin (which, surprisingly does not work out of the box) or.. They include the Bootstrap files through import 'node_modules/*/bootstrap/css/bootstrap.css'. Surely, there must be a cleaner and more efficient way of going about this? This is my current webpack.config.js file: var webpack = require('webpack'); var ExtractTextPlugin = require('extract-text

aptana3 汉化

只愿长相守 提交于 2019-11-27 22:32:41
点击Help-install new software,在work with输入 http://download.eclipse.org/technology/babel/update-site/R0.9.1/helios这个汉化地址,然后点Add输入名称,比如:Chinese,然后勾上下面的选择框prepend,加载完毕,选择simple chinese即可,最后就是下一步,重启,汉化成功 转载于:https://www.cnblogs.com/jivinliu/archive/2012/01/12/2320173.html 来源: https://blog.csdn.net/weixin_30367169/article/details/99779520

按需引入Element-ui步骤

柔情痞子 提交于 2019-11-27 20:26:31
由于之前做项目时,没考虑要页面优化等问题,所以把整个elementui全部引入,造成项目体积大,打开速度慢,所以最近把优化时,把element按需引入 第一步:引入element-ui,babel-plugin-component 执行cnpm install babel-plugin-component -D 第二步:修改.babelrc文件 第三步: 在src下新建一个文件夹,用于存放需要引用的组件 第四步:在main.js中引用 来源: CSDN 作者: 鲁小班吖 链接: https://blog.csdn.net/qq_34310906/article/details/96135130

Javascript: What's the difference between .call() and super()?

穿精又带淫゛_ 提交于 2019-11-27 18:51:24
问题 What's the difference between .call() and super()? Is super() just an es2015 thing? Or does .call() have more functionality? 回答1: super() calls the constructor of the class you extened class Foo extends Bar { constructor() { super(); // calls Bar's constructor } } call is a generic function you can use with any function function a() { console.log(this); }; function b() { console.log(this); }; function c() { console.log(this}; }; a.call("hello"); b.call(123); c.call({}); super knows which

Babel not transpiling arrow functions (Webpack)

筅森魡賤 提交于 2019-11-27 16:20:49
问题 When running webpack, and babel, the resulting bundle.js still contains arrow functions. This gives me a Syntax Error when running in Internet Explorer 10. I would like babel to replace the arrow functions with normal functions that IE can run. My package.json has the following devDependencies: "devDependencies": { "babel-cli": "^6.26.0", "babel-core": "^6.26.0", "babel-loader": "^7.1.4", "babel-preset-env": "^1.6.1", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babel

Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-react'

守給你的承諾、 提交于 2019-11-27 15:39:32
I'm stuck with the following error when trying to build a react app with Webpack4 and Babel7. ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-react' from '/Users/me/Desktop/reflask' - If you want to resolve "react", use "module:react" - Did you mean "@babel/react"? at Function.module.exports [as sync] (/Users/me/Desktop/reflask/node_modules/resolve/lib/sync.js:43:15) at resolveStandardizedName (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/files/plugins.js:101:31) at resolvePreset (/Users/me

SyntaxError with Jest and React and importing CSS files

时间秒杀一切 提交于 2019-11-27 14:17:18
I am trying to get my first Jest Test to pass with React and Babel. I am getting the following error: SyntaxError: /Users/manueldupont/test/avid-sibelius-publishing-viewer/src/components/TransportButton/TransportButton.less: Unexpected token > 7 | @import '../variables.css'; | ^ My package.json config for jest look like this: "babel": { "presets": [ "es2015", "react" ], "plugins": [ "syntax-class-properties", "transform-class-properties" ] }, "jest": { "moduleNameMapper": { "^image![a-zA-Z0-9$_-]+$": "GlobalImageStub", "^[./a-zA-Z0-9$_-]+\\.png$": "RelativeImageStub" }, "testPathIgnorePatterns