babeljs

Babel causing Uncaught TypeError in transpiled ES5 Vue component code

半城伤御伤魂 提交于 2019-12-23 03:51:34
问题 Working on a small Node.js project that needs to send JSON objects over sockets. I discovered that JsonSocket (https://github.com/sebastianseilund/node-json-socket) served my needs and running the simple server/client demos provided by that author works great. I am adapting the demo Client code (https://github.com/sebastianseilund/node-json-socket#simple-clientserver-example) to a Vue.js-Babel-Browserify project framework and placing the code in a .vue component file. Changes primarily

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

react native init: ReferenceError: [BABEL] Unknown option: Unknown option: base.optional

拥有回忆 提交于 2019-12-22 14:16:28
问题 I'm getting the following error upon running react-native init testNative ReferenceError: [BABEL] /Users/m/git/testNative/node_modules/react-native/local-cli/bundle/bundle.js: Unknown option: base.optional at Logger.error (/Users/m/git/testNative/node_modules/babel-core/lib/transformation/file/logger.js:41:11) at OptionManager.mergeOptions (/Users/m/git/testNative/node_modules/babel-core/lib/transformation/file/options/option-manager.js:289:18) at OptionManager.init (/Users/m/git/testNative

Concatenate imports in modules in babeljs

爱⌒轻易说出口 提交于 2019-12-22 14:04:47
问题 I am new to all ES6 transpiling and I was planning on using BabelJS. Is there a way to concatenate scripts with there imports in babelJS I have the following home.js imports home/home-navbar and home/home-slider I want the output to contain both home/home-navbar and home/home-slider but put them all in one file home.js Can I do this in BabelJS? and if not what would be the proper way to do it? 回答1: Can I do this in BabelJS? No, not yet. what would the proper way to do it? Not sure about the

Arrow function is considered unexpected token in React component using babel [closed]

為{幸葍}努か 提交于 2019-12-22 05:12:14
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have this function in one of my react components. export default class EventTags extends React.Component{ showAll () => { this.setState({ showAll: true, showBtn: false }); } } When webpack watch hits it I get an unexpected token error on the arrow function. I have the transform-es2015-arrow-functions plugin

Webpack module build failed unexpected token (rails react build)

假如想象 提交于 2019-12-22 05:04:24
问题 I working on a react/rails build and working through using webpack and babel for the first time. I'm using two files and getting the error : ERROR in ./app/assets/frontend/main.jsx Module build failed: SyntaxError: /Users/cls/GitHub/rails_react/app/assets/frontend/main.jsx: Unexpected token (6:6) Line 6 is: <Greet /> This is the main.jsx file import Greet from './greet'; class Main extends React.Component { render() { return ( <Greet /> ); } } let documentReady = () => { React.render( <Main /

static class property not working with Babel

别等时光非礼了梦想. 提交于 2019-12-21 19:16:17
问题 I am using JSDOC and all it supported npm plugins to create nice documentation. Getting hard time when jsdoc is running and parsing JSX file it always throws error as below near = sign SyntaxError: unknown: Unexpected token export default class SaveDesign extends Component { static displayName = 'SaveDesign'; } conf.json file { "source": { "include": [ "src/app/test.js", "src/app/components/Modals/Template/SaveDesign.jsx"], "exclude": [ "src/fonts", "src/icons", "src/less", "src/vector-icon"

How to resolve the Webpack 2 loaderUtils.parseQuery() Warning?

只愿长相守 提交于 2019-12-21 17:53:27
问题 When I compiled my files by using Webpack2. It showed the following warning: "loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56" I checked the github page and did not find out how to resolve this problem. This is my config: // webpack 2 configuration // https://webpack.js.org/guides/migrating/ const webpack = require('webpack'); const path = require('path'); const ExtractTextPlugin = require('extract-text

How can I mock an imported module in ecmascript 6?

空扰寡人 提交于 2019-12-21 16:58:43
问题 I have a test-setup with mocha, babel and node that is meant to test ecmascript 6 code. Does anybody have any suggestions on how to mock away imports in the module under test? 回答1: Imports and exports in ES2015 are part of the language itself, and are designed to be statically analysable. They therefore cannot be manipulated at runtime, and that makes dynamic mocking impossible. I would recommend that you take a look at implementing some form of lightweight dependency injection framework, or

webpack, babel: es6 import vs. require for Fabric.js

走远了吗. 提交于 2019-12-21 07:22:12
问题 I am using webpack and babel in my development tool chain; when running the following code: import * as fabric from 'fabric'; var canvas = new fabric.Canvas('canvas'); I get the following error: _fabric2.default.Canvas is not a constructor Whereas the same code works fine if I use require('fabric'); instead of import . I tried different ways of calling import but none of them worked. My linting tool complains of the undefined fabric variable, so I would like to have it properly defined.