babeljs

Babel plugin error: Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`

∥☆過路亽.° 提交于 2021-01-29 20:06:10
问题 EDIT / UPDATE: I have taken loganfsmyth's advice and pulled out babel as the first argument to the sveltify function and I can access / console log babel.template.statement.ast however, if I try to call that function my app hangs indefinitely. Thie details: I am trying to use this with svelte to replace the import statement and I have a plugin as: const sveltify = (babel) => ({ visitor: { ImportDeclaration(path){ // import x from 'svelte/somewhere' if (path.node.source.value.startsWith(

Fetch in Internet Explorer?

放肆的年华 提交于 2021-01-29 09:22:53
问题 Following code does not work on IE at all. fetch("{{{LINK TO API}}}", { headers: { "Accept": "application/json", "Content-Type": "application/json" } }) .then(resp => resp.json()) .then(function(json) { // SET VARIABLES var seller = json.sellers[Math.floor(Math.random() * Math.floor(json.sellers.length))]; // INSERT COMPANY LOGO companyLogo.src = json.logo_url; // INSERT SELLER PROFILES document.querySelectorAll("[data-seller-profile]").forEach(wrapper => { var innerHTML = ""; innerHTML += "

Module build failed (from ./node_modules/babel-loader/lib/index.js):

前提是你 提交于 2021-01-29 05:55:43
问题 Well Here i'm trying to create a react app and want to use simple walletconnect package and trying to create a build file of my react app but i'm getting module error when i run webpack command to create the build file of my app. The traceback is given below: ERROR in ./frontend/src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module '@babel/preset-core' Require stack: - C:\Users\AHMED\Dotesrow\dotescrow\node_modules\@babel\core\lib\config

Babel: transpile into single output file

心不动则不痛 提交于 2021-01-28 01:56:34
问题 Babel 7.2.0 I need to transpile my JS-files and combine they into single result file. This is my attempt: npx babel --source-root src/index.js --out-file lib/result.js --minified --presets @babel/preset-env But I get the error: babel: stdin compilation requires either -f/--filename [filename] or --no-babelrc I tried -f and --no-babelrc but it doesn't help me... 回答1: Your current command never tells Babel what file to compile, so it is expecting the file content to come from stdin. Since stdin

React Native: Can't find variable: require

自作多情 提交于 2021-01-27 20:51:09
问题 I am trying to modify a react native boilerplate so that I can be run on Android platform. I installed the expo package and added an index.js file on the root directory. But when I run the android code, it raised Can't find variable: require on the bundling phase I uploaded my code here. Does anyone have an idea what I missed here? 回答1: resetting the cache worked for me. On expo expo r -c for pure react native react-native start --reset-cache 回答2: For those whose cache clearing didn't work.

I cannot understand “ Module not found: Error: Can't resolve 'fs' '”

…衆ロ難τιáo~ 提交于 2021-01-27 20:06:15
问题 Having a little spare time I have tried reworking an old project of mine with new web techs that I like (Typescript, Pug and React). Everything worked fine until I tried adding pug.js into the mix with babel-plugin-transform-react-pug . No matter how much I fiddle with the configurations I can't get the build phase to work and get the following errors: ERROR in ./node_modules/uglify-js/tools/node.js Module not found: Error: Can't resolve 'fs' ERROR in ./node_modules/resolve/lib/sync.js Module

Using rollup in combination with babel and commonjs plugins doesn't resolve all modules

末鹿安然 提交于 2021-01-27 17:18:32
问题 I'm using rollup with the Babel and CommonJS plugins, like this: const inputOptions = { input: "...", plugins: [ resolve(), babel({ exclude: "node_modules/**", externalHelpers: true, include: "**/components/**/*.js", }), commonjs(), ], }; But what happens is that modules referenced from components don't seem to be recognized by the CommonJS plugin, they end up as plain require(...) statements in the output (just like the source input) where of course they cannot be resolved. Modules imported

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

“SyntaxError: Cannot use import statement outside a module” with Babel, Jest, and webpack

北城以北 提交于 2021-01-27 05:42:16
问题 I have a problem with configurations of Babel 7, Webpack 4 and Jest. While I'm running tests I'm getting following error: SyntaxError: Cannot use import statement outside a module package.json "@babel/core": "^7.7.5", "@babel/highlight": "^7.8.3", "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@babel/preset-env": "^7.8.4", "babel-core": "^7.0.0-bridge.0", "babel-loader": "^7.1.5", "@babel/plugin-transform-runtime": "^7.7.4", "@babel/preset-react": "^7.7.4", "@babel/runtime": "^7.8.4",

How to use Native Node Modules on a React, ES6, Electron App?

和自甴很熟 提交于 2021-01-27 04:41:50
问题 I have a React, Electron app that I wish to be able to access native node modules from the ES6 compiled (using Babel and Webpack). For example, when I try to require the "fs" node module to access the filesystem I get the following error. ERROR in ./src/app.js Module not found: Error: Cannot resolve module 'fs' in C:\Users\Propietario-1\Documents\GitHub\AMPLI @ ./src/app.js 1:358-371 But when I required this from a "none compiled" js file it works. I can access the "fs" module. Any help is