babeljs

Module.exports and es6 Import

ぃ、小莉子 提交于 2020-01-11 19:58:27
问题 React with babel. I have this confusion with imports and module.exports. I assume babel when converting the ES6 code to ES5 converts the imports and exports to require and module.exports respectively. If i export a function from one module and import the function in another module, the code executes fine. But if i export the function with module.exports and import using "import" the error is thrown at runtime saying it is not a function. I cooked up an example. // Tiger.js function Tiger() {

Module.exports and es6 Import

风格不统一 提交于 2020-01-11 19:58:05
问题 React with babel. I have this confusion with imports and module.exports. I assume babel when converting the ES6 code to ES5 converts the imports and exports to require and module.exports respectively. If i export a function from one module and import the function in another module, the code executes fine. But if i export the function with module.exports and import using "import" the error is thrown at runtime saying it is not a function. I cooked up an example. // Tiger.js function Tiger() {

Upgrading from Babel 5.8.35 to 6.0.0 will not compile app.js with a SyntaxError and unexpected token

我的未来我决定 提交于 2020-01-07 08:22:47
问题 I am in the process of upgrading all my ReactJS components with webpack . In the process I have not been able to upgrade from babel 5 to 6. When I do so I get the following stack trace within my app.js class. This code worked fine with : "babel-core": "^5.8.35", "babel-loader": "^5.3.3", But broke once upgrading to 6.0.0 The code is: var objectListMap = this.state.objects.map(object => <EntityObject key={object.entity._links.self.href} object={object} jsonAttributes={jsonAttributes}

Get access to the class static properties using BabelJS 6

允我心安 提交于 2020-01-07 05:05:13
问题 Below is the minimal app which demonstrate the issue: 'use strict'; var _ = require('underscore'); class Model { constructor(value) { this._value = value; } get value() { return this._value; } toJS() { return this.value; } } class ObjectModel extends Model { static properties = {}; constructor(value) { super(_.extend({}, new.target.properties, _.pick(value, _.keys(new.target.properties)))); } } class PostModel extends ObjectModel { static properties = { title: 'Hello' /* content: '<p>Lorem

babelify pipe results in: The code generator has deoptimised the styling of “/…/jquery.js” as it exceeds the max of “100KB”

白昼怎懂夜的黑 提交于 2020-01-06 23:49:32
问题 I'm trying to create a single js file containing jquery, bootstrap and reactjs components using a gulp task: app.jsx: var React = require('react'); var ReactDOM = require('react-dom'); var HelloWorld = require('./Application.jsx'); var $, jQuery = require('../../libraries/jquery/dist/jquery'); var bootstrap = require('../../libraries/bootstrap-sass/assets/javascripts/bootstrap'); ReactDOM.render( <Application />, document.getElementById('example') ); gulp task: gulp.task('js', function () {

Integrate ECMAScript-6 into existing AngularJS project

自作多情 提交于 2020-01-06 19:57:52
问题 I'm trying to integrate ECMA6 into existing Angular project. And I'm looking for a best practise for some issues we have. All components (and we have a lot) have following file structure: -app/ --components/ --somemodul/ --somemodul.mdl.js --somemodul.drv.js --somemodul.ctrl.js --somemodul.srv.js --somemodul.tmpl.html -app.js //somemodul.mdl.js (function () { angular.module('somemodul', []); //initiate module })() //somemodul.drv.js (function () { angular.module('somemodul') .directive(

How to prevent dynamic import to duplicate a bundle?

佐手、 提交于 2020-01-06 08:43:09
问题 I am creating a React/Redux App compiled with Babel and bundled by Webpack. I want to implement a plugin feature. So I use Code Splitting with Dynamic import() to divide the main bundle for each plugin. However, if I need the same plugin in many place, Webpack will bundle a bundle for any import() used and iterate it (0.bundle.js, 1.bundle.js, ...). I try to use webpackChunkName: "MyPlugin" in comment in import() thinking that if I import a bunble with the same chunk name, it will replace the

Error loading graphql with react-relay modern

▼魔方 西西 提交于 2020-01-05 05:52:09
问题 I am developing an react-native application using Relay for working with graphql. Before earlier versions I have been using Relay classic with RootContainer and renderer following the 'sibelius' react-native-relay-example also combined with these two posts: first and second. So I have changed the react-relay version from 0.10.0 to 1.0.0 and for starters put a simple query at first screen using relay modern implementation. I did not change babel-relay-plugin. When ever I run the app I get

Modules exported using es6 syntax for the browser

雨燕双飞 提交于 2020-01-04 13:44:23
问题 I have a module module-A which has the following in index.js import SomeModule from './lib/some-module' import AnotherModule from './lib/another-module' module.exports ={ SomeModule: SomeModule, AnotherModule: AnotherModule } I then use this module-A from another module-B : import SomeModule from `module-A` I now want to build module-B for the browser, so I use browserify from the module-B cwd: [I am using babel 6.0] browserify index.js -t [ babelify --presets [ es2015 ] ] This throws an

Sbt: Unresolvable webjar dependencies

若如初见. 提交于 2020-01-04 10:58:11
问题 I've created new play framework app using a angular-seed-play-java template. So now I'm trying to install Babel as a transpiler. Following these instructions I've added sbt-babeljs to my plugins.sbt https://github.com/stonexx/sbt-babeljs . Then I want to install bubel-core locally. I got a webjar from the http://www.webjars.org/ and inserted the following line into my build.sbt . "org.webjars.npm" % "babel-core" % "6.11.4" I'm getting unresolved dependency error: [error] (*:update) sbt