babeljs

How to fix babel react “Uncaught SyntaxError: Unexpected token <”

爱⌒轻易说出口 提交于 2020-05-27 04:24:24
问题 I am having problem with react setup via CDN. Her is my html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" type="text/css" href="css/main.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.7/babel.min.js"><

How to make script type both text/babel and module?

回眸只為那壹抹淺笑 提交于 2020-05-25 11:30:26
问题 It works perfectly because I haven't included JSX, but when I replace the script type with text/babel , it doesn't work because the module fails to load. browser.js the Babel compiler. Here... JSX works only when i replace script type with text/babel but the problem is module fails to load since the script is not module. Any idea how make it work with JSX? <div id="root"> </div> <script type="module"> import './react.min.js'; import './react-dom.min.js'; import './browser.js'; class Hello

Make babel exclude test files

六月ゝ 毕业季﹏ 提交于 2020-05-25 03:24:59
问题 On my build step I'm using babel to transpile the code to es5 (from src to dist ). How do I make it exclude files ending in .test.js ? package.json "scripts": { "build": "babel src --out-dir dist", .babelrc { "presets": [ "es2015" ], "ignore": "\\.test\\.js" } 回答1: Based on the documentation, you should be able to write .babelrc { "ignore": [ "**/*.test.js" ] } However, I was able to verify that this does not seem to work. I tried it with version 6.5.1 (babel-core 6.5.2). At the same time,

Make babel exclude test files

爱⌒轻易说出口 提交于 2020-05-25 03:21:57
问题 On my build step I'm using babel to transpile the code to es5 (from src to dist ). How do I make it exclude files ending in .test.js ? package.json "scripts": { "build": "babel src --out-dir dist", .babelrc { "presets": [ "es2015" ], "ignore": "\\.test\\.js" } 回答1: Based on the documentation, you should be able to write .babelrc { "ignore": [ "**/*.test.js" ] } However, I was able to verify that this does not seem to work. I tried it with version 6.5.1 (babel-core 6.5.2). At the same time,

Make babel exclude test files

懵懂的女人 提交于 2020-05-25 03:21:29
问题 On my build step I'm using babel to transpile the code to es5 (from src to dist ). How do I make it exclude files ending in .test.js ? package.json "scripts": { "build": "babel src --out-dir dist", .babelrc { "presets": [ "es2015" ], "ignore": "\\.test\\.js" } 回答1: Based on the documentation, you should be able to write .babelrc { "ignore": [ "**/*.test.js" ] } However, I was able to verify that this does not seem to work. I tried it with version 6.5.1 (babel-core 6.5.2). At the same time,

How to install babel and using ES6 locally on Browser?

我是研究僧i 提交于 2020-05-24 21:19:09
问题 So, I am following tutorial to learn ES2015 on here: http://k33g.github.io/2015/05/02/ES6.html But, I don't find this file based on that tutorial: node_modules/babel-core/browser.js Where can I get browser.js? Because after I execute: npm install babel-core there are 2 browser.js in node_modules\babel-core 1 node_modules\babel-core\lib\api\register\browser.js 2 node_modules\babel-core\lib\api\browser.js Which one should I copy? 回答1: Since babel 6.2.0 browser.js has been removed. Following

babel@7 and jest configuration

旧巷老猫 提交于 2020-05-24 21:15:11
问题 Maybe you may help me? I try to configure jest to use babel@7 So I have: "jest": "^23.4.1", "@babel/core": "^7.0.0-beta.54", "babel-7-jest": "^21.3.3", "babel-jest": "^20.0.3", And jest config inside package.json "jest": { "transform": { "^.+\\.js$": "babel-7-jest", }, And got TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string But if I use "jest": { "transform": { "^.+\\.js$": "babel-jest", }, I got Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are

babel@7 and jest configuration

大城市里の小女人 提交于 2020-05-24 21:14:32
问题 Maybe you may help me? I try to configure jest to use babel@7 So I have: "jest": "^23.4.1", "@babel/core": "^7.0.0-beta.54", "babel-7-jest": "^21.3.3", "babel-jest": "^20.0.3", And jest config inside package.json "jest": { "transform": { "^.+\\.js$": "babel-7-jest", }, And got TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string But if I use "jest": { "transform": { "^.+\\.js$": "babel-jest", }, I got Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are

Webpack, Babel 7.4.0 and core-js 3

£可爱£侵袭症+ 提交于 2020-05-15 03:46:24
问题 Given the following package.json { "name": "webpack-babel7", "version": "1.0.0", "main": "index.js", "license": "MIT", "devDependencies": { "@babel/core": "^7.4.4", "@babel/preset-env": "^7.4.4", "babel-loader": "^8.0.5", "webpack": "^4.30.0", "webpack-cli": "^3.3.2" }, "dependencies": { "core-js": "3" } } babel.config.js const presets = [ [ '@babel/env', { targets: { chrome: '74', }, useBuiltIns: 'usage', debug: true, corejs: 3, }, ], ] module.exports = { presets } webpack.config.js const

Babel 7 Unexpected token for React component

你。 提交于 2020-05-13 19:24:19
问题 I'm upgrading to Babel v7 from v6 and when I build the project I get the following error: Syntax error: src\app\layout\components\FooterToolbar.js: Unexpected token I'm using the following .babelrc configuration { "presets": [ ["@babel/preset-env", { "useBuiltIns": "usage", "debug": true }], "@babel/preset-typescript", "@babel/preset-react" ], "plugins": [ "@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-object-rest-spread", "@babel/plugin-syntax-dynamic-import", "@babel