browserify

Use of browserify to pack React components

谁说胖子不能爱 提交于 2019-12-02 00:43:08
I am trying to learn browserify to manage my javascript. My first simple task is to create a react.js file which will be generated by gulp + browserify var browserify = require('gulp-browserify'); gulp.task('browserify-react', function () { return gulp.src('js/react/react.js') .pipe(browserify()) .pipe(rename('react-generated.js')) .pipe(gulp.dest('./dist')); }); In js/react/ I created a file react.js which is just two require commands: var React = require('react'); var ReactDOM = require('react-dom'); I expect that a new file react-generated.js will content a react and react-dom modules. File

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

对着背影说爱祢 提交于 2019-12-01 17:01:54
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: "Success", message: "Well Done!", sound: "Glass"})); }

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

天大地大妈咪最大 提交于 2019-12-01 15:08:05
问题 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

browserify Error : http.createServer is not a function

Deadly 提交于 2019-12-01 13:25:42
I tried to browserify this node js script : var phantom = require('phantom') phantom.create(function(ph) { ph.createPage(function(page) { page.open("editor.html", function(status) { console.log("opened diagram? ", status); page.evaluate(function() { return document.getElementById("GraphImage").src; }, function(result) { //console.log(result); ph.exit(); }); }); }); }); So I used this command: browserify myscript.js > bundle.js and when I run bundle.js from an html file I get this error: http.createServer is not a function it seems that browserify does not support httpserver. How can I resolve

Gulp angular unit testing directive templateUrl

 ̄綄美尐妖づ 提交于 2019-12-01 12:04:52
问题 I read many post on internet and SO but couldn't find any solution that works I am trying to write unit test for a directive and want the html files to be served from template cache I am using Gulp as a build tool The gulp task for test looks like this gulp.task('test', function (done) { karma.start({ configFile:__dirname + '/' + config.test.karmaconf, singleRun: false }, done); }); and in karma.conf , I have defined browserify: { debug: true, transform: [['browserify-ng-html2js', { module:

How to bundle multiple javascript libraries with browserify?

情到浓时终转凉″ 提交于 2019-12-01 09:26:12
问题 I'm trying to use Browerifiy in the browser, if I use the standalone option it exposes one module. I don't want to do this. The website and documentation just seems to cut off everywhere I look after actually compiling the code. No one has said how to actually use the code in the browser property. I have a grunt task as such: browserify: { standalone: { src: [ '<%= yeoman.server %>/shared-components/**/*.js' ], dest: '<%= yeoman.client %>/app/js/browserifed-shared-code.js', /* Commented out,

Reduce Browserify bundle of react.min.js and react-dom.min.js

旧城冷巷雨未停 提交于 2019-12-01 09:24:24
问题 I want to bundle some React libs with Browserify and --require them, but was put off by the file size. I use the following Browserify command: browserify path/to/react.min.js path/to/react-dom.min.js > libs.js Now, react.min.js is 21k, react-dom.min.js is 122k, but libs.js results in a whopping 269k. Surely there is not a Browserify overhead of 126k? When I look at libs.js there is a lot of added (unminified) React code. Where does this come from? 回答1: The problem is that Browserify is

Using Node.js modules in HTML

别来无恙 提交于 2019-12-01 04:25:41
I have the following Node.js project (which is a Minimal Working Example of my problem): module1.js : module.exports = function() { return "this is module1!"; }; module2.js : var module1 = require('./module1'); module.exports = function() { return module1()+" and this is module2!"; }; server.js : var module2 = require('./module2'); console.log(module2()); // prints: "this is module1! and this is module2!" Now I want to create a client.html file that will also use module2.js. Here is what I tried (and failed): naive version : <script src='module2.js'></script> <script>alert(module2());</script>

Gulp Error: watch ENOSPC

浪尽此生 提交于 2019-12-01 04:00:14
Hi i'm getting this error while running gulp watch. im using vueify in laravel project. why is this happening. it was working fine all these days and this came in today. $ gulp watch [12:56:01] Using gulpfile ~/Documents/web_projects/next-home/gulpfile.js [12:56:01] Starting 'watch'... [12:56:01] Starting 'browserify'... Fetching Browserify Source Files... - resources/assets/js/app.js Saving To... - public/js/app.js [12:56:02] Finished 'browserify' after 707 ms [12:56:02] 'watch' errored after 722 ms [12:56:02] Error: watch /home/bazi/Documents/web_projects/next-home/resources/assets/less/

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

时间秒杀一切 提交于 2019-12-01 03:37:12
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(browserify()) the gulp did't transform the jsx code. But if I just remove .pipe(browserify()) I find that did