This repository has been archived by the owner on Nov 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update browser script to again emit UMD bundle
- Loading branch information
Showing
3 changed files
with
61 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
window.Should = require('./index'); | ||
|
||
Object.defineProperty(window, 'should', { | ||
enumerable: false, | ||
configurable: true, | ||
value: window.Should | ||
}); | ||
should = require('./index'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,78 @@ | ||
var gulp = require('gulp'); | ||
'use strict'; | ||
|
||
var header = require('gulp-header'); | ||
var uglify = require('gulp-uglify'); | ||
var rename = require('gulp-rename'); | ||
const gulp = require('gulp'); | ||
|
||
var source = require('vinyl-source-stream'); | ||
var buffer = require('vinyl-buffer'); | ||
const derequire = require('gulp-derequire'); | ||
const wrapper = require('gulp-wrapper'); | ||
const uglify = require('gulp-uglify'); | ||
const rename = require('gulp-rename'); | ||
|
||
var browserify = require('browserify'); | ||
const source = require('vinyl-source-stream'); | ||
const buffer = require('vinyl-buffer'); | ||
|
||
var pkg = require('./package.json'); | ||
const browserify = require('browserify'); | ||
const collapse = require('bundle-collapser'); | ||
|
||
var banner = [ | ||
'/*!', | ||
' * <%= pkg.name %> - <%= pkg.description %>', | ||
' * @version v<%= pkg.version %>', | ||
' * @author <%= pkg.author %>', | ||
' * @link <%= pkg.homepage %>', | ||
' * @license <%= pkg.license %>', | ||
' */', | ||
''].join('\n'); | ||
const pkg = require('./package.json'); | ||
|
||
gulp.task('script', function() { | ||
const template = require('lodash.template') | ||
|
||
const header = template(` | ||
/*! | ||
* <%= pkg.name %> - <%= pkg.description %> | ||
* @version v<%= pkg.version %> | ||
* @author <%= pkg.author %> | ||
* @link <%= pkg.homepage %> | ||
* @license <%= pkg.license %> | ||
*/ | ||
;(function (root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define([], factory); | ||
} else if (typeof module === 'object' && module.exports) { | ||
module.exports = factory(); | ||
} else { | ||
root.Should = factory(); | ||
Object.defineProperty(root, 'should', { | ||
enumerable: false, | ||
configurable: true, | ||
value: root.Should | ||
}); | ||
} | ||
}(this, function () { | ||
var should, require = null; | ||
`, { variable: 'pkg' })(pkg); | ||
|
||
var footer = ` | ||
return should; | ||
})); | ||
`; | ||
|
||
gulp.task('script', () => { | ||
var bundleStream = browserify({ | ||
entries: './browser-entry', | ||
builtins: null, | ||
insertGlobals: false, | ||
detectGlobals: false, | ||
fullPaths: false | ||
fullPaths: false, | ||
hasExports: false | ||
}) | ||
.plugin('bundle-collapser/plugin') | ||
.bundle(); | ||
|
||
return bundleStream | ||
.pipe(source('should.js')) | ||
.pipe(buffer()) | ||
.pipe(header(banner, {pkg: pkg})) | ||
.pipe(derequire()) | ||
.pipe(wrapper({ | ||
header, | ||
footer | ||
})) | ||
.pipe(gulp.dest('./')) | ||
.pipe(uglify({ preserveComments: 'some' })) | ||
.pipe(rename('should.min.js')) | ||
.pipe(gulp.dest('./')); | ||
}); | ||
|
||
gulp.task('default', ['script']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters