babeljs

@babel/plugin-proposal-class-properties not being picked up when compiling

≯℡__Kan透↙ 提交于 2020-07-23 07:19:18
问题 I am trying to incorporate React Native Calendars into my React webapp. I have run npm install --save react-native-calendars and then added the Calendar component to a page (this is then rendered by App.js ) import React from 'react'; import {Calendar} from 'react-native-calendars'; class CalendarPage extends React.Component{ render(){ return ( <div> <h1>This is the calendar</h1> <Calendar /> </div> ) } } export default CalendarPage; When I run npm start (or save the file when the server is

Babel-Loader Syntax error on npm run build

删除回忆录丶 提交于 2020-07-18 21:00:29
问题 I am not very strong with webpack and am trying to update webpack from V3 to V4 and have managed to update my webpack config to the point where its not throwing depreciation errors at me, but I am now stuck on a syntax error from babel-loader: Module build failed (from ./node_modules/babel-loader/lib/index.js): /path/react/node_modules/schema-utils/dist/util/hints.js:16 const currentSchema = { ...schema SyntaxError: Unexpected token ... In my webpack config I have this: test: /\.(js|jsx)$/,

Laravel Mix: Configure Babel for IE11 compatibility (transformations and polyfills)

流过昼夜 提交于 2020-07-18 07:44:11
问题 In a Laravel 6 application with Laravel-Mix 4, and using the Vue preset, I need to compile my JavaScript code to be compatible for IE11. This means adding any polyfills for missing functions, compiling out arrow functions, and so on. Out of the box, this is not done. My test code in resources/js/app.js : //require('./bootstrap'); let test = [1, 2, [3, 4]]; console.log( test.flat().map((x) => 2*x) ); With default config, laravel mix does not appear to compile JavaScript code, but only do some

React: ReferenceError: regeneratorRuntime is not defined

别来无恙 提交于 2020-07-09 03:10:01
问题 I am trying to use async and await in my react application. onSubmit = async (model) => { await this.setState({ data: model }); } After adding the above code i get an error in my browser console. ReferenceError: regeneratorRuntime is not defined .babelrc { "presets": ["@babel/preset-env", "@babel/preset-react"], "plugins": [ "@babel/plugin-proposal-class-properties" ], "sourceMaps": "inline" } webpack.config.js const path = require("path"); const WebpackShellPlugin = require("webpack-shell

Why Babel 7 uses require() function for browser which knows nothing about it?

醉酒当歌 提交于 2020-07-03 03:04:19
问题 I try to use d3.js in my module. I use Babel 7 for transpiling my code sources. This is my package.json : { "name": "d3_learning", "version": "1.0.0", "description": "", "main": "index.js", "directories": { "test": "test" }, "scripts": { "build": "babel src --out-dir dist --source-maps --minified --no-comments", "build:watch": "npm run build -- -w" }, "babel": { "presets": [ [ "@babel/preset-env", { "useBuiltIns": "entry", "targets": { "firefox": "64", "opera": "57", "chrome": "71", "edge":

Why Babel 7 uses require() function for browser which knows nothing about it?

…衆ロ難τιáo~ 提交于 2020-07-03 03:02:19
问题 I try to use d3.js in my module. I use Babel 7 for transpiling my code sources. This is my package.json : { "name": "d3_learning", "version": "1.0.0", "description": "", "main": "index.js", "directories": { "test": "test" }, "scripts": { "build": "babel src --out-dir dist --source-maps --minified --no-comments", "build:watch": "npm run build -- -w" }, "babel": { "presets": [ [ "@babel/preset-env", { "useBuiltIns": "entry", "targets": { "firefox": "64", "opera": "57", "chrome": "71", "edge":

React/Typescript /VScode - an import path cannot end with a '.tsx' extension

拟墨画扇 提交于 2020-06-27 12:36:56
问题 I have a series of react projects which I have converted to typescript. Some of these use webpack, and some of them just use babel as they're libraries which are consumed by the other (webpack) projects/actual applications. I've converted everything to typescript without problems, except in one non-webpack project, where I receive the error 'an import path cannot end with a .tsx extension', for example on import LoadingLogo from '../ui/LoadingLogo.tsx'; I can get round this by omitting the

webpack-dev-server: how to get error line numbers of orignal files

醉酒当歌 提交于 2020-06-25 09:19:08
问题 With webpack-dev-server running it seems that all errors in the output are pointing to line numbers in the bundle.js and not the original source file. How do I get line numbers of the original source files? I'm using webpack with babel for ES2015 js. webpack.config.dev.js const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { devtool: '#source-map', entry: [ `webpack-dev-server/client?http://${process.env

SyntaxError: Cannot use import statement outside a module

本小妞迷上赌 提交于 2020-06-07 08:05:47
问题 I've got an ApolloServer project that's giving me trouble, so I thought I might update it and ran into issues when using the latest Babel. My "index.js" is: require('dotenv').config() import {startServer} from './server' startServer() And when I run it I get the error "SyntaxError: Cannot use import statement outside a module". First I tried doing things to convince TPTB* that this was a module (with no success). So I changed the "import" to a "require" and this worked. But now I have about

How do I inject a dependency in a class definition of a component?

馋奶兔 提交于 2020-05-27 04:36:05
问题 I have this class-defined component (transpiled later by webpack and babel back into ES5). I need to use the $http service in one of its methods. How do I do that? Where do I inject $http as a dependency? If I do it in the constructor arguments, I get an error as if I hadn't injected it at all. Maybe classes is not the way to go here? angular.module('myApp').component('home', { template: require('./home.component.html'), controller: class HomeCtrl { constructor() { } doMe() { $http.get('http: