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

Commit 6d32faf

Browse files
committed
Fix to get window correctly in iife.
1 parent 76af330 commit 6d32faf

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

Diff for: browser-entry.js

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import should from './es6/should';
2+
import root from 'root';
23

34
var defaultProto = Object.prototype;
45
var defaultProperty = 'should';
@@ -10,3 +11,17 @@ try {
1011
} catch (e) {
1112
//ignore errors
1213
}
14+
15+
if (typeof define === 'function' && define.amd) {
16+
define([], function() { return should });
17+
} else if (typeof module === 'object' && module.exports) {
18+
module.exports = should;
19+
} else {
20+
root.Should = should;
21+
22+
Object.defineProperty(root, 'should', {
23+
enumerable: false,
24+
configurable: true,
25+
value: should
26+
});
27+
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"eslint": "^2.4.0",
2424
"mocha": "latest",
2525
"mocha-better-spec-reporter": "latest",
26-
"rollup": "^0.26.3",
26+
"rollup": "^0.29.0",
2727
"rollup-plugin-node-resolve": "^1.5.0",
2828
"zuul": "latest"
2929
},

Diff for: rollup.config.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,19 @@ const banner = `/*!
1414
*/
1515
`;
1616

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-
3217
module.exports = {
3318
entry: 'browser-entry.js',
3419
banner,
35-
outro,
3620
format: 'iife',
3721
plugins: [
3822
nodeResolve({
3923
jsnext: true,
4024
main: true,
4125
preferBuiltins: false
4226
})
43-
]
27+
],
28+
external: ['root'],
29+
globals: {
30+
root: 'this'
31+
}
4432
};

0 commit comments

Comments
 (0)