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

“unexpected token import” in Nodejs5 and babel?

From the babel 6 Release notes: Since Babel is focusing on being a platform for JavaScript tooling and not an ES2015 transpiler, we’ve decided to make all of the plugins opt-in. This means when you install Babel it will no longer transpile your ES2015 code by default. In my setup I installed the es2015 preset … Read more

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

This is related to compact option of Babel compiler, which commands to “not include superfluous whitespace characters and line terminators. When set to ‘auto’ compact is set to true on input sizes of >100KB.” By default its value is “auto”, so that is probably the reason you are getting the warning message. See Babel documentation. … Read more

VSCode Linter ES6 ES7 Babel linter

How I proceed: install globally eslint : npm install -g eslint install babel-eslint : npm install –save-dev babel-eslint install eslint-plugin-react : npm install –save-dev eslint-plugin-react create .eslintrc file in you root directory. here is my config: { “env”: { “browser”: true, “node”: true, “es6”: true, “jest”: true, “jquery”: true }, “parser”: “babel-eslint”, “parserOptions”: { “ecmaVersion”: … Read more

Requires Babel “7.0.0-0” but was loaded with “6.26.3”

Test which version you are running with cmd babel -V If it is not verion 7 or higher npm uninstall babel-cli -g npm uninstall babel-core -g And npm install @babel/cli -g npm install @babel/core -g If you are using Jest run npm install babel-core@7.0.0-bridge.0 –save-dev Uninstall and reinstall @babel/node solves the problem if you do … Read more

Babel 7 – ReferenceError: regeneratorRuntime is not defined

Updated Answer: If you are using Babel 7.4.0 or newer, then @babel/polyfill has been deprecated. Instead, you will want to use the following at the top of your main js file (likely index.js or similar): import “core-js/stable”; import “regenerator-runtime/runtime”; Install these packages either with npm: npm install –save core-js npm install –save regenerator-runtime or with … Read more

Code inside DOMContentLoaded event not working

It’s most likely because the DOMContentLoaded event was already fired at this point. The best practice in general is to check for document.readyState to determine whether or not you need to listen for that event at all. if (document.readyState !== ‘loading’) { console.log(‘document is already ready, just execute code here’); myInitCode(); } else { document.addEventListener(‘DOMContentLoaded’, … Read more

ES6 `export * from import`?

Yes, ES6 supports directly exporting imported modules: export { name1, name2, …, nameN } from …; export {FooAction, BarAction} from ‘./action_creators/index.js’ You can also re-export all exports of the imported module using the * syntax: export * from …; export * from ‘./action_creators/index.js’; More info on MDN.

Service mocked with Jest causes “The module factory of jest.mock() is not allowed to reference any out-of-scope variables” error

You need to store your mocked component in a variable with a name prefixed by “mock”. This solution is based on the Note at the end of the error message I was getting. Note: This is a precaution to guard against uninitialized mock variables. If it is ensured that the mock is required lazily, variable … Read more

tech