babel

Dynamic Imports for Code Splitting cause: ESLint Parsing Error 'import'

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using the VueJS Webpack template found here: https://github.com/vuejs-templates/webpack Example Route: const AuthRoute = () => import(/* webpackChunkName: "authroute" */ './AuthRoute.vue') Example Error: [eslint] Parsing error: Unexpected token import I've followed the steps provided in Webpack's Dynamic import section, as well as Anthony Gore's blog post on how to accomplish code splitting with VueJS at the router level. More specifically, here is my setup: Package.json ... "babel-core": "^6.22.1", "babel-eslint": "^8.0.3", "babel-jest"

Promise is undefined in IE11 using babel-polyfill

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: As the title says, even I'd like to use babel-polyfill to allow me to use promises in my code, but I get that undefined error in IE11. I've been trying to make this work for a while as I've seen that has been asked in different sites a few times, but none of the solutions really worked for me (or more accurately I was probably not able to adapt them to my code) These are the files that, I think, are involved: .babelrc { "presets": [ "es2015", "react" ] } package.json: I have babel-polyfill under dev-dependencies and tried to put it under

Promise is undefined in IE11 using babel-polyfill

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: As the title says, even I'd like to use babel-polyfill to allow me to use promises in my code, but I get that undefined error in IE11. I've been trying to make this work for a while as I've seen that has been asked in different sites a few times, but none of the solutions really worked for me (or more accurately I was probably not able to adapt them to my code) These are the files that, I think, are involved: .babelrc { "presets": [ "es2015", "react" ] } package.json: I have babel-polyfill under dev-dependencies and tried to put it under

Cannot setup `babel-plugin-rewire` for React tests

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to setup babel-plugin-rewire so that in my Jest tests I can generate a small test snapshot for a wrapper component instead of having a huge one with all the child components in it. The settings seem all to be correct but I get the following error: ReferenceError: Wrapper is not defined at _get_original__ (app\components\Wrapper\tests\index.te st.js:22:2168) at _get__ (app\components\Wrapper\tests\index.test.js:22: 1912) at Suite. (app\components\Wrapper\tests\index. test.js:8:82) at Object. (app\components\Wrapper\tests\index

Using babel to transpile to es3 (safari compliant)

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to babel. I set it up like this: .babelrc: { "presets": ["es2015", "es2017"] } gulpfile: gulp.task('default', function() { return gulp.src(['src/**/*.js', '!src/**/3rd/*']) .pipe(babel()) .pipe(gulp.dest('dist')); }); However this seems to be compiling to es5 which is not fully supported in Safari. Is there a way to set target? So it can compile to ES3? 回答1: No, Babel does not support transpiling to ES3. Your options are: Compile to ES5 and then use ES5 shim . Use a different transpiler. Google Closure Compiler and TypeScript both

Webpack + Babel: Couldn't find preset “es2015” relative to directory

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a React project using Webpack and Babel. When I created it on an office computer, the Webpack ran fine. When I cloned the project onto my personal computer, it gave the following error: ERROR in ./react_minesweeper.jsx Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/louisstephancruz/Desktop" at /Users/louisstephancruz/Desktop/w6d5/minesweeper/node_modules/babel-core/lib/transformation/file/options/option-manager.js:298:19 at Array.map (native) at OptionManager.resolvePresets (/Users

Karma unit testing: Module name “react” has not been loaded yet for context: _. Use require([])

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to set up the unit testing framework for react. While doing so, the following error has occurred. I have searched all over the internet with no solution that is working. below are the errors shown and code/packages that I am using. debug error 04 03 2016 04 : 48 : 46.340 : DEBUG [ phantomjs . launcher ]: Error : Module name "react" has not been loaded yet for context : _ . Use require ([]) http : //requirejs.org/docs/errors.html#notloaded 04 03 2016 04 : 48 : 46.341 : DEBUG [ phantomjs . launcher ]: http : //localhost

Babel support for Object.entries

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking at the stage 3 proposal of Object.values/Object.entries and I'd really like to use it in my current JavaScript project. However, I can't figure out whether there's any Babel preset which supports it. Since the GitHub repository linked above says it's a stage 3 proposal, I assumed it would be part of babel-preset-stage-3, but it seems not. Is there any Babel preset (or even plugin?) that lets me use Object.entries today? 回答1: Using babel , installing babel-preset-es2017 babel-plugin-transform-runtime gives support for Object

Webpack Missing Module 'Module Not Found'

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm currently working on a react webpack babel etc site and trying to build the first time. The build is successful, but when I open up the browser I get the following error: Uncaught Error: Cannot find module "/Users/michael.nakayama/Documents/Development/jamsesh/node_modules/webpack/node_modules/node-libs-browser/node_modules/process/browser.js" This module exists. Going to that actual url in my browser shows the file in question. But I cannot figure out why webpack cannot find it. I don't know if this is a babel6 issue or a webpack issue,

'Symbol' is undefined in IE after using babel

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a reactjs app written using ES6 standards, and I use webpack to build it. The webpack loads the js modules using babel-loader . To be specific, I use the following versions of packages: ├―― babel@5.8.34 ├―― babel-core@5.8.34 ├―― babel-loader@5.4.0 └―― webpack@1.12.6 However, after building it, the IE 10 gives the following error 'Symbol' is undefined . Shouldn't the babel be supposed to define the Symbol ? Is there any specific configuration for webpack or babel I need to set in order to make it work? I use {stage: 0} configuration in