babel-loader

Webpack - Include file multiple times

旧巷老猫 提交于 2021-02-10 06:38:50
问题 I want to include a file twice through two different loaders. The reasoning is I want to display code snippets in ES6 while allowing them to be run in browsers not supporting the syntax. Effectively what I would like to achieve is the below but with both loaders results being included in the output - { test: /\.(js|jsx)$/, exclude: /node_modules/, loader: "babel-loader" }, { test: /\.(js|jsx)$/, include: /app\/examples/, use: [ { loader: "file-loader", options: { regExp: /app\/examples\/([^\/

Import typescript file in FlowJS (eslit: Flow: Cannot resolve module)

柔情痞子 提交于 2021-01-29 14:29:44
问题 I trying incrementaly migration from Flow to Typescript . I use webpack with babel for transpile flow and typescript. ('@babel/preset-flow', '@babel/typescript') I have this import in FLOW file test.js /* @flow */ import MyComponent from 'components/myComponent' on path: src/components/myComponent/index.tsx is class MyComponent extends Component<Props> { render() {} } export default MyComponent My WebStorm IDE display eslint error Flow : Cannot resolve module components/myComponent For

webpack 4 : bundle js not found

自作多情 提交于 2021-01-27 16:45:37
问题 I recently upgraded to webpack 4. The page is getting loaded successfully and whenever changes happened it refreshes the page automatically using webpack-dev-server. It does very nice but in the console it shows below error GET http://localhost:8090/build/bundle.js 404 (Not Found) And some times when ever there is id in the URL it appends the id to bundle js url like below http://localhost:8090/16/build/bundle.js I tried many ways with Stack Overflow answers and GitHub solutions but none of

Problems with babel loader in react-create-app

泪湿孤枕 提交于 2021-01-21 06:24:44
问题 The Problem create-react-app initializes a repository where babel-loader is installed as an older version than needed. LOG: There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally. The react-scripts package provided by Create React App requires a dependency: "babel-loader": "8.0.4" Don't try to install it manually: your package manager does it automatically. However, a different version of babel-loader was

How to create IE11 Bundles with Webpack 5 and Babel 7

余生颓废 提交于 2020-12-23 07:49:24
问题 How can we compile modern JavaScript into backwards-compatible JavaScript bundles that can be used with Internet Explorer 11 (ie11)? Specifically, how can we do this with the latest versions of Webpack 5 and Babel 7? 回答1: Here's the most minimal configuration I could create, with a test file that's included to test with IE 11. Download on GitHub. package.json { "browserslist": [ "ie 11" ], "scripts": { "dev": "webpack -w", "build": "webpack" }, "devDependencies": { "@babel/core": "^7.12.9", "

How to create IE11 Bundles with Webpack 5 and Babel 7

让人想犯罪 __ 提交于 2020-12-23 07:43:17
问题 How can we compile modern JavaScript into backwards-compatible JavaScript bundles that can be used with Internet Explorer 11 (ie11)? Specifically, how can we do this with the latest versions of Webpack 5 and Babel 7? 回答1: Here's the most minimal configuration I could create, with a test file that's included to test with IE 11. Download on GitHub. package.json { "browserslist": [ "ie 11" ], "scripts": { "dev": "webpack -w", "build": "webpack" }, "devDependencies": { "@babel/core": "^7.12.9", "

How to create IE11 Bundles with Webpack 5 and Babel 7

北慕城南 提交于 2020-12-23 07:41:31
问题 How can we compile modern JavaScript into backwards-compatible JavaScript bundles that can be used with Internet Explorer 11 (ie11)? Specifically, how can we do this with the latest versions of Webpack 5 and Babel 7? 回答1: Here's the most minimal configuration I could create, with a test file that's included to test with IE 11. Download on GitHub. package.json { "browserslist": [ "ie 11" ], "scripts": { "dev": "webpack -w", "build": "webpack" }, "devDependencies": { "@babel/core": "^7.12.9", "

webpack + babel - transpile object arrow functions doesn't work

核能气质少年 提交于 2020-11-25 03:43:31
问题 I'm trying to configure webpack (5) with babel, using babel-loader to transpile to ES5. Unfortunately, the output is not consistent. Basically, it's divided into two parts: Some polyfills: My code: As you can see, the first part contains arrow functions, and the second one not. I've tried to add @babel/plugin-proposal-class-properties and @babel/plugin-transform-arrow-functions to my .babelrc file, but the class-properties is missing (with debug enabled). I must admit, I'm not sure that the

webpack + babel - transpile object arrow functions doesn't work

梦想的初衷 提交于 2020-11-25 03:42:04
问题 I'm trying to configure webpack (5) with babel, using babel-loader to transpile to ES5. Unfortunately, the output is not consistent. Basically, it's divided into two parts: Some polyfills: My code: As you can see, the first part contains arrow functions, and the second one not. I've tried to add @babel/plugin-proposal-class-properties and @babel/plugin-transform-arrow-functions to my .babelrc file, but the class-properties is missing (with debug enabled). I must admit, I'm not sure that the