-
Notifications
You must be signed in to change notification settings - Fork 4
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
Expose an ESM exclusive binary #6
Conversation
dvnrsn
commented
Nov 15, 2023
- create bin.[cjs, mjs]
- duplicate tests for mjs
- duplicate *.cjs files used in binode testing examples
- create bin.[cjs, mjs] - duplicate tests for mjs - duplicate *.cjs files used in binode testing examples
}); | ||
const modPkgDir = path.dirname(modPkgPath); | ||
|
||
fs.readFile(modPkgPath, 'utf8') |
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.
This is the main change. Not as easy as a "require" to read JSON in ESM.
@@ -0,0 +1,119 @@ | |||
import { spawnSync } from 'child_process'; | |||
import path from 'path'; | |||
import { fileURLToPath } from 'url'; |
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.
This test is virtually the same except it runs run-binode*-esm
in the package.json which in turn uses the binode-esm
binary
@@ -0,0 +1,3 @@ | |||
if (!global.globalSetup) { |
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.
Maybe overkill to duplicate these files but wanted to prove the full ESM format case
}, | ||
"keywords": [], | ||
"author": "Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)", | ||
"license": "MIT", | ||
"bin": { | ||
"binode": "bin.js" | ||
"binode": "bin.cjs", | ||
"binode-esm": "bin.mjs" |
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.
Could be clever to simply tease out which module system is being used and proceed from there. Seems like that could be doable I suppose by checking import.meta
or __dirname. Haven't investigated
Thanks for this. Can you help me understand why this is necessary? |
I wanted to use remix-utils. But remix-utils@7 prefers I authored this proposal under the impression that an ESM exclusive binary was necessary in a After noticing that for some reason However, as I noted in the same issue mentioned earlier, I believe using At this point I simply want to do whatever I can to get indie-stack to a better state for newcomers (like me). It might be best to pocket mock service worker as an option for down the road, for example. Or maybe people should be pointed to templates? |