-
Notifications
You must be signed in to change notification settings - Fork 0
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
Switch to the Node 12 experimental module system #12
Conversation
Another approach is not to provide a umd build at all, and ask users to rely solely on |
@@ -2,15 +2,16 @@ | |||
"name": "monastic", | |||
"version": "1.0.1", | |||
"description": "A functional approach to stateful computations", | |||
"main": "index", | |||
"type": "commonjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should lint-package-json
assert that "type"
is specified?
Now that |
Motivation
Node 12 has introduced breaking changes to the way that the experimental module system works. Users of experimental modules will expect packages to follow this new system going forward.
Changes
index
toindex.mjs
: Node 12 no longer switches transparently between the most appropriateindex
file. Every package must provide an explicit path to its entry-point.umd.js
: User have to deep-require this file now, as the package entry point is a.mjs
file. I think using a specific name like this is clearer than usingindex.js
.commonjs
: This is a way for Node 12 to understand what the type is of files that don't express the type in their extension. We use commonjs so that our.js
files are treated as such, so that we keep backwards compatibility on those files with older versions of Node.require('*.mjs')
calls. Since this is how, deep down, the file was being loaded by Rollup, we get an error in Node 12.Tests
The tests in this module run through Mocha and nyc. Since Mocha and/or nyc use
require
to load the files, and Node 12 forbidsrequire('*.mjs')
now, the tests don't run in Node 12. I left this problem for another time. In Fluture, I switched to an approach where I run the tests natively using c8 and oletus.