Open na2hiro opened 2 years ago
@na2hiro
Looks like Remix looks for a require
prop on exports
. I think if you use that, you'll get rid of this problem.
Microbundle has this example in its README:
{
"name": "foo", // your package name
"type": "module",
"source": "src/foo.js", // your source code
"exports": {
"require": "./dist/foo.cjs", // used for require() in Node 12+
"default": "./dist/foo.modern.js" // where to generate the modern bundle (see below)
},
"main": "./dist/foo.cjs", // where to generate the CommonJS bundle
"module": "./dist/foo.module.js", // where to generate the ESM bundle
"unpkg": "./dist/foo.umd.js", // where to generate the UMD bundle (also aliased as "umd:main")
"scripts": {
"build": "microbundle", // compiles "source" to "main"/"module"/"unpkg"
"dev": "microbundle watch" // re-build when source files change
}
}
I think I set up the build with microbundle so the npm module is universal, namely as ESM, CJS and UMD. However, it still needs some config in Remix usage: https://github.com/na2hiro/namespaced-fieldset/issues/4. This suggests our module is recognized only as ESM module.
Is there some better setup for the package so it works universally?