Compare commits
70 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
6de689a766 | |||
774269da57 | |||
6a884cda78 | |||
3e46c8c927 | |||
31d1fae5a2 | |||
95e874c8e8 | |||
6594932cbd | |||
9457f3ce8a | |||
eb636603ab | |||
462d11da27 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -5,5 +5,10 @@ npm-debug.log
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
ts/typings/
|
||||
|
||||
test/result/
|
||||
test/result/
|
||||
|
||||
coverage/
|
||||
|
||||
docs/
|
37
.gitlab-ci.yml
Normal file
37
.gitlab-ci.yml
Normal file
@ -0,0 +1,37 @@
|
||||
image: hosttoday/ht-docker-node:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- page
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish npm
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
@ -1,3 +1,4 @@
|
||||
node_modules
|
||||
test
|
||||
ts
|
||||
ts
|
||||
coverage/
|
@ -1,8 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '4.1'
|
||||
before_install:
|
||||
- npm install -g tsd
|
||||
- 4
|
||||
- stable
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@lossless.digital
|
||||
|
34
README.md
34
README.md
@ -1,24 +1,31 @@
|
||||
# gulp-browser
|
||||
browserify and other goodies for gulp
|
||||
|
||||
### Build Status/Dependencies
|
||||
[](https://travis-ci.org/pushrocks/gulp-browser)
|
||||
### Status
|
||||
[](https://gitlab.com/pushrocks/gulp-browser/commits/master)
|
||||
[](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)
|
||||
|
||||
[](https://codecov.io/github/pushrocks/gulp-browser?branch=master)
|
||||
|
||||
### Usage
|
||||
gulp-browser is meant to be easy:
|
||||
|
||||
#### Browserify:
|
||||
```javascript
|
||||
var gulp = require("gulp");
|
||||
var gulpBrowser = require("gulp-browser");
|
||||
```typescript
|
||||
let gulp = require("gulp");
|
||||
let gulpBrowser = require("gulp-browser");
|
||||
|
||||
let transforms = [
|
||||
{
|
||||
transform: "babelify",
|
||||
options: {presets: ["es2015", "react"]}
|
||||
}
|
||||
];
|
||||
|
||||
gulp.task('gulpBrowserTest',function() {
|
||||
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/"));
|
||||
return stream;
|
||||
});
|
||||
@ -30,7 +37,14 @@ gulp-browser is meant to be easy:
|
||||
[](https://david-dm.org/pushrocks/gulp-browser#info=devDependencies)
|
||||
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
||||
|
||||
### About the authors:
|
||||
[](https://lossless.com/)
|
||||
### Extending this module
|
||||
If you have ideas for other great browser related gulp pipe stops, feel free to raise an issue on GitHub.
|
||||
|
||||
[](https://paypal.me/lossless)
|
||||
### Contributors
|
||||
* [Phil Kunz](https://github.com/philkunz)
|
||||
* [Steffan Donal](https://github.com/SteffanDonal)
|
||||
|
||||
### About the maintainer:
|
||||
[](https://lossless.com/)
|
||||
|
||||
[](https://paypal.me/lossless)
|
3
dist/gulpbrowser.browserify.d.ts
vendored
Normal file
3
dist/gulpbrowser.browserify.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import "typings-global";
|
||||
declare let browserify: (transforms?: any[]) => any;
|
||||
export = browserify;
|
46
dist/gulpbrowser.browserify.js
vendored
Normal file
46
dist/gulpbrowser.browserify.js
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./gulpbrowser.plugins");
|
||||
var browserify = function (transforms) {
|
||||
if (transforms === void 0) { transforms = []; }
|
||||
if (!Array.isArray(transforms)) {
|
||||
transforms = [transforms];
|
||||
}
|
||||
var forEach = 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(new Error(err.message), file);
|
||||
return;
|
||||
}
|
||||
cb(null, file);
|
||||
};
|
||||
if (file.contents.length > 0) {
|
||||
var browserified_1 = plugins.browserify(file, { basedir: file.base });
|
||||
transforms.forEach(function (transform) {
|
||||
if (typeof transform === 'function') {
|
||||
browserified_1.transform(transform);
|
||||
}
|
||||
else {
|
||||
browserified_1.transform(transform.transform, transform.options);
|
||||
}
|
||||
});
|
||||
browserified_1.bundle(bundleCallback);
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.warn("gulp-browser: .browserify() file.contents appears to be empty");
|
||||
cb(null, file);
|
||||
}
|
||||
;
|
||||
};
|
||||
var atEnd = function (cb) {
|
||||
cb();
|
||||
}; // no need to clean up after ourselves
|
||||
return plugins.through.obj(forEach, atEnd); // this is the through object that gets returned by gulpBrowser.browserify();
|
||||
};
|
||||
module.exports = browserify;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBicm93c2VyLmJyb3dzZXJpZnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFPLE9BQU8sV0FBVyx1QkFBdUIsQ0FBQyxDQUFDO0FBR2xELElBQUksVUFBVSxHQUFJLFVBQVMsVUFBZTtJQUFmLDBCQUFlLEdBQWYsZUFBZTtJQUV0QyxFQUFFLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzdCLFVBQVUsR0FBRyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0lBQzlCLENBQUM7SUFFRCxJQUFJLE9BQU8sR0FBRyxVQUFTLElBQUksRUFBRSxHQUFHLEVBQUUsRUFBRTtRQUVoQyxJQUFJLGNBQWMsR0FBR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ICAgICAgICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgICAgICAgICAgYnJvd3NlcmlmaWVkLnRyYW5zZm9ybSh0cmFuc2Zvcm0udHJhbnNmb3JtLCB0cmFuc2Zvcm0ub3B0aW9ucyk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgIH0pO1xyXG5cclxuICAgICAgICAgICAgYnJvd3NlcmlmaWVkLmJ1bmRsZShidW5kbGVDYWxsYmFjayk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgcGx1Z2lucy5iZWF1dHlsb2cud2FybihcImd1bHAtYnJvd3NlcjogLmJyb3dzZXJpZnkoKSBmaWxlLmNvbnRlbnRzIGFwcGVhcnMgdG8gYmUgZW1wdHlcIik7XHJcbiAgICAgICAgICAgIGNiKG51bGwsZmlsZSk7XHJcbiAgICAgICAgfTtcclxuICAgIH1cclxuXHJcbiAgICBsZXQgYXRFbmQgPSBmdW5jdGlvbihjYil7XHJcbiAgICAgICAgY2IoKTtcclxuICAgIH0gLy8gbm8gbmVlZCB0byBjbGVhbiB1cCBhZnRlciBvdXJzZWx2ZXNcclxuXHJcbiAgICByZXR1cm4gcGx1Z2lucy50aHJvdWdoLm9iaihmb3JFYWNoLGF0RW5kKTsgLy8gdGhpcyBpcyB0aGUgdGhyb3VnaCBvYmplY3QgdGhhdCBnZXRzIHJldHVybmVkIGJ5IGd1bHBCcm93c2VyLmJyb3dzZXJpZnkoKTtcclxuIH07XHJcblxyXG5leHBvcnQgPSBicm93c2VyaWZ5O1xyXG4iXX0=
|
5
dist/gulpbrowser.plugins.d.ts
vendored
Normal file
5
dist/gulpbrowser.plugins.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import "typings-global";
|
||||
export declare let beautylog: any;
|
||||
export declare let through: any;
|
||||
export declare let path: any;
|
||||
export declare let browserify: any;
|
8
dist/gulpbrowser.plugins.js
vendored
Normal file
8
dist/gulpbrowser.plugins.js
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.through = require("through2");
|
||||
exports.path = require("path");
|
||||
exports.browserify = require("browserify");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBicm93c2VyLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUNiLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGVBQU8sR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7QUFDOUIsWUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUN2QixrQkFBVSxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQyIsImZpbGUiOiJndWxwYnJvd3Nlci5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcclxuZXhwb3J0IGxldCBiZWF1dHlsb2cgPSByZXF1aXJlKFwiYmVhdXR5bG9nXCIpO1xyXG5leHBvcnQgbGV0IHRocm91Z2ggPSByZXF1aXJlKFwidGhyb3VnaDJcIik7XHJcbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xyXG5leHBvcnQgbGV0IGJyb3dzZXJpZnkgPSByZXF1aXJlKFwiYnJvd3NlcmlmeVwiKTtcclxuIl19
|
2
dist/index.d.ts
vendored
Normal file
2
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import "typings-global";
|
||||
export import browserify = require("./gulpbrowser.browserify");
|
5
dist/index.js
vendored
Normal file
5
dist/index.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.browserify = require("./gulpbrowser.browserify");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFVixrQkFBVSxXQUFXLDBCQUEwQixDQUFDLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiO1xyXG5cclxuZXhwb3J0IGltcG9ydCBicm93c2VyaWZ5ID0gcmVxdWlyZShcIi4vZ3VscGJyb3dzZXIuYnJvd3NlcmlmeVwiKTtcclxuXHJcbiJdfQ==
|
12
index.d.ts
vendored
12
index.d.ts
vendored
@ -1,12 +0,0 @@
|
||||
/// <reference path="ts/typings/tsd.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)
|
||||
.bundle(bundleCallback);
|
||||
});
|
||||
};
|
||||
}
|
||||
GulpBrowserBrowserify.init = init;
|
||||
})(GulpBrowserBrowserify || (GulpBrowserBrowserify = {}));
|
||||
/// <reference path="./typings/tsd.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;
|
4
npmts.json
Normal file
4
npmts.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coveralls":true
|
||||
}
|
28
package.json
28
package.json
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "gulp-browser",
|
||||
"version": "1.0.3",
|
||||
"version": "2.1.8",
|
||||
"description": "browserify and other goodies for gulp",
|
||||
"main": "index.js",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"test": "(npmts) && (node test.js)",
|
||||
"test": "(npmts)",
|
||||
"reinstall": "(rm -r node_modules && npm install)",
|
||||
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
||||
"update": "(git checkout master && git pull origin master && npm install)",
|
||||
@ -12,7 +12,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pushrocks/gulp-browser.git"
|
||||
"url": "https://gitlab.com/pushrocks/gulp-browser.git"
|
||||
},
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
@ -21,18 +21,20 @@
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"license": "MIT",
|
||||
"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": {
|
||||
"browserify": "13.0.0",
|
||||
"gulp-util": "3.0.7",
|
||||
"through2": "2.0.0"
|
||||
"beautylog": "^5.0.8",
|
||||
"browserify": "^13.0.1",
|
||||
"through2": "^2.0.1",
|
||||
"typings-global": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"beautylog": "2.0.2",
|
||||
"gulp": "3.9.0",
|
||||
"gulp-callfunction": "0.0.10",
|
||||
"npmts": "^1.0.9"
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-function": "^1.3.1",
|
||||
"npmts": "^5.2.1",
|
||||
"should": "^9.0.0",
|
||||
"typings-test": "^1.0.1"
|
||||
}
|
||||
}
|
||||
|
29
test.js
29
test.js
@ -1,29 +0,0 @@
|
||||
/// <reference path="./typings/tsd.d.ts" />
|
||||
var plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
gulp: require("gulp"),
|
||||
gulpBrowser: require("./index.js"),
|
||||
gulpCallFunction: require("gulp-callfunction")
|
||||
};
|
||||
var pipeWorked = function () {
|
||||
plugins.beautylog.info("Pipe didn't break! Ready for Primetime!");
|
||||
};
|
||||
plugins.beautylog.log('Now trying to browserify a testfile...');
|
||||
plugins.gulp.task('gulpBrowserTest', function (cb) {
|
||||
var stream = plugins.gulp.src('./test/browserifyGulpTest.js')
|
||||
.pipe(plugins.gulpBrowser.browserify())
|
||||
.pipe(plugins.gulp.dest("./test/result/"))
|
||||
.pipe(plugins.gulpCallFunction(pipeWorked));
|
||||
return stream;
|
||||
});
|
||||
plugins.gulp.task('gulpBrowserTestError', function (cb) {
|
||||
var stream = plugins.gulp.src('./test/browserifyGulpTestError.js')
|
||||
.pipe(plugins.gulpBrowser.browserify())
|
||||
.pipe(plugins.gulp.dest("./test/result/"))
|
||||
.pipe(plugins.gulpCallFunction(pipeWorked));
|
||||
return stream;
|
||||
});
|
||||
plugins.gulp.task("default", ['gulpBrowserTest', 'gulpBrowserTestError'], function () {
|
||||
plugins.beautylog.success("Test passed!");
|
||||
});
|
||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
2
test/test.d.ts
vendored
Normal file
2
test/test.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import "typings-test";
|
||||
import "should";
|
56
test/test.js
Normal file
56
test/test.js
Normal file
File diff suppressed because one or more lines are too long
1
test/test.js.map
Normal file
1
test/test.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,OAAO,GAAG;IACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC,kBAAkB,CAAC;IACxC,YAAY,EAAE,OAAO,CAAC,eAAe,CAAC;CACzC,CAAC;AACF,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAG/B,QAAQ,CAAC,aAAa,EAAE;IACpB,QAAQ,CAAC,aAAa,EAAE;QACpB,EAAE,CAAC,6BAA6B,EAAE,UAAU,IAAI;YAC5C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,gCAAgC,CAAC;iBAC1D,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;iBACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;iBACzC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mDAAmD,EAAE,UAAU,IAAI;YAClE,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;YACnC,IAAI,UAAU,GAAG,KAAK,CAAA;YACtB,CAAC,CAAC,EAAE,CAAC,OAAO,EAAC,UAAS,KAAK;gBACvB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;gBAC1B,EAAE,CAAA,CAAC,CAAC,UAAU,CAAC,CAAA,CAAC;oBACZ,IAAI,EAAE,CAAC;oBACP,UAAU,GAAG,IAAI,CAAC;gBACtB,CAAC;YACL,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,GAAG,CAAC;gBACF,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,+BAA+B,CAAC;qBACzD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;YAChD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uCAAuC,EAAE,UAAU,IAAI;YACtD,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,+BAA+B,CAAC;iBACzD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;iBACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;iBACzC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
57
test/test.ts
Normal file
57
test/test.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import "typings-test"
|
||||
let plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
gulp: require("gulp"),
|
||||
gulpBrowser: require("../dist/index.js"),
|
||||
gulpFunction: require("gulp-function")
|
||||
};
|
||||
import "should";
|
||||
|
||||
|
||||
describe("gulpBrowser", function () {
|
||||
describe(".browserify", function () {
|
||||
it("should run through smoothly", function (done) {
|
||||
this.timeout(30000);
|
||||
let stream = plugins.gulp.src('./test/testBrowserifyNormal.js')
|
||||
.pipe(plugins.gulpBrowser.browserify())
|
||||
.pipe(plugins.gulp.dest("./test/result/"))
|
||||
.pipe(plugins.gulpFunction(done));
|
||||
});
|
||||
|
||||
it("should throw an error, when a module is not found", function (done) {
|
||||
let d = require('domain').create();
|
||||
let doneCalled = false
|
||||
d.on("error",function(error){
|
||||
console.log(error.message)
|
||||
if(!doneCalled){
|
||||
done();
|
||||
doneCalled = true;
|
||||
}
|
||||
});
|
||||
d.run(function() {
|
||||
let stream = plugins.gulp.src("./test/testBrowserifyError.js")
|
||||
.pipe(plugins.gulpBrowser.browserify());
|
||||
});
|
||||
});
|
||||
|
||||
it("should run through with an empty file", function (done) {
|
||||
let stream = plugins.gulp.src('./test/testBrowserifyEmpty.js')
|
||||
.pipe(plugins.gulpBrowser.browserify())
|
||||
.pipe(plugins.gulp.dest("./test/result/"))
|
||||
.pipe(plugins.gulpFunction(done));
|
||||
});
|
||||
it("should run through work with transforms", function (done) {
|
||||
this.timeout(30000);
|
||||
let transforms = [
|
||||
{
|
||||
transform: "babelify",
|
||||
options: {presets: ["es2015", "react"]}
|
||||
}
|
||||
];
|
||||
let stream = plugins.gulp.src('./test/testBrowserifyNormal.js')
|
||||
.pipe(plugins.gulpBrowser.browserify(transforms))
|
||||
.pipe(plugins.gulp.dest("./test/result/"))
|
||||
.pipe(plugins.gulpFunction(done));
|
||||
});
|
||||
});
|
||||
});
|
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 "typings-global";
|
||||
import plugins = require("./gulpbrowser.plugins");
|
||||
|
||||
|
||||
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 {
|
||||
plugins.beautylog.error("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 {
|
||||
plugins.beautylog.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.through.obj(forEach,atEnd); // this is the through object that gets returned by gulpBrowser.browserify();
|
||||
};
|
||||
|
||||
export = browserify;
|
5
ts/gulpbrowser.plugins.ts
Normal file
5
ts/gulpbrowser.plugins.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import "typings-global";
|
||||
export let beautylog = require("beautylog");
|
||||
export let through = require("through2");
|
||||
export let path = require("path");
|
||||
export let browserify = require("browserify");
|
18
ts/index.ts
18
ts/index.ts
@ -1,18 +1,4 @@
|
||||
/// <reference path="./typings/tsd.d.ts" />
|
||||
/// <reference path="./modulebrowserify.ts" />
|
||||
import "typings-global";
|
||||
|
||||
var plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
through: require("through2"),
|
||||
gutil: require("gulp-util"),
|
||||
path: require("path"),
|
||||
browserify: require("browserify")
|
||||
};
|
||||
export import browserify = require("./gulpbrowser.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)
|
||||
.bundle(bundleCallback)
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
33
ts/test.ts
33
ts/test.ts
@ -1,33 +0,0 @@
|
||||
/// <reference path="./typings/tsd.d.ts" />
|
||||
|
||||
var plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
gulp: require("gulp"),
|
||||
gulpBrowser: require("./index.js"),
|
||||
gulpCallFunction: require("gulp-callfunction")
|
||||
};
|
||||
|
||||
|
||||
var pipeWorked = function() {
|
||||
plugins.beautylog.info("Pipe didn't break! Ready for Primetime!");
|
||||
};
|
||||
|
||||
plugins.beautylog.log('Now trying to browserify a testfile...');
|
||||
plugins.gulp.task('gulpBrowserTest',function(cb) {
|
||||
var stream = plugins.gulp.src('./test/browserifyGulpTest.js')
|
||||
.pipe(plugins.gulpBrowser.browserify())
|
||||
.pipe(plugins.gulp.dest("./test/result/"))
|
||||
.pipe(plugins.gulpCallFunction(pipeWorked));
|
||||
return stream;
|
||||
});
|
||||
plugins.gulp.task('gulpBrowserTestError',function(cb) {
|
||||
var stream = plugins.gulp.src('./test/browserifyGulpTestError.js')
|
||||
.pipe(plugins.gulpBrowser.browserify())
|
||||
.pipe(plugins.gulp.dest("./test/result/"))
|
||||
.pipe(plugins.gulpCallFunction(pipeWorked));
|
||||
return stream;
|
||||
});
|
||||
plugins.gulp.task("default",['gulpBrowserTest','gulpBrowserTestError'],function(){
|
||||
plugins.beautylog.success("Test passed!");
|
||||
});
|
||||
plugins.gulp.start.apply(plugins.gulp, ['default']);
|
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"
|
||||
}
|
||||
}
|
||||
}
|
41
ts/typings/browserify/browserify.d.ts
vendored
41
ts/typings/browserify/browserify.d.ts
vendored
@ -1,41 +0,0 @@
|
||||
// Type definitions for Browserify
|
||||
// Project: http://browserify.org/
|
||||
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
interface BrowserifyObject extends NodeJS.EventEmitter {
|
||||
add(file:string, opts?:any): BrowserifyObject;
|
||||
require(file:string, opts?:{
|
||||
expose: string;
|
||||
}): BrowserifyObject;
|
||||
bundle(opts?:{
|
||||
insertGlobals?: boolean;
|
||||
detectGlobals?: boolean;
|
||||
debug?: boolean;
|
||||
standalone?: string;
|
||||
insertGlobalVars?: any;
|
||||
}, cb?:(err:any, src:any) => void): NodeJS.ReadableStream;
|
||||
|
||||
external(file:string, opts?:any): BrowserifyObject;
|
||||
ignore(file:string, opts?:any): BrowserifyObject;
|
||||
transform(tr:string, opts?:any): BrowserifyObject;
|
||||
transform(tr:Function, opts?:any): BrowserifyObject;
|
||||
plugin(plugin:string, opts?:any): BrowserifyObject;
|
||||
plugin(plugin:Function, opts?:any): BrowserifyObject;
|
||||
}
|
||||
|
||||
interface Browserify {
|
||||
(): BrowserifyObject;
|
||||
(files:string[]): BrowserifyObject;
|
||||
(opts:{
|
||||
entries?: string[];
|
||||
noParse?: string[];
|
||||
}): BrowserifyObject;
|
||||
}
|
||||
|
||||
declare module "browserify" {
|
||||
var browserify: Browserify;
|
||||
export = browserify;
|
||||
}
|
2092
ts/typings/node/node.d.ts
vendored
2092
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
2
ts/typings/tsd.d.ts
vendored
2
ts/typings/tsd.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
/// <reference path="node/node.d.ts" />
|
||||
/// <reference path="browserify/browserify.d.ts" />
|
Reference in New Issue
Block a user