browserify

How do you use JSHint and Browserify together?

混江龙づ霸主 提交于 2019-11-29 17:16:32
问题 I'm attempting to build a project using Angular and Browserify. My controllers.js file looks like this... 'use strict'; module.exports.testController = function($scope){ $scope.message = 'Controller 1'; console.log( 'hello' ); }; As you may expect, that generates three linting errors. Use the function form of Strict 'module' is not defined 'console' is not defined I did find a bit of a solution here that enables JSHint to process Node.js files by putting jslint node: true at the top of the

Compacting node_modules for client-side deployment

北慕城南 提交于 2019-11-29 14:14:54
I'm implementing a client-side application in JavaScript using Node.js. Because I will be deploying the software on many machines, I would like to minimize the size of the package I distribute. In particular, I would like to remove any unnecessary files from node_modules. For starters this means deduping and pruning the dependency tree, which npm can do for me. But I'd also like to remove all the package.json files and (especially) any other files that are not needed for deployment. In many of the packages I am using there are tons of tests, multiple versions of files (minified, browserified,

order dependencies: jQuery is not defined with browserify

随声附和 提交于 2019-11-29 13:33:32
问题 I am trying to use a plugin that is in /js/lib/stellar.jquery.js : var $ = require('jquery'); require('./lib/stellar.jquery') $(function(){ $.stellar(); }); When I run this though I get jQuery is not defined. I think the stellar jQuery plugin is loading before the jq library. At the bottom of the stellar plugin there's this code: ... // Expose the plugin class so it can be modified window.Stellar = Plugin; }(jQuery, this, document)); Changing "jQuery" to "$" does not work either, gives "$ is

Howto patch/shim crypto.getRandomValues for React Native

扶醉桌前 提交于 2019-11-29 12:08:32
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('babel-plugin-rewrite-require'), { aliases: { crypto: 'crypto-browserify', // ... },

Shim a jQuery plugin with browserify

吃可爱长大的小学妹 提交于 2019-11-29 07:53:13
问题 Hi I'm using the grunt browserify task to setup my code, I have shimmed in jQuery and I'm now trying to include jquery.tablesorter. Can jquery plugins be used with browserify in this way? shim: { jquery: { path: 'lib/bower/jquery/jquery.js', exports: '$' }, 'jquery.tablesorter': { path: 'lib/bower/jquery.tablesorter/js/jquery.tablesorter.js', exports: 'tablesorter', depends: { jquery: '$', } } } 回答1: You may try by doing this: shim: { jquery: { path: 'lib/bower/jquery/jquery.js', exports: '$'

Missing observable methods RxJS 5.0.0-beta.0

混江龙づ霸主 提交于 2019-11-29 06:12:38
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... Michael Oryl 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 longer now that it has entered the Beta stage. You will need to import either the operator(s)

Get browserify require paths to behave more like requirejs

我的梦境 提交于 2019-11-29 06:12:08
问题 I'm finding that it's a pain when moving files around and constantly having to rewrite the file include paths to be relative to their new folder. I want to avoid this in my browserify code: var View = require('../../../../base/view'); And do something more in line with requirejs where it knows my base path is js : var View = require('base/view'); 回答1: You should use the paths option. It is not documented in browserify but in node-browser-resolve (used under the hood): paths - require.paths

Node/NPM: Can one npm package expose more than one file?

拜拜、爱过 提交于 2019-11-29 03:58:06
I have made a JS library for web development, it consists of several modules, which build up multiple distribution builds. It's fine when it is distributed over cdn or for example using Bower. But now I'm trying to publish it with NPM so that it can be consumed using Browserify. My question is how can I expose more than one main file statically so that they can be consumable by Browserify. you don't need to do anything. require('my-library') // will require the `main` entry point require('my-library/some-other-file') // will require a different file 来源: https://stackoverflow.com/questions

How do I watch multiple files with gulp-browserify but process only one?

久未见 提交于 2019-11-29 02:52:27
问题 I'm trying to wire up gulp-browserify and gulp-watch to rebuild my bundle each time a source file changes. However, gulp-browserify requires a single entry point for the compilation (e.g. src/js/app.js ) and fetches every dependency itself: gulp.src('src/js/app.js') .pipe(browserify()) .pipe(gulp.dest('dist')) However, with gulp-watch this fails to rebuild on every change because only the entry point file is being watched. What I actually need is a possibility to watch multiple files and then

Singleton pattern with Browserify/CommonJS

送分小仙女□ 提交于 2019-11-29 02:48:00
问题 Trying to implement the singleton pattern within CommonJS modules, using Browserify. So far: // foo.js var instance = null; var Foo = function(){ if(instance){ return instance; } this.num = 0; return instance = new Foo(); } Foo.prototype.adder = function(){ this.num++; }; module.exports = Foo(); // main.js var foo = require('./foo.js'); console.log(foo.num); // should be 0 foo.adder(); // should be 1 var bar = require('./foo.js'); console.log(bar.num); // like to think it'd be 1, not 0 First