browserify

Make browserify modules external with Gulp

ぐ巨炮叔叔 提交于 2020-01-01 03:06:06
问题 I have a library lib.js that I want to create from lib/a.js and lib/b.js and to be able to use it from a script client.js using var a = require('lib/a.js'); and that it works when I just include the compiled lib.js library before client.js (therefore, lib.js has to declare a require function that knows about lib/a.js ) I guess I have to use external and alias but I am not sure what is the proper way to do it Also, is it possible to have a Gulp file that creates all the alias automatically for

browserify require in required file cannot find module

自古美人都是妖i 提交于 2019-12-31 04:09:30
问题 I'm trying to package my angular js into a single script using browserify. It works well when I use require from within my main file app.js , but when one of the modules required in app.js contains it's own require , the dependency is not included in my bundle. To recap, in app.js (link to line in repo): require("splash-header"); // more code here splashHeader.js: require("social-button-directive"); // more code here socialButtons.js has no dependencies. browserify --list app.js does not list

React +(Router) without webpack or browserify

柔情痞子 提交于 2019-12-30 18:42:07
问题 Is it possible to use react with ReactRouter, without using browserify or webpack. I am following the documentation from http://rackt.github.io/react-router they require react and react-router ( require('react-router'); ). If I use browerifly my generated bundle is about 1MB filesize, which sounds like a lot. So is it possible to get reactrouter working with including compiled JS from a CDN like https://cdnjs.cloudflare.com/ajax/libs/react-router/0.13.3/ReactRouter.js, instead of bundle all

How to use both 'gulp-babel' and 'gulp-browserify'

独自空忆成欢 提交于 2019-12-30 08:15:59
问题 I try to write these code gulp.task('script', function() { 'use strict' return gulp.src(['app.js', 'components/**/*.jsx']) .pipe(babel()) .pipe(browserify()) .pipe(gulp.dest("dist")); }); but it shows some error: SyntaxError: /Users/Zizy/Programming/learn-react-js/components/CommentBox.jsx:58 <div className="commentBox"> ^ ParseError: Unexpected token at wrapWithPluginError (/Users/Zizy/Programming/learn-react-js/node_modules/gulp-browserify/index.js:44:10) It seems that before .pipe

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

两盒软妹~` 提交于 2019-12-30 00:47:08
问题 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: <html> <head> <title>React server rendering example</title> <script src="static

How to import jquery using ES6 syntax?

余生颓废 提交于 2019-12-27 10:37:30
问题 I'm writing a new app using (JavaScript) ES6 syntax through babel transpiler and the preset-es2015 plugins, as well as semantic-ui for the style. index.js import * as stylesheet from '../assets/styles/app.scss'; import * as jquery2 from '../dist/scripts/jquery.min'; import * as jquery3 from '../node_modules/jquery/dist/jquery.min'; console.log($('my-app')); index.html <!DOCTYPE html> <html lang="fr"> <head> <body> <script src="dist/app.js"></script> </body> </html> Project structure . ├── app

Event handling with subclasses

杀马特。学长 韩版系。学妹 提交于 2019-12-25 10:00:10
问题 Based on this question. I'm moving from RequireJS to browserify (together with babelify) and try to rewrite my current modules to classes. For each of my RequireJS modules I have a method called eventHandler which handles all general module specific events. Now when I extend a class, the parent class calls the subclass`s eventHandler method which leads to invoking the method twice. There's another problem with my current code, though. I've also two methods on several modules to bind and

Event handling with subclasses

风流意气都作罢 提交于 2019-12-25 10:00:08
问题 Based on this question. I'm moving from RequireJS to browserify (together with babelify) and try to rewrite my current modules to classes. For each of my RequireJS modules I have a method called eventHandler which handles all general module specific events. Now when I extend a class, the parent class calls the subclass`s eventHandler method which leads to invoking the method twice. There's another problem with my current code, though. I've also two methods on several modules to bind and

Is there a way to use fs sync functions with browserify?

我怕爱的太早我们不能终老 提交于 2019-12-25 09:11:59
问题 I already tried the brfs transformation, but I got the following error message: 08 03 2016 16:50:14.894:ERROR [framework.browserify]: bundle error 08 03 2016 16:50:14.894:ERROR [framework.browserify]: Error: tried to statically call { readFile: [Function: readFile], readFileSync: [Function: readFileSync], readdir: [Function: readdir], readdirSync: [Function: readdirSync] } as a function while parsing file ... PhantomJS 1.9.8 (Windows 7 0.0.0) ERROR You need to include some adapter that

Dealing With Dependencies in angularjs Testing

拟墨画扇 提交于 2019-12-25 03:59:16
问题 This is for work (I have permission) so I can't post exact code. So I have to test controllers of a large module. The module has a large config function with a bunch of controllers for the logic of the different pages. For the actual application it's loaded with bower, which is irritating since I'm testing with Karma-Browserify and npm. So the the dependencies are a mess. I basically have to import everything that was loaded from bower.json to package.json. This is my karma.conf.js: module