babel

Why does React require Babel and Webpack to work?

时间秒杀一切 提交于 2019-12-03 01:59:28
I was looking at the wiki page of vue.js and saw this: When compared to React development, Vue can be integrated to an existing web application much more easily. Normally, a web application can start using Vue immediately by simply including the Vue.js JavaScript library. Usage with Webpack or Browserify, are not strictly necessarily. This is in stark contrast to React development where Usage with Webpack and Babel is unavoidable, therefore making converting existing web application much more difficult. Can someone explain why React needs webpack and babel? I thought you can just drop in the

what's the difference between babel-preset-stage-0, babel-preset-stage-1 etc

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: So my question is : what's the difference between babel-preset-stage-0 , babel-preset-stage-1 , babel-preset-stage-2 and babel-preset-stage-3 , and what's the best choice when we develop with ES6 ? 回答1: Babel's stage presets equate to the TC39 Process and the different states of each proposal for a potential language change. They include implementations and polyfills for all of the proposed changes in that stage. Anything currently in Stage-0 is Strawman, not ES6. It is future Javascript and absolutely not certain that it will ever

Unexpected reserved word 'import' when using babel

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using Babel in my NodeJSv4.1.1 code. Got the require hook in: require("babel-core/register"); $appRoot = __dirname; module.exports = require("./lib/controllers/app"); In a subsequently lodaded .js file I am doing: import { Strategy as LocalStrategy } from "passport-local"; However this is generating the following error in the CLI: import { Strategy as LocalStrategy } from "passport-local"; ^^^^^^ SyntaxError: Unexpected reserved word at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:413:25) at loader (/Users/*/Documents

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

匿名 (未验证) 提交于 2019-12-03 01:46:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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: [ { test: /\.jsx?$/, loader: 'babel-loader', exclude:

How to transform module after ordinary transform has run in jest

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Testing React components with jest. Some of these components make use of OpenLayers (ol package v5.2.0). In ol package v4 I applied transformIgnorePatterns to have the ol package transformed: "jest": { "transformIgnorePatterns": [ "node_modules/(?!(ol)/)" ], (...) } Now I get the following error when running NODE_ENV=test jest : (...) (...)/node_modules/ol/index.js:5 export {default as AssertionError} from './AssertionError.js'; ^^^^^^ SyntaxError: Unexpected token export 14 | let map = new Map({ 15 | layers: options.layers, > 16 | target:

Jest encountered an unexpected token: SyntaxError: Unexpected Token {

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Issue: I am running my tests with Jest and Enzyme when I came across this error when I was running my code on a different machine. When I run npm test which only runs jest --coverage --verbose it will get this error every time. However, this doesn't happen when I run it on my work lap top. What I'm trying to figure out is why this is breaking over the "{" token when I run my testing script. I've seen some people suggest that using babel-jest would help, but I don't believe that is the cause of this issue, as it doesn't affect my work laptop.

webpack bundle.js not found

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use webpack dev server, but can't access my bundle.js file. Edit: I am using this webpack config without bower-webpack-plugin . package.json { "name": "react_modules", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "npm run serve | npm run dev", "serve": "./node_modules/.bin/http-server -p 8080", "dev": "webpack-dev-server -d --progress --colors --port 8090" }, "author": "", "license": "ISC", "devDependencies": { "babel-core": "^6.0.20", "babel-loader": "^6.0.1", "babel-preset-es2015": "^6.0.15",

Webpack: TypeError: Cannot read property 'properties' of undefined

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here is the branch and repo in question: https://github.com/Futuratum/moon.holdings/tree/dev /Users/leongaban/projects/Futuratum/moon.holdings/node_modules/webpack-cli/bin/config-yargs.js:89 describe: optionsSchema.definitions.output.properties.path.description, Not sure why I'm getting this error, but I upgraded from Webpack 3 to 4. webpack /* eslint-disable no-console */ import webpack from 'webpack'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import ExtractTextPlugin from 'extract-text-webpack-plugin'; import CopyWebpackPlugin

Trace: The node type SpreadProperty has been renamed to SpreadElement at Object.isSpreadProperty

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm launching a react app, and here's my Webpack configuration: 'use strict' const ExtractPlugin = require('extract-text-webpack-plugin') const HTMLPlugin = require('html-webpack-plugin') module.exports = { devtool: 'eval', entry: `${__dirname}/src/main.js`, output: { filename: 'bundle-[hash].js', path: `${__dirname}/build`, publicPath: '/', }, mode: 'development', performance: { hints: false }, plugins: [ new HTMLPlugin(), new ExtractPlugin('bundle-[hash].css'), ], module: { rules: [ { test: /\.js$/, exclude: /node_module/, loader: 'babel

Error in IE11 caused by babel polyfill - delegate.iterator.return

匿名 (未验证) 提交于 2019-12-03 01:36:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hope to get some help with following: The problem @babel/polyfill causes error in IE11: SCRIPT1010: Expected identifier Debugger point on the line: if (delegate.iterator.return) { in the function maybeInvokeDelegate() in regenerator-runtime plugin. But Problem occures only in test environment . When I run my aplication locally, with exactly same build, same browser it works just fine. It contains same code, but it doesn't break anything. What I've already tried: babel-plugin-transform-member-expression-literals doesn't seem to help. I tried