Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and export ES module along side umd bundle #151

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add rollup config and script to create umd bundle
blikblum committed Jun 28, 2021
commit 2bb74575167f07d9b7873f5b4de1ca3172762f2d
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@
"test": "mocha",
"test-travis": "npm install && npm install chai@$CHAI_VERSION && npm install sinon@$SINON_VERSION && npm test",
"lint": "eslint .",
"cover": "nyc --reporter=html mocha && opener ./coverage/sinon-chai.js.html"
"cover": "nyc --reporter=html mocha && opener ./coverage/sinon-chai.js.html",
"prepublishOnly": "rollup -c"
},
"peerDependencies": {
"chai": "^4.0.0",
22 changes: 22 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function globalRegister () {
return {
name: 'sinon-chai-global-register',
generateBundle(options, bundle, isWrite) {
const chunk = bundle['sinon-chai.js']
chunk.code = chunk.code.replace(/\(global.*global.sinonChai\s*=\s*factory\(\)\)/, 'chai.use(factory())')
}

};
}


export default {
input: 'lib/sinon-chai.mjs',
plugins: [globalRegister()],
output: {
file: 'lib/sinon-chai.js',
format: 'umd',
name: 'sinonChai',
esModule: false
}
};