babel

Use .babelrc from different path

纵然是瞬间 提交于 2019-12-23 11:43:06
问题 Is there a way to provide the path to the .babelrc file to babel-cli? Something like: babel src --out-dir lib --config random-folder/sub-folder/.babelrc 回答1: Considering the version you are using you may try extends or babelrc http://henryzoo.com/babel.github.io/docs/usage/options/ 回答2: You can put the .babelrc file in a shared parent directory of the other 5 modules as the lookup behavior of babel regarding the .babelrc is: Babel will look for a .babelrc in the current directory of the file

React Native - Jest: Broken since update to 0.56. How to fix it?

让人想犯罪 __ 提交于 2019-12-23 09:46:55
问题 Ever since upgrading to the new React Native version my tests are broken. Environment Here is my environment: React Native Environment Info: System: OS: macOS High Sierra 10.13.4 CPU: x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz Memory: 486.81 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 9.4.0 - /usr/local/bin/node npm: 6.1.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3 IDEs: Android Studio:

Babel - regeneratorRuntime is not defined, when using transform-async-to-generator plugin

雨燕双飞 提交于 2019-12-23 07:29:44
问题 I am not able to setup babel correctly for the usage of async / await. I am using babel 7 and webpack 4. I do not want to use babel-polyfill if possible! My babelrc file: { "presets": [[ "@babel/env", {"modules": false} ]], "plugins": [ "syntax-dynamic-import", "transform-async-to-generator" ] } Code: async function init() { const loaderData = await initLoader(); initCmp(loaderData) .then(initApi(loaderData.key)) .catch(); } init(); And Error: refactor.main.js:18 Uncaught ReferenceError:

Babel 7 - Decorators transform doesn't work with babel-loader

纵然是瞬间 提交于 2019-12-23 07:29:07
问题 I have a problem with decorators in React with mobX app. And it works ok with .babelrc , but I also have babel-loader with webpack . I copy babel config to webpack config, but it doesn't work. I checked all solutions that I can found in google, but they all refers to bebelrc , not webpack config. My webpack config: const path = require('path'); const webpack = require('webpack'); module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', 'babel

Babel Plugin Class Properties – React Arrow Functions

痴心易碎 提交于 2019-12-23 02:56:19
问题 I am running a React project using npm. After hours of research and experimenting, everywhere says I have to add the following code to my ".babelrc" file, which I do not have in my directory and cannot create: { "plugins": [ ["@babel/plugin-proposal-class-properties", { "loose": true }] ] } But this leads to the following error when I run the code: ERROR in ./src/components/NavBar/Menu.js Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: /Users/ymoondhra

Unable to run a node.js file with @babel/preset-env

拜拜、爱过 提交于 2019-12-23 01:52:09
问题 I'm trying to run a simple node.js file which needs the @babel/preset-env preset. The moment I run the js file, I get a message saying Requires Babel “7.0.0-0” but was loaded with “6.26.3” To replicate the issue, please try the following in a new folder: 1. Run the following commands npm init npm install @babel/register npm install @babel/core@^7.2.2 npm install @babel/preset-env Create a .babelrc file with the following { "presets": ["@babel/preset-env"], "plugins": [] } Create a sample emp

Broken autobinding in arrow function for referenced node modules when using react-native with react-relay

本小妞迷上赌 提交于 2019-12-22 09:36:17
问题 I'm using react-native and react-relay, therefore I've the following .babelrc file: { "sourceMaps": "both", "presets": [ "./plugins/babelRelayPlugin", "react-native" ], "passPerPreset": true } Adding a dependency which uses arrow functions in their components as the MKIconToggle from react-native-material-kit (https://github.com/xinthink/react-native-material-kit) doesn't get transpiled correctly and the this reference is lost/wrong. The original code which ultimately causes the error looks

Error using ES7 async/await with node, webpack and babel-loader

会有一股神秘感。 提交于 2019-12-22 06:37:03
问题 I'm trying to use javascript ES7 syntax on the server using node.js with webpack and babel-loader (es2015 + stage-0 presets). I've gotten it to work with babel-node but when I run webpack I get the following error at the async keyword (9:22 is after the async keyword): ERROR in ./src/server.js Module parse failed: C:\dev\node-async-sample\src\server.js Unexpected token (9:22) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (9:22) I've put the code on

Babel doesn't recognize jinja2 extraction method for language support

╄→гoц情女王★ 提交于 2019-12-22 05:58:12
问题 I'm adding language translation support to my project. The code is on Python and has jinja2 in the html files, and Javascript. I'm trying to use Babel to do the translation, but it doesn't recognize the extraction method of jinja2. Maybe I'm using an incorrect name for it. This is my ini file: # Extraction from Python source files [python: **.py] # Extraction from Jinja2 template files [jinja2: **.html] # Extraction from JavaScript files [javascript: **.js] extract_messages = $._, jQuery._

babel 7 don't compile class ES6 which in node_modules

别等时光非礼了梦想. 提交于 2019-12-22 04:18:14
问题 I have error in IE11 SCRIPT1002: Syntax error (problem with class syntax). My simple code with 2 lines: import { struct } from 'superstruct'; console.log('finished'); I wan't that my babel7 compile class into ES5 code I have tried write .babelrc file : { "presets": [ [ "@babel/preset-env", { "targets": { "ie": "11" } } ] ] } and https://babeljs.io/docs/en/babel-plugin-transform-classes haven't fixed too Update : I have tried use @babel/plugin-preset-es2015 which convert class in ES5 code but