browserify

“Cannot find module 'jquery'” - handling globals for JQuery and AngularJS in browserify with Gulp

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been trying to create a project that utilizes AngularJS , Browserify and Gulp for an excellent developer experience, one that produces a distributable 'module' (in Angular parlance). The idea being to have a self-documented project, like Angular Bootstrap , that also produces a consumable distribution for use in another application. We've had great results with Gulp , but we're having trouble with browserify/browserify-shim . Also, unfortunately, most of the examples out there either don't use gulp, or use gulp-browserify , which has

Shim a jQuery plugin with browserify

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Hi I'm using the grunt browserify task to setup my code, I have shimmed in jQuery and I'm now trying to include jquery.tablesorter. Can jquery plugins be used with browserify in this way? shim : { jquery : { path : 'lib/bower/jquery/jquery.js' , exports : '$' }, 'jquery.tablesorter' : { path : 'lib/bower/jquery.tablesorter/js/jquery.tablesorter.js' , exports : 'tablesorter' , depends : { jquery : '$' , } } } 回答1: You may try by doing this: shim : { jquery : { path : 'lib/bower/jquery/jquery.js' , exports : '$' }, 'jquery

How to expose 'require' to the browser when using browserify from within gulp?

匿名 (未验证) 提交于 2019-12-03 02:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I have a file x.js that looks like this: x.js module.exports = function (n) { return n * 111 } and I run browserify from the command line like so: browserify -r ./x.js > bundle.js I get an output file that looks like this (roughly): require=(function e(t,n,r){function ...... ./App.jsx":[function(require,module,exports){ module.exports=require('0+DPR/'); },{}]},{},[]) Then in my browser code I can do this: React server rendering example Welcome to the React server rendering example. Here is a server-rendered React component: I actually

Browserify/Babelify React for production (NODE_ENV production)

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 选择语言 中文(简体) 日语 英语 中文(繁体) 由 翻译 强力驱动 问题: I run this command: browserify src . js - t [ babelify -- presets [ react ] ] > build . js and I get a single file that can be used by it's own. Works fine, but it's NODE_ENV is set to development and I get a console.log about downloading React DevTools. How do I set it to production? I browsed around and didn't find anything that worked for me. I tried envify, but no luck (I'm very newb with JS builds). I tried putting --NODE_ENV production somewhere in the line above, but I'm very new to browserify and

Using Bootstrap 3.0 with Browserify

匿名 (未验证) 提交于 2019-12-03 01:17:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to use Bootstrap 3.0 with Browserify 5.9.1, but getting the following error: Uncaught ReferenceError : jQuery is not defined What's the correct way to do this? Here are the relavant portions of my package.json: { ... "scripts" : { "bundle" : "browserify main.js -o bundle.js --debug --list" }, "dependencies" : { "backbone" : "~1.1.x" , "jquery" : "~2.1.x" , "underscore" : "~1.6.x" }, "devDependencies" : { "browserify" : "^5.9.1" , ... }, ... } The module that requires bootstrap is shown below: var $ = require ( 'jquery'

How to include node_modules in a separate browserify vendor bundle

旧街凉风 提交于 2019-12-03 01:16:51
I am trying to convert an AngularJS app to use browserify. I have installed all my bower packages in node_modules using napa. Now I want to browserify them into a separate vendor bundle and declare them as 'external' dependencies. I would like to give them aliases, so that I can "require('angular')" instead of "require('angular/angular')", as it seems you can do with externals. The examples I have seen (e.g. http://benclinkinbeard.com/posts/external-bundles-for-faster-browserify-builds/ ) all assume that I have downloaed the vendor files into a 'lib' directory. I want to just bundle my vendor

Browserify - ParseError: 'import' and 'export' may appear only with 'sourceType: module

匿名 (未验证) 提交于 2019-12-03 00:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my gulpfile I have var gulp = require('gulp'); var browserSync = require('browser-sync').create(); var sass = require('gulp-sass'); var babel = require("gulp-babel"); var rename = require('gulp-rename'); var source = require('vinyl-source-stream'); var browserify = require('gulp-browserify'); var notify = require("gulp-notify"); gulp.task('js', function () { gulp.src('js/main.js') .pipe(babel()) .pipe(browserify()) .on('error', errorAlert) .pipe(rename('./dist/js/bundle.js')) //.pipe(uglify()) .pipe(gulp.dest('./')) .pipe(notify({title:

gulp : browserify then concat files

匿名 (未验证) 提交于 2019-12-03 00:54:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to browserify a file, and then to concat the bundle with another file. I tried the gulp code below but it's not working properly. When I make changes in mymodule.js and run gulp, those changes appear in the bundle file but not in the concatenated file, unless I run gulp a second time. It's like if the concat step is not waiting for the bundle step to finish and take the previously browserified bundle. As I'm a beginner with gulp, I'm sure there is something wrong with my gulp logic... My gulpfile is : var gulp = require('gulp'); var

how to detect when browserify is being run?

荒凉一梦 提交于 2019-12-02 21:35:16
I have a library that I want to use in both client side and server side. However, because request is not compatible with browserify, when compiling using browserify, I need to use a different library called browser-request if (inNodejsRuntime) { var request = require('request'); } else if (isBrowserifyRuntime) { var request = require('browser-request'); } How do I go about detecting when browserifying is running vs when it is inside node If you are just doing a simple module swap with compatible APIs you should use the browser field in package.json. So for your example, just do var request =