babeljs

React bootstrap dropdown compatibility with webpack and babel

删除回忆录丶 提交于 2020-04-30 11:42:07
问题 i was using react-bootstrap components without any problem before adding webpack to my react project, now i am experiencing some weird things. Navbar Component: import React, { Component } from 'react'; import { Link } from 'react-router-dom'; import {Dropdown, DropdownButton} from 'react-bootstrap'; class Navbar extends Component { constructor(props) { super(props); this.state = {}; } toggleOffcanvas() { document.querySelector('.sidebar-offcanvas').classList.toggle('active'); }

“You may need an appropriate loader to handle this file type” with Webpack and Babel

人走茶凉 提交于 2020-04-23 06:34:22
问题 I am trying to use Webpack with Babel to compile ES6 assets, but I am getting the following error message: You may need an appropriate loader to handle this file type. | import React from 'react'; | /* | import { render } from 'react-dom' Here is what my Webpack config looks like: var path = require('path'); var webpack = require('webpack'); module.exports = { entry: './index', output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/dist/' }, module: { loaders: [ {

“You may need an appropriate loader to handle this file type” with Webpack and Babel

落爺英雄遲暮 提交于 2020-04-23 06:27:31
问题 I am trying to use Webpack with Babel to compile ES6 assets, but I am getting the following error message: You may need an appropriate loader to handle this file type. | import React from 'react'; | /* | import { render } from 'react-dom' Here is what my Webpack config looks like: var path = require('path'); var webpack = require('webpack'); module.exports = { entry: './index', output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/dist/' }, module: { loaders: [ {

ReactJS inside .NET framework project - Cannot use import statement outside a module

左心房为你撑大大i 提交于 2020-04-14 06:01:08
问题 I've tried to use reactJS inside .net framework MVC application. View: <script src="https://unpkg.com/react@16/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.js"></script> <div id="root"></div> @Scripts.Render("~/Scripts/ReactJS/test.jsx") test.jsx: import React from 'react'; import ReactDOM from 'react-dom'; const App = () => <div>Hello

How to integrate ES6 Module syntax in RequireJS project

允我心安 提交于 2020-04-11 02:07:13
问题 I'm looking for a way to use ES6 Modules (import/export) syntax in my current RequireJS project. I can run my project directly in a recent browser, without build or Babel transformation. I build my project with r.js and Babel only for production. We would like to start building ES6 modules and use it with requireJS. Is there a way to do that ? NB : RequireJS does not load dependencies written in ES6. 回答1: Yes, RequireJS should be compatible with Babel's es2015-modules-umd plugin. So you

How to integrate ES6 Module syntax in RequireJS project

故事扮演 提交于 2020-04-11 02:06:50
问题 I'm looking for a way to use ES6 Modules (import/export) syntax in my current RequireJS project. I can run my project directly in a recent browser, without build or Babel transformation. I build my project with r.js and Babel only for production. We would like to start building ES6 modules and use it with requireJS. Is there a way to do that ? NB : RequireJS does not load dependencies written in ES6. 回答1: Yes, RequireJS should be compatible with Babel's es2015-modules-umd plugin. So you

`regeneratorRuntime` is not defined when running Jest test

非 Y 不嫁゛ 提交于 2020-04-07 17:38:10
问题 The title pretty much explains what I'm facing. I'm trying to test a React component that has some state, and I attempt to provide my store to the component in order to get what it needs. When I run the test of the component using Jest, I get the following error: ReferenceError: regeneratorRuntime is not defined I've determined through some reading that this is caused by babel-polyfill or regenerator-runtime not being applied correctly to Jest. However, I've tried installing both of those

Optional Chaining Operator in React and babel

纵饮孤独 提交于 2020-03-24 05:55:32
问题 In my project I config babel: { "presets": ["react", "es2015","stage-1", "transform-optional-chaining"], "plugins": ["transform-runtime"] } And this is my devDependencies in package.json : "devDependencies": { "babel-cli": "^7.0.0-alpha.19", "babel-loader": "^7.1.5", "babel-plugin-module-resolver": "^3.1.1", "babel-plugin-transform-optional-chaining": "^7.0.0-beta.3", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.24.1", "babel-preset-stage-1": "^6.24.1", "copy

Optional Chaining Operator in React and babel

孤者浪人 提交于 2020-03-24 05:53:58
问题 In my project I config babel: { "presets": ["react", "es2015","stage-1", "transform-optional-chaining"], "plugins": ["transform-runtime"] } And this is my devDependencies in package.json : "devDependencies": { "babel-cli": "^7.0.0-alpha.19", "babel-loader": "^7.1.5", "babel-plugin-module-resolver": "^3.1.1", "babel-plugin-transform-optional-chaining": "^7.0.0-beta.3", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.24.1", "babel-preset-stage-1": "^6.24.1", "copy

How to resolve “Cannot use import statement outside a module” in jest

ぃ、小莉子 提交于 2020-03-18 04:38:05
问题 I have a React application (not using Create React App) built using TypeScript, Jest, Webpack, and Babel. When trying to run "yarn jest", I get the following error: I have tried removing all packages and re-adding them. It does not resolve this. I have looked at similar questions and documentation and am still misunderstanding something. I went so far as to follow another guide for setting up this environment from scratch and still received this issue with my code. Dependencies include...