browserify

Multiple React components in a single module

雨燕双飞 提交于 2019-11-28 06:54:27
I am new to the whole browserify thing. I have been trying to use browserify + reactify + gulp to transform, minify and combine a React application. As long as I have a single React.createClass with a single module.exports = MyComponent everything works fine. Since I have several shared components I physically host in the same file and reuse across projects, I would like to export more than one component. I have tried an array: module.exports = [Component1, Component2] and have also tried an object with multiple properties: module.exports = {Comp1: Componenet1, Comp2: Component2} and have also

Howto patch/shim crypto.getRandomValues for React Native

时光毁灭记忆、已成空白 提交于 2019-11-28 06:03:39
问题 I am porting some packages created for NodeJS to React Native using ReactNativify to rewrite Node API object dependencies to their browserify equivalents. One of them is crypto . In transformer.js (or .babelrc ) I have: // The following plugin will rewrite imports. Reimplementations of node // libraries such as `assert`, `buffer`, etc. will be picked up // automatically by the React Native packager. All other built-in node // libraries get rewritten to their browserify counterpart. [require(

How do I manage relative path aliasing in multiple grunt-browserify bundles?

落花浮王杯 提交于 2019-11-28 04:39:00
This is tad long but I'll need the code example to illustrate my confusion. After which I am interested to the answer for the following: How do I use require('module') instead of require('../../src/module') or require('./module') ? How do I reuse ./index.js in spec/specs.js without duplicating work? (And preventing src/app.js from running as it's an entry module). I've started several browser based projects already and love browserify and grunt. But each project dies at the same point in my development/learning curve. Once I add testing to the mix and have to manage two browserify bundles (

How to get minified output with browserify?

蹲街弑〆低调 提交于 2019-11-28 03:38:19
Just started to use browserify , but I cannot find documentation for how to get it spilling out minified output. So I am looking something like: $> browserify main.js > bundle.js --minified topek Pipe it through uglifyjs: browserify main.js | uglifyjs > bundle.js You can install it using npm like so: npm install -g uglify-js As of 3.38.x you can use my minifyify plugin to minify your bundle and still have usable sourcemaps. This is not possible with the other solutions -- the best you can do is map back to the uncompressed bundle. Minifyify maps all the way back to your separate source files

'jQuery is not defined' when use ES6 import

▼魔方 西西 提交于 2019-11-28 03:27:42
问题 My code: import $ from 'jquery' import jQuery from 'jquery' import owlCarousel from '../../node_modules/owlcarousel/owl-carousel/owl.carousel' class App { … _initSlider() { $("#partners-carousel").owlCarousel(); } } I have 'jQuery is not defined' in browser console. What's wrong? I can use jQuery as $ in methods of this class, but not with name 'jQuery'. 回答1: According to this comment and apply it to your case, when you're doing: import $ from 'jquery' import jQuery from 'jquery' you aren't

How to save a stream into multiple destinations with Gulp.js?

ぐ巨炮叔叔 提交于 2019-11-28 03:26:37
const gulp = require('gulp'); const $ = require('gulp-load-plugins')(); const source = require('vinyl-source-stream'); const browserify = require('browserify'); gulp.task('build', () => browserify('./src/app.js').bundle() .pipe(source('app.js')) .pipe(gulp.dest('./build')) // OK. app.js is saved. .pipe($.rename('app.min.js')) .pipe($.streamify($.uglify()) .pipe(gulp.dest('./build')) // Fail. app.min.js is not saved. ); Piping to multiple destinations when file.contents is a stream is not currently supported. What is a workaround for this problem? Currently you have to use two streams for each

Gulp + browserify + 6to5 + source maps

筅森魡賤 提交于 2019-11-28 03:16:03
I'm trying to write a gulp task allowing me to use modules in JS (CommonJS is fine), using browserify + 6to5. I also want source mapping to work. So: 1. I write modules using ES6 syntax. 2. 6to5 transpiles these modules into CommonJS (or other) syntax. 3. Browserify bundles the modules. 4. Source maps refers back to the original ES6 files. How to write such a task? Edit: Here's what I have so far: gulp task gulp.task('browserify', function() { var source = require('vinyl-source-stream'); var browserify = require('browserify'); var to5ify = require('6to5ify'); browserify({ debug: true })

Configure a generic jQuery plugin with Browserify-shim?

别来无恙 提交于 2019-11-28 03:12:01
I'm using browserify-shim and I want to use a generic jQuery plugin. I have looked over the Browserify-shim docs multiple times and I just can't seem to understand what's going on and/or how it knows where to put plugins, attach to the jQuery object etc. Here's what my package.json file looks like: "browser": { "jquery": "./src/js/vendor/jquery.js", "caret": "./src/js/vendor/jquery.caret.js" }, "browserify-shim": { "caret": { "depends": ["jquery:$"] } } According the the example given on the browserify-shim documentation, I don't want to specify an exports because this plugin (and most if not

How to use the net module from Node.js with browserify?

ⅰ亾dé卋堺 提交于 2019-11-28 01:33:48
问题 I want to use the net module from Node.js on the client side (in the browser): var net = require('net'); So I looked up how to get Node.js modules to the client, and browserify seems to be the answer. I tried it with jQuery and it worked like a charm. But for some reason the net module does not want to work. If I write require('jquery') it works fine, but if I write require('net') it does not work, meaning my bundled .js file is empty. I tried to search for something else, but the only thing

Browserifying libraries that were themselves browserified: relative paths error

自作多情 提交于 2019-11-27 23:01:34
I want to use a library that was build using browserify. The library built correctly and works fine when it is used by itself. Now that built library is in my vendors/ directory, and I try to require it in my new application: var myLib = require('./vendors/myLib'); When I try to browserify my application, it complains that it can't find some of the internal require statements inside that library: Error: Cannot find module '../utils/logger' from '/myApp/vendor' Browserify seems to be trying to re-build the lib from the wrong directory. How can I fix this? More specifics: The lib looks like this