What does “The code generator has deoptimised the styling of [some file] as it exceeds the max of “100KB”” mean?

I added a new npm package to my project and require it in one of my modules. Now I get this message from webpack, build modulesNote: The code generator has deoptimised the styling of “D:/path/to/project/node_modules/ramda/dist/ramda.js” as it exceeds the max of “100KB”. What does it mean? Do I need to take some action? 11 Answers … Read more

“unexpected token import” in Nodejs5 and babel?

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 … Read more

Null-safe property access (and conditional assignment) in ES6/2015

Is there a null-safe property access (null propagation / existence) operator in ES6 (ES2015/JavaScript.next/Harmony) like ?. in CoffeeScript for example? Or is it planned for ES7? var aThing = getSomething() … aThing = possiblyNull?.thing This will be roughly like: if (possiblyNull != null) aThing = possiblyNull.thing Ideally the solution should not assign (even undefined) to … Read more

Export multiple classes in ES6 modules

I’m trying to create a module that exports multiple ES6 classes. Let’s say I have the following directory structure: my/ └── module/ ├── Foo.js ├── Bar.js └── index.js Foo.js and Bar.js each export a default ES6 class: // Foo.js export default class Foo { // class definition } // Bar.js export default class Bar { … Read more

Unable to access React instance (this) inside event handler [duplicate]

This question already has answers here: How to access the correct `this` inside a callback (13 answers) Closed 2 years ago. I am writing a simple component in ES6 (with BabelJS), and functions this.setState is not working. Typical errors include something like Cannot read property ‘setState’ of undefined or this.setState is not a function Do … Read more

ES6 exporting/importing in index file

I am currently using ES6 in an React app via webpack/babel. I am using index files to gather all components of a module and export them. Unfortunately, that looks like this: import Comp1_ from ‘./Comp1.jsx’; import Comp2_ from ‘./Comp2.jsx’; import Comp3_ from ‘./Comp3.jsx’; export const Comp1 = Comp1_; export const Comp2 = Comp2_; export const … Read more

babel-loader jsx SyntaxError: Unexpected token [duplicate]

This question already has answers here: Babel file is copied without being transformed (10 answers) Closed 5 years ago. I’m a beginner in React + Webpack. I found a weird error in my hello world web app. I’m using babel-loader in webpack to help me convert jsx into js, but it seems like babel can’t … Read more

How do I generate sourcemaps when using babel and webpack?

I’m new to webpack, and I need a hand in setting up to generate sourcemaps. I’m running webpack serve from the command line, which compiles successfully. But I really need sourcemaps. This is my webpack.config.js. var webpack = require(‘webpack’); module.exports = { output: { filename: ‘main.js’, publicPath: ‘/assets/’ }, cache: true, debug: true, devtool: true, … Read more