Skip to content

Conversation

@gingerbenw
Copy link
Member

@gingerbenw gingerbenw commented Feb 4, 2025

Add es modules and appropriate exports so package can be used in project which require esm syntax.

Uses rollup v2 to maintain node12 support, but could also separate out the build and test step to use a newer version

@gingerbenw gingerbenw requested a review from djskinner February 4, 2025 09:19
@djskinner
Copy link

hmm, even though its not that much code but still doesn't seem ideal to maintain two copies of the source code that need to be manually synced. Can't we write the source code once and transpile accordingly with rollup as we are doing with the other packages?

@gingerbenw
Copy link
Member Author

gingerbenw commented Feb 4, 2025

@djskinner yes we can! refactored.

Comment on lines +16 to +19
"./lib/fingerprint": {
"browser": "./lib/fingerprint.browser.js",
"node": "./lib/fingerprint.js"
}

Choose a reason for hiding this comment

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

is this export being used by other packages?

Copy link
Member Author

Choose a reason for hiding this comment

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

I doubt it to be honest, but I was leaving it in for the sake of backwards compatibility

"license": "MIT",
"devDependencies": {
"browserify": "17.0.0",
"@rollup/plugin-alias": "^5.1.1",

Choose a reason for hiding this comment

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

is this dependency being used?

Copy link
Member Author

Choose a reason for hiding this comment

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

this handles the #fingerprint import flipping between node and browser versions

index.js Outdated
discreteValues << 0)
.toString(base), blockSize);
}
export { fingerprint, isCuid };

Choose a reason for hiding this comment

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

is rollup not complaining about mixing default and named exports for the cjs output? I thought it would. Just wondering if we should do this for the esm output only because this isn't well defined for cjs:

const cuid = require('@bugsnag/cuid')

const { isCuid } = cuid

Which isCuid is this referring to, the one on export default cuid, or the one from export { isCuid }?

@gingerbenw gingerbenw merged commit f8bbf9a into master Feb 18, 2025
6 checks passed
@gingerbenw gingerbenw deleted the PLAT-13269/modulify branch February 18, 2025 11:29
@gingerbenw gingerbenw mentioned this pull request Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants