-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined when use cjs/mjs config #133
Comments
I've created minimal reproduce |
@azu Thanks, this should fix it #136 On a side note, I suggest not using cjs/mjs in parallel as you run the risk of the dual package hazard. https://nodejs.org/api/packages.html#dual-commonjses-module-packages I suggest one or the other, preferably cjs as packemon will automatically create an mjs wrapper. https://packemon.dev/docs/features#automatic-mjs-wrappers-for-cjs-inputs |
Published, let me know if there's still issues. |
Thanks!
2022年7月28日(木) 7:50 Miles Johnson ***@***.***>:
… Closed #133 <#133> as completed.
—
Reply to this email directly, view it on GitHub
<#133 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAE2AUWXYLQMVAE4NZL5X3VWG4KRANCNFSM53XBQKKQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
==================================
Name : azu
Mail : ***@***.***
==================================
|
I want to treat my package as mjs package by default( By contrast, index-wrapper.mjs force |
@azu How does the index-wrapper.mjs force it to CJS? |
@milesj Reproduce Steps:
Aug-01-2022.07-21-05_optimized.mp4 |
@azu The type is set based on the chosen format: https://github.com/milesj/packemon/blob/master/packages/packemon/src/Package.ts#L475 And since the format is It shouldn't matter though since the wrapper will be used when importing from ESM because the |
@file-cache has used packemon for packaging.
And, packemon config is following.
https://github.com/azu/file-cache/blob/26d5a23128bfcb5680c007fedc5607c737a87780/packages/core/package.json#L13-L29
I aim to publish dual package CJS/MJS.
I've published this package, but this package can not be required from CJS.
It means that
require("@file-cache/core")
throw an error.Expected
No Error on
require("@file-cache/core")
Actual
Can not
require("@file-cache/core")
.However,
import * from "@file-cache/core"
is work.Details
Published
@file-cache/core/package.json
is following:I've noticed that that Conditional exports does not define
require
field like"require": "./cjs/index.cjs"
.I mofify
node_modules/@file-cache/core/package.json
directory andrequire("@file-cache/core")
is work."types": "./dts/index.d.ts", "main": "./cjs/index.cjs", "exports": { "./package.json": "./package.json", "./*": { "types": "./dts/*.d.ts", "node": { "import": "./mjs/*.mjs" } }, ".": { "types": "./dts/index.d.ts", "node": { "import": "./mjs/index.mjs" + "require": "./cjs/index.cjs" } } }
packemon format the
exports
field automatically. So I can not addrequire
ordefault
property tonode
.Reproduce repository
Env
Note
The text was updated successfully, but these errors were encountered: