babel

Gulp TypeError: Path must be a string. Received undefined

[亡魂溺海] 提交于 2020-01-01 16:07:12
问题 I want to run build command but got the error message: TypeError: Path must be a string. Received undefined. Do you guys have any ideas? Thanks. gulp.task('build', function () { browserify("./src/components/source.js") .transform("babelify", {presets: ["es2015", "react"]}) .bundle() .pipe(gulp.dest(path.resolve(__dirname, './src/app.js'))); }); Below is the tracestack details: TypeError: Path must be a string. Received undefined at assertPath (path.js:8:11) at Object.posix.resolve (path.js

Gulp TypeError: Path must be a string. Received undefined

≡放荡痞女 提交于 2020-01-01 16:06:53
问题 I want to run build command but got the error message: TypeError: Path must be a string. Received undefined. Do you guys have any ideas? Thanks. gulp.task('build', function () { browserify("./src/components/source.js") .transform("babelify", {presets: ["es2015", "react"]}) .bundle() .pipe(gulp.dest(path.resolve(__dirname, './src/app.js'))); }); Below is the tracestack details: TypeError: Path must be a string. Received undefined at assertPath (path.js:8:11) at Object.posix.resolve (path.js

Confused about useBuiltIns option of @babel/preset-env (using Browserslist Integration)

久未见 提交于 2019-12-31 11:28:53
问题 I'm working on a web project using Babel 7 with Webpack 4. I've never used Babel before and can't really understand some parts of it. Based on the documentation I'm using @babel/preset-env because it seems the recommended way (especially for beginners). Also using Browserslist integration via my .browserslistrc file. Webpack does the compilation well ( babel-loader version 8.0.2 ), I have no errors but I'm confused about this useBuiltIns: "entry" option mentioned here and how polyfill system

React, WebPack and Babel for Internet Explorer 10 and below produces SCRIPT1002: Syntax error

*爱你&永不变心* 提交于 2019-12-31 00:56:28
问题 I've read multiple threads regarding similar issues and tried some propositions, but had no results. I've followed few tutorials related to React.js and WebPack 3 . As the result the application is working well on all browsers (at this moment) except IE 10 and below. The error points to bundle.js (once I'm using the configuration Nr.1): SCRIPT1002: Syntax error and the line - const url = __webpack_require__(83); With configuration Nr2., on local server - : SCRIPT1002: Syntax error - line with

Import React from 'react' results in Uncaught SyntaxError: Unexpected identifier

旧时模样 提交于 2019-12-30 18:04:05
问题 I've installed webpack 3 along with babel and my entry index.js/bundle.js will build and run, which I've tested with ES7/8 features, however imports won't work and result in Uncaught SyntaxError: Unexpected identifier . I've tried putting the babel config in the package.json as well as in a separate .babelrc file in my app root directory but I still get the error when trying to import. Am I missing a package or setting? index.js (works) // does not work // import React from 'react' // works

“require is not defined” Using webpack 2

两盒软妹~` 提交于 2019-12-30 06:22:52
问题 I'm having problems with bundle my app using webpack, I've reading in the site similar problems though I've trying all the recommendations and I can't figure it out what's wrong. Everything bundles well. However when I open the browser show me this error: Uncaught ReferenceError: require is not defined webpack-dist.conf.js const webpack = require('webpack'); const conf = require('./gulp.conf'); const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const

babel的使用以及安装配置

吃可爱长大的小学妹 提交于 2019-12-30 06:02:38
简介 babel是一个广泛使用的转码器,可以将ES6代码转化为ES5代码,从而在现有环境执行,这意味着,你可以现在就用ES6编写程序,而不用担心现有环境是否支持。 安装及配置 npm install babel-cli --save-dev 或者 cnpm install babel-cli --save-dev使用淘宝镜像安装会更快。 步骤:进入项目 ==>cnpm install babel-cli --save-dev 为什么不安装在全局 如果安装在全局,那意味着项目要运行,全局环境必须有bable,也就是说项目产生了对环境的依赖。另一方面,这样做也无法支持不同项目使用不同版本的babel。 设定转码规则 根目录下安装:cnpm install babel-preset-es2015 --save-dev 安装完成之后,再创建配置文件 .babelrc这个文件,得放在项目根目录下,它的基本格式是: { "presets":[], "plugins":[] } presets字段设置的就是转码规则,plugins是设置的babel的插件。然后配置文件: { "presets":["es2015"] } 到这里,关于babel的基本配置就完成了。 实例演示: 在项目根目录下创建demo.js let a = 5; const b = 10; let input = [1,2,3]

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

拥有回忆 提交于 2019-12-29 07:55:26
问题 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.<anonymous> (app\components\Wrapper\tests\index. test

Access a Flask extension that is defined in the app factory

本小妞迷上赌 提交于 2019-12-29 07:46:29
问题 I am using the app factory pattern to set up my Flask application. My app uses the Flask-Babel extension, and that is set up in the factory as well. However, I want to access the extension in a blueprint in order to use it, The factory is in __init__.py . def create_app(object_name): app = Flask(__name__) app.config.from_object(object_name) babel = Babel(app) app.register_blueprint(main_blueprint) app.register_blueprint(category_blueprint) app.register_blueprint(item_blueprint) db.init_app

解决问题SyntaxError: Unexpected token import

泪湿孤枕 提交于 2019-12-29 07:33:27
ES6语法的模块导入导出( import/export )功能,我们在使用它的时候,可能会报错: SyntaxError: Unexpected token import 语法错误:此处不应该出现import 我遇到的情况是 import 语法不识别导致的。在这里,有两种方法可以解决。 1: 使用node的v8及之后的版本 因为,node需要v8.x之后的版本才支持ECMAScript Modules 和 imort 语法 目前,node稳定版本是v8.11.2 可以使用 nvm 来安装管理查看多个node版本 。 可以使用 --experimental-modules 实验模块标志来启用加载ECMAScript Modules的特性。 而且作为ES模块加载的文件名,必须以 .mjs 后缀结尾 node --experimental-modules my-app.mjs 此种方法,在输出的时候会提示: (node:16208) ExperimentalWarning: The ESM module loader is experimental. 表示是个实验模块,到时候可能会修改。 例子: https://github.com/weiqinl/demo/tree/master/01-es6-import 2: 使用babel,通用方法 浏览器直接支持 import 程度比较低