browserify

Is it okay to use babel-node in production

女生的网名这么多〃 提交于 2019-11-27 05:54:18
I have been developing a site using babel-node and browserify with the babelify transform, to support ES6 syntax. I am just wondering, can I run this in production as babel-node server rather than node server What other options do I have to run ES6 in node? Here are the commands I am running for build and start in development // npm run build browserify -t [babelify] client.js > public/js/bundle.js", // npm start babel-node server.js" Here are my dev dependencies "babel": "^4.0.1", "babelify": "^5.0.3", "browserify": "^8.0.3" For the client side code , you're doing the correct thing. babelify

Gulp + browserify + 6to5 + source maps

不问归期 提交于 2019-11-27 05:05:40
问题 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 - How to call function bundled in a file generated through browserify in browser

≡放荡痞女 提交于 2019-11-27 02:59:37
I am new to nodejs and browserify. I started with this link . I have file main.js which contains this code var unique = require('uniq'); var data = [1, 2, 2, 3, 4, 5, 5, 5, 6]; this.LogData =function(){ console.log(unique(data)); }; Now I Install the uniq module with npm: npm install uniq Then I bundle up all the required modules starting at main.js into a single file called bundle.js with the browserify command: browserify main.js -o bundle.js The generated file looks like this: (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a

browserify error /usr/bin/env: node: No such file or directory

随声附和 提交于 2019-11-27 02:45:30
I installed node js and npm via apt-get install and all of the dependencies, then I installed browserify npm install browserify -g it goes through the process and it seems like it installed correctly, but when I try to do a simple bundle per this walkthrough I get the error: /usr/bin/env: node: No such file or directory Some linux distributions install nodejs not as "node" executable but as "nodejs". In this case you have to manually link to "node" as many packages are programmed after the "node" binary. Something similar also occurs with "python2" not linked to "python". In this case you can

React - Minified exception occurred

旧城冷巷雨未停 提交于 2019-11-27 02:02:51
问题 I have React js installed via NPM and using browserify to manage components in react. When an exception occurs in React, the console shows as "Uncaught Error: Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." How do I enable full error messages ? 回答1: Setting NODE_ENV to development as Benjamin Gruenbaum pointed out in the comment resolved the issues. set NODE_ENV=development 回答2: If you are encountering this issue

Using Bootstrap 3.0 with Browserify

懵懂的女人 提交于 2019-11-27 01:48:54
问题 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:

Multiple React components in a single module

隐身守侯 提交于 2019-11-27 01:36:15
问题 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

How to get minified output with browserify?

喜夏-厌秋 提交于 2019-11-27 00:06:16
问题 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 回答1: Pipe it through uglifyjs: browserify main.js | uglifyjs > bundle.js You can install it using npm like so: npm install -g uglify-js 回答2: 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

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

夙愿已清 提交于 2019-11-27 00:02:47
问题 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

Configure a generic jQuery plugin with Browserify-shim?

最后都变了- 提交于 2019-11-26 23:58:05
问题 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