Compare commits
76 Commits
Author | SHA1 | Date | |
---|---|---|---|
c0bb143128 | |||
d3069ebf5f | |||
d0e6bbd162 | |||
9b27ed9e7f | |||
93ed4fbbf9 | |||
8aa5ce6a5d | |||
2992f54f11 | |||
c9929963d7 | |||
5ea199e470 | |||
e729dd8e6f | |||
54335338ab | |||
3109585d30 | |||
b28b79cae6 | |||
a7d0bfc63f | |||
f436fffecd | |||
77b5949a81 | |||
ad9dde6fb6 | |||
e928510886 | |||
7065094a84 | |||
7e210d473f | |||
e3aa4cbbcc | |||
4a7ffa1caf | |||
872eef5de8 | |||
7d464df932 | |||
712000b688 | |||
e2ed8c5f4c | |||
245449ee13 | |||
7cd695fc92 | |||
80223dc038 | |||
7b1df4148d | |||
e81288a9dd | |||
1734a2030b | |||
65b96af6a8 | |||
eec824e959 | |||
d28634a865 | |||
540d9a9b56 | |||
65c70eec98 | |||
1622715a51 | |||
2d063f1fe4 | |||
bc87a24ae8 | |||
dd2f410fdb | |||
acde823f08 | |||
6edd270a92 | |||
be43477dca | |||
03a931a9d3 | |||
f05b790e4d | |||
61dc3347c7 | |||
2de34d9928 | |||
2c69bdd39c | |||
130f8b00d7 | |||
a87263888c | |||
802a348123 | |||
74bbd71ef4 | |||
86f7e0631b | |||
0657edac50 | |||
01a89ecad1 | |||
213cd764d8 | |||
244048fccb | |||
aee39d4a33 | |||
f5f1d59c79 | |||
895063ec65 | |||
ba29214eea | |||
5fe7d563d0 | |||
29534a3c6d | |||
e5cbefd195 | |||
83ddb95968 | |||
7afda4e508 | |||
f459bd5537 | |||
53dba94a78 | |||
47b5d718ee | |||
e0902b9f6c | |||
5ee39fc04d | |||
40254e394e | |||
9306dcf0a1 | |||
9b6609a2e5 | |||
943fcf8634 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,10 +1,7 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
|
||||||
.idea/
|
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
|
||||||
ts/*.js
|
|
||||||
ts/*.js.map
|
|
||||||
ts/typings/
|
|
||||||
|
|
||||||
test/result/
|
test/result/
|
||||||
|
coverage/
|
||||||
|
docs/
|
||||||
|
pages/
|
||||||
|
public
|
||||||
|
72
.gitlab-ci.yml
Normal file
72
.gitlab-ci.yml
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# gitzone standard
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .yarn/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- trigger
|
||||||
|
- pages
|
||||||
|
|
||||||
|
testLEGACY:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci test legacy
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
testLTS:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci test lts
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
testSTABLE:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci test stable
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: trigger
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
pages:
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
stage: pages
|
||||||
|
script:
|
||||||
|
- npmci command yarn global add npmpage
|
||||||
|
- npmci command npmpage
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
@ -1,3 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
test
|
test
|
||||||
ts
|
ts
|
||||||
|
coverage/
|
16
.travis.yml
16
.travis.yml
@ -1,16 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- '4.1'
|
|
||||||
before_install:
|
|
||||||
- npm install -g tsd
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@lossless.digital
|
|
||||||
api_key:
|
|
||||||
secure: MNBFCPscAm1+rY1qIHbye3Bwif9W/bPyHxvXyoKbi8G2URQjZKNYTpRT0bVShj6UBJihBrnXa40cxmU/F+rcQhPeY4uFIC5oBIyYkSrn0XvhJEqn/yQnBl0DrdImYSuYx480jLKvvNq3RIft2K+5y6+qb8QuumV/1p4QYbiM6Ibwz54SPfmJtzsMsei8bHzbDvOtKeoX8l3mGqyIVX1D/Nnnq9rH0UZnbqf7W5IH/QlCTpVAj5v/HRCSbCbJkbmwTYtx4PV0xS9vYgXklwFr0FcJXyZPmzqSRM/EYnhOg61uQCWM1JG12nDmdv8lkE+x5L6fV+YXTeBAKmnCBAZy8D7CYX0jDELrpKp4wKFofl/AkTDAlVsjEb4U+DVXuJOWt8KQzjYGLX6nXXOUzDD9OXNmB6010a2g3SQ4vCX3jHomycPZTgKPd4MN5xiJBfg/EXn1HlJdtO8jYFB2S87VVmFrJfwQ6x4iZxabmWPtasye3DP/OLX+8/8aWNGLMjP/Lr4muPS4B9OOlI3EvVo+DR3B381NPwzKaM9NLkeM3pHgMhm0K2mqOnbvhUhhkmmMkQI1T+RRf91zraPXAh7fMRDh2lDqKfrhtKobFBmONgXAtO7QPz2Bhp+kszwRo/Vx//H2VpUD45CNfMKnN99VYY/FHGYICBYH2mK/MX50HAA=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/gulp-browser
|
|
||||||
notifications:
|
|
||||||
slack:
|
|
||||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
|
44
README.md
44
README.md
@ -1,24 +1,41 @@
|
|||||||
# gulp-browser
|
# gulp-browser
|
||||||
browserify and other goodies for gulp
|
browserify and other goodies for gulp
|
||||||
|
|
||||||
### Build Status/Dependencies
|
## Availabililty
|
||||||
[](https://travis-ci.org/pushrocks/gulp-browser)
|
[](https://www.npmjs.com/package/gulp-browser)
|
||||||
|
[](https://GitLab.com/pushrocks/gulp-browser)
|
||||||
|
[](https://github.com/pushrocks/gulp-browser)
|
||||||
|
[](https://pushrocks.gitlab.io/gulp-browser/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://GitLab.com/pushrocks/gulp-browser/commits/master)
|
||||||
|
[](https://GitLab.com/pushrocks/gulp-browser/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/gulp-browser)
|
||||||
[](https://david-dm.org/pushrocks/gulp-browser)
|
[](https://david-dm.org/pushrocks/gulp-browser)
|
||||||
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
||||||
[](https://www.bithound.io/github/pushrocks/gulp-browser)
|
[](https://www.bithound.io/github/pushrocks/gulp-browser)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
### Usage
|
Use TypeScript for best in class instellisense.
|
||||||
gulp-browser is meant to be easy:
|
|
||||||
|
|
||||||
#### Browserify:
|
#### Browserify:
|
||||||
```javascript
|
```javascript
|
||||||
var gulp = require("gulp");
|
let gulp = require("gulp");
|
||||||
var gulpBrowser = require("gulp-browser");
|
let gulpBrowser = require("gulp-browser");
|
||||||
|
|
||||||
|
let transforms = [
|
||||||
|
{
|
||||||
|
transform: "babelify",
|
||||||
|
options: {presets: ["es2015"]}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
gulp.task('gulpBrowserTest',function() {
|
gulp.task('gulpBrowserTest',function() {
|
||||||
var stream = gulp.src('./test/*.js')
|
var stream = gulp.src('./test/*.js')
|
||||||
.pipe(gulpBrowser.browserify())
|
.pipe(gulpBrowser.browserify(transforms)) // gulp.browserify() accepts an optional array of tansforms
|
||||||
.pipe(gulp.dest("./test/browserifiedJS/"));
|
.pipe(gulp.dest("./test/browserifiedJS/"));
|
||||||
return stream;
|
return stream;
|
||||||
});
|
});
|
||||||
@ -26,11 +43,8 @@ gulp-browser is meant to be easy:
|
|||||||
|
|
||||||
> **Note:** Be aware of how gulp.src creates values of file.base and file.path since that is important to the require statements.
|
> **Note:** Be aware of how gulp.src creates values of file.base and file.path since that is important to the require statements.
|
||||||
|
|
||||||
### Dev Information:
|
### Contributors
|
||||||
[](https://david-dm.org/pushrocks/gulp-browser#info=devDependencies)
|
* [Phil Kunz](https://github.com/philkunz)
|
||||||
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
* [Steffan Donal](https://github.com/SteffanDonal)
|
||||||
|
|
||||||
### About the authors:
|
[](https://push.rocks)
|
||||||
[](https://lossless.com/)
|
|
||||||
|
|
||||||
[](https://paypal.me/lossless)
|
|
||||||
|
4
dist/gulpbrowser.browserify.d.ts
vendored
Normal file
4
dist/gulpbrowser.browserify.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/// <reference types="node" />
|
||||||
|
import * as stream from 'stream';
|
||||||
|
declare let browserify: (transforms?: any[]) => stream.Transform;
|
||||||
|
export = browserify;
|
43
dist/gulpbrowser.browserify.js
vendored
Normal file
43
dist/gulpbrowser.browserify.js
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
"use strict";
|
||||||
|
const plugins = require("./gulpbrowser.plugins");
|
||||||
|
let browserify = function (transforms = []) {
|
||||||
|
if (!Array.isArray(transforms)) {
|
||||||
|
transforms = [transforms];
|
||||||
|
}
|
||||||
|
let forEach = function (file, enc, cb) {
|
||||||
|
let bundleCallback = function (err, bufferedContent) {
|
||||||
|
if (Buffer.isBuffer(bufferedContent)) {
|
||||||
|
file.contents = bufferedContent;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('gulp-browser: .browserify() ' + err.message);
|
||||||
|
cb(new Error(err.message), file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cb(null, file);
|
||||||
|
};
|
||||||
|
if (file.contents.length > 0) {
|
||||||
|
let browserified = plugins.browserify(file, { basedir: file.base });
|
||||||
|
transforms.forEach(function (transform) {
|
||||||
|
if (typeof transform === 'function') {
|
||||||
|
browserified.transform(transform);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
browserified.transform(transform.transform, transform.options);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
browserified.bundle(bundleCallback);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.warn('gulp-browser: .browserify() file.contents appears to be empty');
|
||||||
|
cb(null, file);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
};
|
||||||
|
let atEnd = function (cb) {
|
||||||
|
cb();
|
||||||
|
}; // no need to clean up after ourselves
|
||||||
|
return plugins.through2.obj(forEach, atEnd); // this is the through object that gets returned by gulpBrowser.browserify();
|
||||||
|
};
|
||||||
|
module.exports = browserify;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIuYnJvd3NlcmlmeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLmJyb3dzZXJpZnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLGlEQUFpRDtBQUdqRCxJQUFJLFVBQVUsR0FBRyxVQUFVLFVBQVUsR0FBRyxFQUFFO0lBRXRDLEVBQUUsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDN0IsVUFBVSxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUE7SUFDN0IsQ0FBQztJQUVELElBQUksT0FBTyxHQUFHLFVBQVUsSUFBSSxFQUFFLEdBQUcsRUFBRSxFQUFFO1FBRWpDLElBQUksY0FBYyxHQUFHLFVBQVUsR0FBRyxFQUFFLGVBQWU7WUFDL0MsRUFBRSxDQUFDLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxlQUFlLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQ25DLElBQUksQ0FBQyxRQUFRLEdBQUcsZUFBZSxDQUFBO1lBQ25DLENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDSixPQUFPLENBQUMsR0FBRyxDQUFDLDhCQUE4QixHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQTtnQkFDekQsRUFBRSxDQUFDLElBQUksS0FBSyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQTtnQkFDaEMsTUFBTSxDQUFBO1lBQ1YsQ0FBQztZQUNELEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUE7UUFDbEIsQ0FBQyxDQUFBO1FBRUQsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUMzQixJQUFJLFlBQVksR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLElBQUksRUFBRSxFQUFFLE9BQU8sRUFBRSxJQUFJLENBQUMsSUFBSSxFQUFFLENBQUMsQ0FBQTtZQUVuRSxVQUFVLENBQUMsT0FBTyxDQUFDLFVBQVUsU0FBUztnQkFDbEMsRUFBRSxDQUFDLENBQUMsT0FBTyxTQUFTLEtBQUssVUFBVSxDQUFDLENBQUMsQ0FBQztvQkFDbEMsWUFBWSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQTtnQkFDckMsQ0FBQztnQkFBQyxJQUFJLENBQUMsQ0FBQztvQkFDSixZQUFZLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxTQUFTLEVBQUUsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFBO2dCQUNsRSxDQUFDO1lBQ0wsQ0FBQyxDQUFDLENBQUE7WUFFRixZQUFZLENBQUMsTUFBTSxDQUFDLGNBQWMsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE9BQU8sQ0FBQyxJQUFJLENBQUMsK0RBQStELENBQUMsQ0FBQTtZQUM3RSxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFBO1FBQ2xCLENBQUM7UUFBQSxDQUFDO0lBQ04sQ0FBQyxDQUFBO0lBRUQsSUFBSSxLQUFLLEdBQUcsVUFBVSxFQUFFO1FBQ3BCLEVBQUUsRUFBRSxDQUFBO0lBQ1IsQ0FBQyxDQUFBLENBQUMsc0NBQXNDO0lBRXhDLE1BQU0sQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUEsQ0FBQyw2RUFBNkU7QUFDN0gsQ0FBQyxDQUFBO0FBRUQsaUJBQVMsVUFBVSxDQUFBIn0=
|
4
dist/gulpbrowser.plugins.d.ts
vendored
Normal file
4
dist/gulpbrowser.plugins.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import 'typings-global';
|
||||||
|
export import through2 = require('through2');
|
||||||
|
export import path = require('path');
|
||||||
|
export import browserify = require('browserify');
|
7
dist/gulpbrowser.plugins.js
vendored
Normal file
7
dist/gulpbrowser.plugins.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
require("typings-global");
|
||||||
|
exports.through2 = require("through2");
|
||||||
|
exports.path = require("path");
|
||||||
|
exports.browserify = require("browserify");
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsdUNBQTRDO0FBQzVDLCtCQUFvQztBQUNwQywyQ0FBZ0QifQ==
|
1
dist/index.d.ts
vendored
Normal file
1
dist/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export import browserify = require("./gulpbrowser.browserify");
|
4
dist/index.js
vendored
Normal file
4
dist/index.js
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.browserify = require("./gulpbrowser.browserify");
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHlEQUE4RCJ9
|
12
index.d.ts
vendored
12
index.d.ts
vendored
@ -1,12 +0,0 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
|
||||||
declare module GulpBrowserBrowserify {
|
|
||||||
function init(): () => any;
|
|
||||||
}
|
|
||||||
declare var plugins: {
|
|
||||||
beautylog: any;
|
|
||||||
through: any;
|
|
||||||
gutil: any;
|
|
||||||
path: any;
|
|
||||||
browserify: any;
|
|
||||||
};
|
|
||||||
declare var gulpBrowser: any;
|
|
37
index.js
37
index.js
@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var GulpBrowserBrowserify;
|
|
||||||
(function (GulpBrowserBrowserify) {
|
|
||||||
function init() {
|
|
||||||
return function () {
|
|
||||||
return plugins.through.obj(function (file, enc, cb) {
|
|
||||||
var bundleCallback = function (err, bufferedContent) {
|
|
||||||
if (Buffer.isBuffer(bufferedContent)) {
|
|
||||||
file.contents = bufferedContent;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
|
|
||||||
}
|
|
||||||
cb(null, file);
|
|
||||||
};
|
|
||||||
plugins.browserify(file, { basedir: file.base })
|
|
||||||
.bundle(bundleCallback);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
GulpBrowserBrowserify.init = init;
|
|
||||||
})(GulpBrowserBrowserify || (GulpBrowserBrowserify = {}));
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
/// <reference path="./modulebrowserify.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
through: require("through2"),
|
|
||||||
gutil: require("gulp-util"),
|
|
||||||
path: require("path"),
|
|
||||||
browserify: require("browserify")
|
|
||||||
};
|
|
||||||
//create the return object
|
|
||||||
var gulpBrowser = {};
|
|
||||||
gulpBrowser.browserify = GulpBrowserBrowserify.init();
|
|
||||||
module.exports = gulpBrowser;
|
|
7
npmextra.json
Normal file
7
npmextra.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"globalNpmTools": [
|
||||||
|
"npmts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
38
package.json
38
package.json
@ -1,8 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-browser",
|
"name": "gulp-browser",
|
||||||
"version": "1.0.5",
|
"version": "3.0.5",
|
||||||
"description": "browserify and other goodies for gulp",
|
"description": "browserify and other goodies for gulp",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(npmts)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"reinstall": "(rm -r node_modules && npm install)",
|
||||||
@ -12,27 +13,38 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pushrocks/gulp-browser.git"
|
"url": "https://gitlab.com/pushrocks/gulp-browser.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"gulpplugin",
|
"gulpplugin",
|
||||||
"browserify"
|
"browserify",
|
||||||
|
"browser",
|
||||||
|
"TypeScript",
|
||||||
|
"typed"
|
||||||
],
|
],
|
||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/gulp-browser/issues"
|
"url": "https://gitlab.com/pushrocks/gulp-browser/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/gulp-browser",
|
"homepage": "https://gitlab.com/pushrocks/gulp-browser",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "2.0.4",
|
"@types/browserify": "^12.0.32",
|
||||||
"browserify": "13.0.0",
|
"@types/q": "1.0.2",
|
||||||
"gulp-util": "3.0.7",
|
"@types/through2": "^2.0.33",
|
||||||
"through2": "2.0.0"
|
"browserify": "^14.4.0",
|
||||||
|
"q": "^1.5.0",
|
||||||
|
"smartq": "^1.1.6",
|
||||||
|
"through2": "^2.0.3",
|
||||||
|
"typings-global": "^1.0.19"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "3.9.0",
|
"@types/gulp": "^4.0.4",
|
||||||
"gulp-callfunction": "0.0.10",
|
"babel-preset-es2015": "^6.24.1",
|
||||||
"npmts": "^2.0.2"
|
"babelify": "^7.3.0",
|
||||||
|
"beautylog": "^6.1.10",
|
||||||
|
"gulp": "^3.9.1",
|
||||||
|
"gulp-function": "^2.2.9",
|
||||||
|
"tapbundle": "^1.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
test/test.js
29
test/test.js
@ -1,29 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
gulpBrowser: require("../index.js"),
|
|
||||||
gulpCallFunction: require("gulp-callfunction")
|
|
||||||
};
|
|
||||||
describe("gulpBrowser", function () {
|
|
||||||
describe(".browserify", function () {
|
|
||||||
it("should run through smoothly", function (done) {
|
|
||||||
this.timeout(15000);
|
|
||||||
plugins.gulp.task('gulpBrowserNormal', function (cb) {
|
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTest.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
|
||||||
.pipe(plugins.gulp.dest("./test/result/"))
|
|
||||||
.pipe(plugins.gulpCallFunction(done));
|
|
||||||
return stream;
|
|
||||||
});
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['gulpBrowserNormal']);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
plugins.gulp.task('gulpBrowserTestError', function (cb) {
|
|
||||||
plugins.beautylog.info("Expecting an error:");
|
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTestError.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
|
||||||
.pipe(plugins.gulp.dest("./test/result/"));
|
|
||||||
return stream;
|
|
||||||
});
|
|
66
test/test.ts
Normal file
66
test/test.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import * as beautylog from 'beautylog'
|
||||||
|
import * as gulp from 'gulp'
|
||||||
|
import * as gulpFunction from 'gulp-function'
|
||||||
|
import * as smartq from 'smartq'
|
||||||
|
|
||||||
|
import { expect, tap } from 'tapbundle'
|
||||||
|
|
||||||
|
import * as gulpBrowser from '../dist/index.js'
|
||||||
|
|
||||||
|
tap.test('should run through smoothly', async () => {
|
||||||
|
let done = smartq.defer()
|
||||||
|
let stream = gulp.src('./test/testBrowserifyNormal.js')
|
||||||
|
.pipe(gulpBrowser.browserify())
|
||||||
|
.pipe(gulp.dest('./test/result/'))
|
||||||
|
.pipe(gulpFunction.atEnd(async () => {
|
||||||
|
done.resolve()
|
||||||
|
}))
|
||||||
|
await done.promise
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('should throw an error, when a module is not found', async () => {
|
||||||
|
let done = smartq.defer()
|
||||||
|
let d = require('domain').create()
|
||||||
|
let doneCalled = false
|
||||||
|
d.on('error', function (error) {
|
||||||
|
if (!doneCalled) {
|
||||||
|
done.resolve()
|
||||||
|
doneCalled = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
d.run(function () {
|
||||||
|
let stream = gulp.src('./test/testBrowserifyError.js')
|
||||||
|
.pipe(gulpBrowser.browserify())
|
||||||
|
})
|
||||||
|
await done.promise
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('should run through with an empty file', async () => {
|
||||||
|
let done = smartq.defer()
|
||||||
|
let stream = gulp.src('./test/testBrowserifyEmpty.js')
|
||||||
|
.pipe(gulpBrowser.browserify())
|
||||||
|
.pipe(gulp.dest('./test/result/'))
|
||||||
|
.pipe(gulpFunction.atEnd(async () => {
|
||||||
|
done.resolve()
|
||||||
|
}))
|
||||||
|
await done.promise
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('should run through work with transforms', async () => {
|
||||||
|
let done = smartq.defer()
|
||||||
|
let transforms = [
|
||||||
|
{
|
||||||
|
transform: 'babelify',
|
||||||
|
options: { presets: [ 'es2015' ] }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
let stream = gulp.src('./test/testBrowserifyNormal.js')
|
||||||
|
.pipe(gulpBrowser.browserify(transforms))
|
||||||
|
.pipe(gulp.dest('./test/result/'))
|
||||||
|
.pipe(gulpFunction.atEnd(async () => {
|
||||||
|
done.resolve()
|
||||||
|
}))
|
||||||
|
await done.promise
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.start()
|
0
test/testBrowserifyEmpty.js
Normal file
0
test/testBrowserifyEmpty.js
Normal file
49
ts/gulpbrowser.browserify.ts
Normal file
49
ts/gulpbrowser.browserify.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import * as stream from 'stream'
|
||||||
|
import plugins = require('./gulpbrowser.plugins')
|
||||||
|
import * as q from 'q'
|
||||||
|
|
||||||
|
let browserify = function (transforms = []) {
|
||||||
|
|
||||||
|
if (!Array.isArray(transforms)) {
|
||||||
|
transforms = [transforms]
|
||||||
|
}
|
||||||
|
|
||||||
|
let forEach = function (file, enc, cb) { // do this with every chunk (file in gulp terms)
|
||||||
|
|
||||||
|
let bundleCallback = function (err, bufferedContent) { // our bundle callback for when browserify is finished
|
||||||
|
if (Buffer.isBuffer(bufferedContent)) {
|
||||||
|
file.contents = bufferedContent
|
||||||
|
} else {
|
||||||
|
console.log('gulp-browser: .browserify() ' + err.message)
|
||||||
|
cb(new Error(err.message), file)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cb(null, file)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.contents.length > 0) {
|
||||||
|
let browserified = plugins.browserify(file, { basedir: file.base })
|
||||||
|
|
||||||
|
transforms.forEach(function (transform) {
|
||||||
|
if (typeof transform === 'function') {
|
||||||
|
browserified.transform(transform)
|
||||||
|
} else {
|
||||||
|
browserified.transform(transform.transform, transform.options)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
browserified.bundle(bundleCallback)
|
||||||
|
} else {
|
||||||
|
console.warn('gulp-browser: .browserify() file.contents appears to be empty')
|
||||||
|
cb(null, file)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let atEnd = function (cb) {
|
||||||
|
cb()
|
||||||
|
} // no need to clean up after ourselves
|
||||||
|
|
||||||
|
return plugins.through2.obj(forEach, atEnd) // this is the through object that gets returned by gulpBrowser.browserify();
|
||||||
|
}
|
||||||
|
|
||||||
|
export = browserify
|
4
ts/gulpbrowser.plugins.ts
Normal file
4
ts/gulpbrowser.plugins.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import 'typings-global'
|
||||||
|
export import through2 = require('through2')
|
||||||
|
export import path = require('path')
|
||||||
|
export import browserify = require('browserify')
|
19
ts/index.ts
19
ts/index.ts
@ -1,18 +1 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
export import browserify = require("./gulpbrowser.browserify")
|
||||||
/// <reference path="./modulebrowserify.ts" />
|
|
||||||
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
through: require("through2"),
|
|
||||||
gutil: require("gulp-util"),
|
|
||||||
path: require("path"),
|
|
||||||
browserify: require("browserify")
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//create the return object
|
|
||||||
var gulpBrowser:any = {};
|
|
||||||
|
|
||||||
gulpBrowser.browserify = GulpBrowserBrowserify.init();
|
|
||||||
|
|
||||||
module.exports = gulpBrowser;
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
module GulpBrowserBrowserify {
|
|
||||||
export function init() {
|
|
||||||
return function() {
|
|
||||||
return plugins.through.obj((file, enc, cb) => { //this is the through object that gets returned by gulpBrowser.browserify();
|
|
||||||
var bundleCallback = function(err, bufferedContent) {
|
|
||||||
if (Buffer.isBuffer(bufferedContent)){
|
|
||||||
file.contents = bufferedContent;
|
|
||||||
} else {
|
|
||||||
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
|
|
||||||
}
|
|
||||||
cb(null,file);
|
|
||||||
};
|
|
||||||
plugins.browserify(file, { basedir: file.base })
|
|
||||||
.bundle(bundleCallback)
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
31
ts/test.ts
31
ts/test.ts
@ -1,31 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
gulpBrowser: require("../index.js"),
|
|
||||||
gulpCallFunction: require("gulp-callfunction")
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("gulpBrowser",function(){
|
|
||||||
describe(".browserify",function(){
|
|
||||||
it("should run through smoothly",function(done){
|
|
||||||
this.timeout(15000);
|
|
||||||
plugins.gulp.task('gulpBrowserNormal',function(cb) {
|
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTest.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
|
||||||
.pipe(plugins.gulp.dest("./test/result/"))
|
|
||||||
.pipe(plugins.gulpCallFunction(done));
|
|
||||||
return stream;
|
|
||||||
});
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['gulpBrowserNormal']);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task('gulpBrowserTestError',function(cb) {
|
|
||||||
plugins.beautylog.info("Expecting an error:");
|
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTestError.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
|
||||||
.pipe(plugins.gulp.dest("./test/result/"))
|
|
||||||
return stream;
|
|
||||||
});
|
|
15
ts/tsd.json
15
ts/tsd.json
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
|
||||||
},
|
|
||||||
"browserify/browserify.d.ts": {
|
|
||||||
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"ambientDependencies": {
|
|
||||||
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts#3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9",
|
|
||||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
|
||||||
}
|
|
||||||
}
|
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "tslint-config-standard"
|
||||||
|
}
|
Reference in New Issue
Block a user