browserify

Difficulty getting browserify-shim working with grunt-browserify (> 2.0.2) as transform

血红的双手。 提交于 2019-12-18 12:24:36
问题 In version 2.0.2 of grunt-browserify , browserify-shim was removed from the module itself and converted to be used as a transform , rather than a straightforward option on a grunt-browserify task. The old version of using the shim with grunt-browserify would look as such: 'libs-dev': { src: [path.join('<%= config.dirs.browserLibs %>', 'angular', 'angular.js')], dest: path.join('<%= config.dirs.dest.dev %>', 'js', 'libs.js'), options: { shim: { angular: { path: path.join('<%= config.dirs

Browserify import/require?

◇◆丶佛笑我妖孽 提交于 2019-12-18 12:16:23
问题 I'm trying to pick up browserify and have been through a number of examples. In one example I see the use of 'import': import 'jquery'; and importing local files with: import Header from './Header'; but in other examples I see people importing via: require('./Header'); What is the difference? 回答1: require() is the Node module system (CommonJS) in ES5. import is ES6 module syntax. If you want to browserify modules written with ES6 module syntax you'll need to compile them using something like

Browserify import/require?

一曲冷凌霜 提交于 2019-12-18 12:16:01
问题 I'm trying to pick up browserify and have been through a number of examples. In one example I see the use of 'import': import 'jquery'; and importing local files with: import Header from './Header'; but in other examples I see people importing via: require('./Header'); What is the difference? 回答1: require() is the Node module system (CommonJS) in ES5. import is ES6 module syntax. If you want to browserify modules written with ES6 module syntax you'll need to compile them using something like

Missing observable methods RxJS 5.0.0-beta.0

主宰稳场 提交于 2019-12-18 04:38:17
问题 I'm having a problem using RxJS with Angular 2. Most of methods suggested from Typescript definition file are not defined on my Observable object like... then I figured out, that methods does not exists on the Observable prototype. I know a lot of things changed from version 4 to 5,so do I miss something? Browserify added it for me... 回答1: Without seeing your actual code, I can't tell you exactly what to add to fix it. But the general problem is this: RxJS 5 is not included with Angular 2 any

Karma/Istanbul Code Coverage does not find functions and always returns 100%

被刻印的时光 ゝ 提交于 2019-12-17 19:53:40
问题 I am attempting to add Code Coverage for my Karma tests, however although it finds the correct JS files that I'm testing, it does not find the functions inside those files. From what I have read so far I believe it to be to do with the files not being correctly browserified before being passed to istanbul to do the coverage, but admittedly I am new to this so I'm hoping for some suggestions. Here is my JS file(common.js): var applicationSettings = require('./settings'); var common = {

Node JS fs module inside browser

泪湿孤枕 提交于 2019-12-17 19:34:49
问题 I have a scenario where I want to export data to CSV from the client-side. I will have a textbox/area or whatever where the user can input data and then ideally with one click, a local CSV file will be updated with that data. This is easily achievable with NodeJS with server interaction, and its core modules (specifically fs module), but apparently not so much from a browser. I found out that certain node modules (for example underscore ), support RequireJS's method of making a particular

Exporting p5.js function with Browserify

血红的双手。 提交于 2019-12-14 04:19:05
问题 Here I have a p5 object that I am exporting to be bundled by browserify: var p5 = require('p5') var colorPicker = require('./color_picker.js') module.exports = new p5(function () { this.setup = function setup () { this.createCanvas(700, 400) this.background(205) this.loadImage('/uploads/uploaded_image', function (img) { image(img, 0, 0) }) this.updatePixels() } this.clearCanvas = function redraw () { this.background('black') } this.mouseDragged = function mouseDragged () { var rgb =

how to use the exclude in browserify?

蓝咒 提交于 2019-12-14 03:51:21
问题 in browserify-handbook, exclude part,it gives an example of using the exclude: $ npm install jquery $ browserify -r jquery --standalone jquery > jquery-bundle.js then we want to just require('jquery') in a main.js: var $ = require('jquery'); $(window).click(function () { document.body.bgColor = 'red' }); defering to the jquery dist bundle so that we can write: <script src="jquery-bundle.js"></script> <script src="bundle.js"></script> and not have the jquery definition show up in bundle.js,

Gulp + Browserify task not working (no output)

折月煮酒 提交于 2019-12-13 21:35:27
问题 I have the following task on my gulpfile.js gulp.task('default', ['browserify']) gulp.task('browserify', function () { return browserify('./public/js/x.js') .bundle() .pipe(source('y.js')) .pipe(gulp.dest('./public/dist/js')) }) But after running $ gulp it gives no output. Am I missing something? 回答1: I am not sure what your browserify is but I'm gonna assume it's not the deprecated gulp-browserify . This should work. I tested it: var gulp = require('gulp'); var browserify = require(

Browserify - create bundle with external module

泄露秘密 提交于 2019-12-13 19:48:14
问题 I'm really new to browserify world. I want to use this module peer-file, in order to allow the file transfer between two browsers. Reading the Usage section into readme, I note I have to include the script bundle.js in my web page. To build the bundle I need to type browserify -r ./index.js > build.js , where -r option means external require, so I can use in my main script the keyword require() , like this: var send = require('peer-file/send') var receive = require('peer-file/receive')