babel

How to remove global “use strict” added by babel

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm using function form of "use strict" and don't want global form which Babel adds after transpilation. The problem is I'm using some libraries that aren't using "use strict" mode and it might throw error after scripts are concatenated 回答1: Babel 5 You'd blacklist "useStrict" . For instance here's an example in a Gruntfile: babel : { options : { blacklist : [ "useStrict" ], // ... }, // ... } Babel 6 Since Babel 6 is fully opt-in for plugins now , instead of blacklisting useStrict , you just don't include the strict-mode plugin .

Webpack babel 6 ES6 decorators

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've got a project written in ES6 with webpack as my bundler. Most of the transpiling works fine, but when I try to include decorators anywhere, I get this error: Decorators are not supported yet in 6.x pending proposal update . I've looked over the babel issue tracker, and haven't been able to find anything on it there, so I'm assuming I'm using it wrong. My webpack config (the relevant bits): loaders : [ { loader : 'babel' , exclude : /node_modules/ , include : path . join ( __dirname , 'src' ), test : /\.jsx?$/ , query : {

“unexpected token import” in Nodejs5 and babel?

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: In js file, i used import to instead of require import co from 'co' ; And tried to run it directly by nodejs since it said import is 'shipping features' and support without any runtime flag ( https://nodejs.org/en/docs/es6/ ), but i got an error import co from 'co' ; ^^^^^^ SyntaxError : Unexpected token import Then i tried to use babel npm install - g babel - core npm install - g babel - cli npm install babel - core //install to babel locally, is it necessary? and run by babel - node js . js still got same error, unexpected token

BABEL Note: The code generator has deoptimised the styling of “app.js” as it exceeds the max of \"100KB in Meteor

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My app.js file in meteor has exceeded the limit of 100KB How do I fix this now? Does It affects my application? Is that because of installing packages? 回答1: This is not a real issue. Just a warning. When babel compiles some code, it try to offer a readable output, but when files become big (>100KB), babel considers (by default) that it's not useful to keep this option enabled (because yes it's an option, see https://stackoverflow.com/a/30879872/988941 for more information). It's not a problem to keep it. If you don't care about readability,

babel + path + node 6.x: TypeError: Path must be a string. Received undefined

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been trying to update my nodejs version to 6.x but the following errors always appear everytime: path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path)); ^ TypeError: Path must be a string. Received undefined at assertPath (path.js:7:11) at Object.dirname (path.js:1326:5) at /usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:36 at /usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:396:22 at Array.map (native) at OptionManager.resolvePresets (

require('babel/register') doesn't work

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have isomorphic app written in ES6 on client with Babel transpiler . I want my express server to have the same ES6 syntax as client code. Unfortunately require('babel/register') doesn't work.. server.js require('babel/register'); // doesn't work // require('babel-core/register); doesn't work.. const env = process.env.NODE_ENV || 'development'; const port = process.env.NODE_PORT || 1995; const http = require('http'); const express = require('express'); const address = require('network-address'); let app = express(); app.set('port', port);

ava: SyntaxError: Unexpected token import

匿名 (未验证) 提交于 2019-12-03 02:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So ava comes with build-in ES2015 support , which works fine for my actual test files. However, when I do import {newUser, createUser, login} from './helpers/user'; I can't use import and export in the helper file, I then get: Users/rowe/Code/fv/foxvision-api/test/api/helpers/user.js:1 (function (exports, require, module, __filename, __dirname) { import request from 'supertest'; SyntaxError: Unexpected token import I have no specific babel configuration set up as for the test files it works out of the box. Can anyone explain to me why the

Unexpected “Uncaught TypeError: XXX is not a constructor” errors with Babel and ES6

匿名 (未验证) 提交于 2019-12-03 02:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am giving a try to Webpack, and am giving a try to the instructions in this tutorial , give or take a few custom things. This is simple code, really, but I'm quite puzzled about this error, and feel this is something silly that I missed. I defined two ES6 classes, each corresponding to a Handlebars template, and my app's entrypoint is supposed to replace the placeholder HTML in the index file by their contents: Entrypoint: import './bloj.less' // If we have a link, render the Button component on it if (document.querySelectorAll('a').length

Karma, PhantomJS and es6 Promises

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am writing a JavaScript library that uses the new es6 promises. I can test the library in Firefox because promises are defined. However, when I try to test my code with Karma and PhantomJS, I get the error Can't find variable: Promise. . I am guessing this is because the PhantomJS browser doesn't support es6 promises yet. How can I configure Karma to bring in the polyfill for promises? 回答1: You can pull in the Babel polyfill by simply installing Babel Polyfill : npm install --save-dev babel-polyfill and then include the polyfill file

Babel 6 transform-runtime: $export is not a function

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to incorporate Babel's transform-runtime to make my code compatible with IE9. But since integrating it, the code won't even run on Chrome. I get the error Uncaught TypeError: $export is not a function on es6.object.define-property.js:3 . Without the "transform-runtime" line in my .babelrc, everything runs fine. Any ideas? Here is my .babelrc : { "plugins": [ "transform-runtime" ], "presets": [ "es2015", "react" ] } And my webpack.config.js : var webpack = require('webpack'); var commonsPlugin = new webpack.optimize