browserify

How to avoid code duplication using Browserify

佐手、 提交于 2019-12-10 19:26:58
问题 CommonJS noob here, I read about browserify and thought it was simpler than my existing RequireJS setup, so I went ahead and changed them. What I have found out is I am going to have code duplication in each bundle. Let me explain: Lets say, I have page1.js and page2.js make use of jquery.js and jquery-ui.js Now I have to create bundle1.js and bundle2.js and the content of jquery.js and jquery-ui.js is duplicated in each bundle. I have tried separated into different files in browser by only

Angular 2 NgModel doesn't work

我的未来我决定 提交于 2019-12-10 18:28:24
问题 I'm starting my transition from Angular 1 to Angular 2. I tried to do simple things first so I wrote a component: import {Component} from 'angular2/core'; import {NgModel} from 'angular2/common'; @Component({ selector: 'app', template: ` <div> <div>Value is {{ value }}</div> <input type="text" [(ngModel)]="value" /> </div> `, directives: [NgModel] }) export class App { value: string; }; <!DOCTYPE html> <html> <head> <title>Angular2</title> </head> <body> <app></app> <script src="./js/bundle

Reactify transform not running when declared in package.json

我怕爱的太早我们不能终老 提交于 2019-12-10 17:48:23
问题 I'm trying to use the reactify transform with browserify and gulp. This gulp task works: return browserify({ paths: ['./node_modules','./app/scripts/'], entries: ['./app/scripts/index.js'], transform: ['reactify'], debug: true }) .bundle() .pipe(source('bundle.js')) .pipe(gulp.dest('.tmp/scripts/')); If i remove the transform key from gulp and move it to package.json: "browserify": { "transform": [ ["reactify", {"es6": true}] ] } The transform no longer runs (also tried without es6). I'm

this inside prototype function equal to window instead of object instance

可紊 提交于 2019-12-10 16:27:52
问题 In the following code in HeadDirective.prototype.link , this is equal to the global window object rather than the HeadDirective instance. My understanding is that the value of this inside a prototype function is the containing object itself. var HeadDirective = (function () { function HeadDirective($rootScope, $compile) { this.$rootScope = $rootScope; this.$compile = $compile; this.restrict = 'E'; } HeadDirective.prototype.link = function (scope, elem) { var html = '<link rel="stylesheet" ng

gulp.watch() not working with ftp update

[亡魂溺海] 提交于 2019-12-10 15:58:44
问题 I have recently learnt gulp and scripted this gulp script on my local computer, so that it can watch for any changes, and compile my javascripts (in this case, ./js/main.js with its dependencies) into a single file ./js/bundle.js : var gulp = require('gulp'); // Plugins var jshint = require('gulp-jshint'); var browserify = require('gulp-browserify'); var rename = require('gulp-rename'); // Lint Task gulp.task('lint', function() { return gulp.src(['./js/**/*.js', '!./js/bundle.js']) .pipe

node browserify for node core libraries

青春壹個敷衍的年華 提交于 2019-12-10 15:33:45
问题 This is a question just to confirm my understanding of node browserify. substack/node-browserify says: compatibility: Many npm modules that don't do IO will just work after being browserified. Others take more work. Many node built-in modules have been wrapped to work in the browser, but only when you explicitly require() or use their functionality. -- get browser versions of the node core libraries events, stream, path, url, assert, buffer, util, querystring, http, vm, and crypto when you

Write TypeScript and emit a library for Browser and Node

﹥>﹥吖頭↗ 提交于 2019-12-10 15:08:37
问题 I have an internal library used in Node.js and browser. It has many files, concatenated with a Grunt task and different prologues, one for browser, one for Node: browser: // dependent 3rd-party libs like Mustache are already global window.myLib = { /*just a namespace object filled with stuff later*/ } // then comes the plain javascript which just adds elements to myLib. // This part is identical to that used in Node // example: myLib.renderPartDetail = function (...) {...}; Node: var Mustache

How should I transform ES6 node_modules with browserify and babelify?

孤人 提交于 2019-12-10 14:16:16
问题 I'm using gulp, browserify and babelify in order to use ES6 syntax in my project. As soon as I import a node_module, which was also written in ES6, gulp throws an error: 'import' and 'export' may appear only with 'sourceType: module' I've read the proposed solutions on babelify's github page. In short, the two possibilities are: Add a browserify option to the affected node_module's package.json Configure gulp, so that browserify tries to transform all files with babelify (and add an ignore

NPM installation error

房东的猫 提交于 2019-12-10 13:54:05
问题 I tried installing browserify (npm module).. I got following error- praful@ubuntu:~/terminalcloud$ npm install -g browserify npm http GET https://registry.npmjs.org/browserify npm ERR! Error: failed to fetch from registry: browserify npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12 npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9) npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client /request.js:136:18) npm ERR! at

How to use gulp to build JavaScript bundles?

寵の児 提交于 2019-12-10 13:43:30
问题 I want to use gulp to build bundles of JavaScript files. For example I have the following structure in my project: /vendor/vendor1/vendor1.js /vendor/vendor2/vendor2.js /js/includes/include1.js /js/includes/include2.js /js/bundle1.js /js/bundle2.js There are vendor includes (1-2), local includes (3-4), and bundle files (5-6). Vendor includes are just third-party JavaScript libraries installed with bower or composer. They can be CommonJS , AMD or just a plain-old jQuery plugins. I want to