Skip to content
This repository was archived by the owner on Nov 4, 2020. It is now read-only.

Commit 0b36b50

Browse files
committed
Use rollup for build
1 parent f9b3f75 commit 0b36b50

7 files changed

+72
-96
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ desktop.ini
55
should.js.for-tests
66
*.swp
77
npm-debug.log
8+
cjs/
9+
es6/

as-function.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./lib/should');
1+
module.exports = require('./cjs/should');

browser-entry.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
should = require('./index');
1+
import should from './es6/should';
2+
3+
var defaultProto = Object.prototype;
4+
var defaultProperty = 'should';
5+
6+
//Expose api via `Object#should`.
7+
try {
8+
var prevShould = should.extend(defaultProperty, defaultProto);
9+
should._prevShould = prevShould;
10+
} catch (e) {
11+
//ignore errors
12+
}

gulpfile.js

-78
This file was deleted.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var should = require('./lib/should');
1+
var should = require('./cjs/should');
22

33
var defaultProto = Object.prototype;
44
var defaultProperty = 'should';

package.json

+12-15
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,22 @@
99
},
1010
"homepage": "https://github.com/shouldjs/should.js",
1111
"scripts": {
12+
"cjs": "rollup --format=cjs --output=cjs/should.js lib/should.js",
13+
"es6": "rollup --format=es6 --output=es6/should.js lib/should.js",
14+
"build": "npm run cjs && npm run es6",
15+
"prepublish": "npm run build && npm run browser",
16+
"pretest": "npm run build",
1217
"test": "mocha -R mocha-better-spec-reporter --check-leaks ./test/*.test.js ./test/**/*.test.js",
1318
"zuul": "zuul -- ./test/**/*.test.js ./test/*.test.js",
14-
"browser": "gulp script"
19+
"browser": "rollup -c rollup.config.js --output ./should.js"
1520
},
1621
"devDependencies": {
1722
"bluebird": "^3.0.6",
18-
"browserify": "latest",
19-
"bundle-collapser": "^1.2.1",
2023
"eslint": "^2.4.0",
21-
"gulp": "^3.8.10",
22-
"gulp-derequire": "^2.1.0",
23-
"gulp-rename": "^1.2.0",
24-
"gulp-uglify": "^1.0.1",
25-
"gulp-wrapper": "^1.0.0",
26-
"lodash.template": "^4.2.4",
2724
"mocha": "latest",
2825
"mocha-better-spec-reporter": "latest",
29-
"vinyl-buffer": "^1.0.0",
30-
"vinyl-source-stream": "^1.1.0",
26+
"rollup": "^0.26.3",
27+
"rollup-plugin-node-resolve": "^1.5.0",
3128
"zuul": "latest"
3229
},
3330
"keywords": [
@@ -39,10 +36,10 @@
3936
"main": "./index.js",
4037
"license": "MIT",
4138
"dependencies": {
42-
"should-equal": "0.8.0",
43-
"should-format": "0.3.2",
44-
"should-type": "0.2.0"
45-
}
39+
"should-equal": "^1.0.0",
40+
"should-format": "^1.0.0",
41+
"should-type": "^1.0.0"
42+
},
4643
"files": [
4744
"cjs/*",
4845
"es6/*",

rollup.config.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*eslint-env node */
2+
'use strict';
3+
4+
const nodeResolve = require('rollup-plugin-node-resolve');
5+
6+
const pkg = require('./package.json');
7+
8+
const banner = `/*!
9+
* ${pkg.name} - ${pkg.description}
10+
* @version v${pkg.version}
11+
* @author ${pkg.author}
12+
* @link ${pkg.homepage}
13+
* @license ${pkg.license}
14+
*/
15+
`;
16+
17+
const outro = `
18+
if (typeof define === 'function' && define.amd) {
19+
define([], function() { return should });
20+
} else if (typeof module === 'object' && module.exports) {
21+
module.exports = should;
22+
} else {
23+
this.Should = should;
24+
25+
Object.defineProperty(this, 'should', {
26+
enumerable: false,
27+
configurable: true,
28+
value: should
29+
});
30+
}`;
31+
32+
module.exports = {
33+
entry: 'browser-entry.js',
34+
banner,
35+
outro,
36+
format: 'iife',
37+
plugins: [
38+
nodeResolve({
39+
jsnext: true,
40+
main: true,
41+
preferBuiltins: false
42+
})
43+
]
44+
};

0 commit comments

Comments
 (0)