jest: Test suite failed to run, SyntaxError: Unexpected token import

Jest sets the env variable to test, so I had to add my presets to the env setting in .babelrc: { “plugins”: [“syntax-dynamic-import”, “transform-runtime”], “presets”: [ [ “es2015”, { “modules”: false } ], “react”, “stage-0” ], “env”: { “start”: { “presets”: [ “react-hmre” ] }, “test”: { “presets”: [“es2015”, “react”, “stage-0”] } } }

Preset files are not allowed to export objects

You’re using a combination of Babel 6 and Babel 7. There is no guarantee of compatibility across versions: “@babel/core”: “^7.0.0-beta.40”, “babel-cli”: “^6.26.0”, “babel-loader”: “^8.0.0-beta.0”, “babel-plugin-lodash”: “^3.3.2”, “babel-plugin-react-transform”: “^3.0.0”, “babel-preset-react”: “^6.24.1”, should be “@babel/core”: “^7.0.0-beta.40”, “@babel/cli”: “^7.0.0-beta.40”, “babel-loader”: “^8.0.0-beta.0”, “babel-plugin-lodash”: “^3.3.2”, “babel-plugin-react-transform”: “^3.0.0”, “@babel/preset-react”: “^7.0.0-beta.40”, and query: { presets: [‘react’, ‘es2015’], plugins: [‘transform-class-properties’] } would be … Read more

How to Inject Angular2 Http service into es6/7 Class?

Since you have @Decorators enabled in Babel …I’ll fine-tune this answer to work with your specific setup. 1. You’re missing HTTP_PROVIDERS The HTTP_PROVIDERS constant includes a number of functions required to handle HTTP requests/responses. import {Http, HTTP_PROVIDERS} from ‘angular2/http’; @Component({ selector: ‘login’, providers: [ HTTP_PROVIDERS ] }) 2. You need to desugar the DI (Dependency … Read more

Running Mocha 6 ES6 tests with Babel 7, how to set up?

Testing in ES6 with Mocha and Babel 7. Look here: https://dev.to/bnorbertjs/my-nodejs-setup-mocha–chai-babel7-es6-43ei or http://jamesknelson.com/testing-in-es6-with-mocha-and-babel-6/ npm install –save @babel/runtime npm install –save-dev @babel/plugin-transform-runtime And, in .babelrc, add: { “presets”: [“@babel/preset-env”], “plugins”: [ [“@babel/transform-runtime”] ] }

Babel 6.0.20 Modules feature not work in IE8

By default, Babel 6.x requires you to enable an explicit set of transformations. The standard es2015 preset converts ES6 to ES5, however IE8 is not ES5-compatible. In this case, if you look at the plugins list, you will see transform-es3-member-expression-literals transform-es3-property-literals These will convert your properties to be compatible with IE8. Generally in Babel 6.x … Read more

How to setup TypeScript + Babel + Webpack?

Babel 7 does not need ts-loader. As of Babel 7 the ts-loader is unnecessary, because Babel 7 understands TypeScript. Complete details of a TypeScript + Babel7 + Webpack setup are here. An overview of the set up without ts-loader. Install Babel’s TypeScript support. Only @babel/preset-typescript is mandatory; the other three add additional features that TypeScript … Read more