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

Commit

Permalink
Fix to get window correctly in iife.
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Jun 9, 2016
1 parent 76af330 commit 6d32faf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
15 changes: 15 additions & 0 deletions browser-entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import should from './es6/should';
import root from 'root';

var defaultProto = Object.prototype;
var defaultProperty = 'should';
Expand All @@ -10,3 +11,17 @@ try {
} catch (e) {
//ignore errors
}

if (typeof define === 'function' && define.amd) {
define([], function() { return should });
} else if (typeof module === 'object' && module.exports) {
module.exports = should;
} else {
root.Should = should;

Object.defineProperty(root, 'should', {
enumerable: false,
configurable: true,
value: should
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"eslint": "^2.4.0",
"mocha": "latest",
"mocha-better-spec-reporter": "latest",
"rollup": "^0.26.3",
"rollup": "^0.29.0",
"rollup-plugin-node-resolve": "^1.5.0",
"zuul": "latest"
},
Expand Down
22 changes: 5 additions & 17 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,19 @@ const banner = `/*!
*/
`;

const outro = `
if (typeof define === 'function' && define.amd) {
define([], function() { return should });
} else if (typeof module === 'object' && module.exports) {
module.exports = should;
} else {
this.Should = should;
Object.defineProperty(this, 'should', {
enumerable: false,
configurable: true,
value: should
});
}`;

module.exports = {
entry: 'browser-entry.js',
banner,
outro,
format: 'iife',
plugins: [
nodeResolve({
jsnext: true,
main: true,
preferBuiltins: false
})
]
],
external: ['root'],
globals: {
root: 'this'
}
};

0 comments on commit 6d32faf

Please sign in to comment.