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

Add ESM/CJS double-publishing #28

Merged
merged 8 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
6 changes: 6 additions & 0 deletions build.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
entries: ["./index.js"],
rollup: {
emitCJS: true,
},
};
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,29 @@
"type": "git",
"url": "git://github.com/brianloveswords/buffer-crc32.git"
},
"main": "index.js",
"scripts": {
"test": "tap tests/*.test.js --reporter classic"
"test": "tap tests/*.test.js --reporter classic",
"build": "unbuild",
"prepublishOnly": "npm run build"
},
"type": "commonjs",
Copy link
Collaborator Author

@kibertoad kibertoad Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed explicit type, because it can actually be either ESM or CommonJS, but we can't default it to ESM, because otherwise tests break, as older TAP does not support CJS format, and older Node versions don't support ESM

"dependencies": {},
"devDependencies": {
"tap": "~11.1.5"
"tap": "~11.1.5",
"unbuild": "^2.0.0"
},
"optionalDependencies": {},
"engines": {
"node": ">=8.0.0"
},
"license": "MIT",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"files": [
"index.js"
"dist"
]
}
2 changes: 1 addition & 1 deletion tests/crc.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const crc32 = require('..');
const crc32 = require('../index.js');
const test = require('tap').test;

test('simple crc32 is no problem', function (t) {
Expand Down
Loading