Open talentlessguy opened 4 years ago
Hi. It prob won’t work.
@paulmillr hi, I made it work in other Node.js packages, here's one of them: https://github.com/talentlessguy/es-accepts
This is how it would look like:
// package.json
"main": "index.cjs",
"module": "index.js",
"types": "index.d.ts",
"type": "module",
"exports": {
".": {
"import": "./index.js",
"require": "./index.cjs"
},
"./package.json": "./package.json",
"./": "./"
},
I can submit a pull request with adding the required fields and an ESM file
What is index.cjs, how does it look like?
What is the benefit of switching to cjs ?
@paulmillr .cjs
is basically the same as .js
with require
, but when you use modules, Node.is will recommend to use .js
for ESM and .cjs
for CommonJS
Another way is using .mjs
for ESM and .js
for CommonJS, and it will still work
tldr; cjs
= js
w/ require
Here are some relevant articles that explain what @talentlessguy is talking about: packages determining module system hybrid npm packages package checks
@talentlessguy - Is this fixed or no longer needed, or some other solution?
installing / running @tinyhttp/static provides the error:
SyntaxError: Named export 'promise' not found. The requested module 'readdirp' is a CommonJS module, which may not support all module.exports as named exports.
I know its probably an error with @tinyhttp/static not with this repo, but since the discussion for it seems to be here, thought i would continue this thread.
@calumk @tinyhttp/static
has been deleted from the repo... probably I should also add a deprecation warning
use sirv
instead
Hello, thanks for making this module! I'm the author of tinyhttp framework and it has
@tinyhttp/static
middleware which usesreaddirp
. As I noticed, it doesn't have a"module"
field.Is it a good idea to add this field to package.json so it will work? Or better not touch it?