browserify

how to output multiple bundles with browserify and gulp

孤街浪徒 提交于 2020-01-30 14:16:26
问题 I have browserify bundling up files and it's working great. But what if I need to generate multiple bundles? I would like to end up with dist/appBundle.js and dist/publicBundle.js gulp.task("js", function(){ return browserify([ "./js/app.js", "./js/public.js" ]) .bundle() .pipe(source("bundle.js")) .pipe(gulp.dest("./dist")); }); Obviously this isn't going to work since I am only specifying one output (bundle.js). I can accomplish this by repeating the above statement like so (but it doesn't

can't browserify file - “Error: Parsing file” (HTML5 checkValidity() ?)

牧云@^-^@ 提交于 2020-01-25 08:35:12
问题 I want to see if I can test form field validation using mocha & chai. I have the following files: ./src/index.html : <!doctype html> <html> <head> <title>TDD Project</title> <style> #container {width: 600px; max-width: 100%; margin: 1em auto;} </style> <link rel="stylesheet" href="../node_modules/mocha/mocha.css"> </head> <body> <div id="container"> <form> <input type="text" id="text" placeholder="enter some text" required maxlength="10" pattern="^[a-z,A-Z]{1,10}$"><br /> <input type="text"

How do I import an NPM module without using 'require' or 'import'?

。_饼干妹妹 提交于 2020-01-24 00:34:09
问题 I know this is probably a very common and widely answered question. One of the reasons I know it, is because i've spent the last 3 hours figuring out how I shall be importing 3rd party libraries properly in my project which does not support the use of 'import' or 'require'. It is most likely something very fundamental that i'm missing, but I have reached the point where i'm literally steaming with anger from not being able to find a solution. So my case ATM: I am currently working on a

Trying to export a class as a module ES6 babel

天大地大妈咪最大 提交于 2020-01-23 16:24:27
问题 I have an ES6 class which I am trying to export as a module, however I am getting an error SyntaxError: Unexpected reserved word Car.js class Car { constructor(make) { this.make = make; this.currentSpeed = 25; } printCurrentSpeed(){ console.log(this.make + ' is going ' + this.currentSpeed + ' mph.'); } } module.exports = Car; I am trying to use the Car module like this main.js var Car = require("./models/Car"); let must = new Car('Mustang'); console.log(must.printCurrentSpeed()); I am using

Creating a bundle supporting browserify and jQuery <script> tag loading

余生颓废 提交于 2020-01-23 06:28:38
问题 I am working on a JavaScript library (bitcoin-prices.js) which I'd like to maintain using browserify. The library depends on jQuery. I would not like to force the library users move to browserify, but retain "drop one file + script tag" integration for those who have not drank the latest koolaid from JavaScript community. My question is how to create a bundle.js with browserify, so that browserify-enabled users can install the package from NPM, having proper jQuery dependency Traditional

Gulp with browserify: Cannot find module src/js/main.js

喜欢而已 提交于 2020-01-23 06:17:08
问题 I'm trying to get a basic build set up using Gulp and browserify, but keep seeing this error when trying to run the default task: Error: Cannot find module 'src/js/main.js' from '/Users/ben/dev/git/myapp/' gulpfile.js var gulp = require('gulp'); var browserify = require('browserify'); var del = require('del'); var source = require('vinyl-source-stream'); var paths = { main_js: ['src/js/main.js'], js: ['src/js/*.js'] }; gulp.task('clean', function(done) { del(['build'], done); }); gulp.task(

Wavesurfer.js is working fine, but react-wavesurfer has issues

╄→гoц情女王★ 提交于 2020-01-22 10:07:29
问题 I have run into a roadblock on my web project that uses Wavesurfer. I have installed wavesurfer.js and react-wavesurfer as node modules in my project. Wavesurfer.js seems to be working fine, but react-wavesurfer seems to be encountering issues that I am finding difficult to debug. The following code: import React from "react"; import WaveSurfer from "wavesurfer.js" import ReactWavesurfer from "react-wavesurfer"; class Waveform extends React.Component { makeWave() { var wavesurfer = WaveSurfer

Wavesurfer.js is working fine, but react-wavesurfer has issues

北战南征 提交于 2020-01-22 10:07:13
问题 I have run into a roadblock on my web project that uses Wavesurfer. I have installed wavesurfer.js and react-wavesurfer as node modules in my project. Wavesurfer.js seems to be working fine, but react-wavesurfer seems to be encountering issues that I am finding difficult to debug. The following code: import React from "react"; import WaveSurfer from "wavesurfer.js" import ReactWavesurfer from "react-wavesurfer"; class Waveform extends React.Component { makeWave() { var wavesurfer = WaveSurfer

Browserify with jQuery >= 2 produces “jQuery requires a window with a document”

北慕城南 提交于 2020-01-22 09:46:22
问题 I'm using browserify to bundle my front-end javascript using CommonJS-style dependencies. For example, I have: $ = require('jquery/dist/jquery'); // v2.1.0-beta2 _ = require('underscore'); Backbone = require('backbone'); However, when browserify bundles the dependencies I run into the following console error: Error: jQuery requires a window with a document Looking at the jQuery code, I see it's trying to use this for the global window . (function( window, factory ) { .... }(this, function(

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

孤街浪徒 提交于 2020-01-19 06:52:51
问题 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