Closed xaviergonz closed 2 years ago
Ah, yeah will need the default
key in there.
exports
was ignored before v0.13.2
Getting the same error with the following config: https://github.com/edit-distance/myers-1986/blob/351a970520f5c1724cc1fdf24d62086ad849f256/package.json#L30-L44
Any update from this issue? I can't use the microbundle package because this issue.
When using a microbundled package, I get this:
Error [ERR_INVALID_PACKAGE_CONFIG]: Invalid package config .../node_modules/x/package.json. "exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.
@whitelizard That indicates a misconfigured package, not an issue with Microbundle. Microbundle doesn't generate any export keys for you, so the user needs to write them properly.
Can you share the package?
Can you share the package?
Sure, it's this one in this case: https://www.npmjs.com/package/ploson-rule-engine It's not an open repo yet, but npm install it to see its package.json and the built files.
I haven't stripped down the problem, but I think one will get this error when doing import { createRuleEngine } from 'ploson-rule-engine';
@whitelizard https://www.runpkg.com/?ploson-rule-engine@1.3.2/package.json
Yes, that's invalid and doesn't follow the spec. See: https://nodejs.org/api/packages.html#packages_exports
"."
is used as a key when you have multiple subpath exports, i.e., "."
-> import ... from 'pkg'
, "./foo"
-> ... from 'pkg/foo'
, "./bar"
-> ... from 'pkg/bar'
, etc.
In the absence of multiple subpaths, "."
has no purpose. Change your package to the following:
"exports": {
"browser": "./dist/ploson-rule-engine.module.js",
"umd": "./dist/ploson-rule-engine.umd.js",
"import": "./dist/ploson-rule-engine.mjs",
"require": "./dist/ploson-rule-engine.js"
"default": "./dist/ploson-rule-engine.module.js"
},
Or whatever keys you want. Point is, you can't define subpaths and conditional exports on the same level, like that warning says. If you're using subpaths, all conditional exports need to be children of subpath keys. See Preact's package.json for a sizable example of this.
In the absence of multiple subpaths,
"."
has no purpose. Change your package to the following:
@rschristian Do you mean that in my situation:
Getting the same error with the following config: https://github.com/edit-distance/myers-1986/blob/351a970520f5c1724cc1fdf24d62086ad849f256/package.json#L30-L44 https://github.com/developit/microbundle/issues/852#issuecomment-865259708
the exports key of package.json
:
"."
key's items@make-github-pseudonymous-again What I mean is that it does nothing for you.
"exports": {
".": {
"browser": "./dist/index.module.js",
"umd": "./dist/index.umd.js",
"require": "./dist/index.cjs",
"default": "./dist/index.modern.js"
}
},
should be equivalent to
"exports": {
"browser": "./dist/index.module.js",
"umd": "./dist/index.umd.js",
"require": "./dist/index.cjs",
"default": "./dist/index.modern.js"
},
Changing this would not solve this issue for you at the moment though, as we expect "import"
or "module"
keys to exist, see:
Changing this would not solve this issue for you at the moment though, as we expect
"import"
or"module"
keys to exist, see:
In the midterm future I will try to add one or both of these keys to see if it fixes the problem.
In the midterm future I will try to add one or both of these keys to see if it fixes the problem
It definitely would, see the code block I referenced, but there's certainly very valid reasons to not have either of those keys, which was an oversight on my part when writing that. If you can get away with adding one, great! If not, downgrading (for now) might be better.
It definitely would, see the code block I referenced, but there's certainly very valid reasons to not have either of those keys, which was an oversight on my part when writing that. If you can get away with adding one, great! If not, downgrading (for now) might be better.
Yep. Currently running microbundle@0.13.1
. I'll reevaluate my position later.
I ran into this yesterday, and I believe another solution is to add an explicit import
key rather than relying on default
:
{
"exports": {
".": {
"browser": "./dist/index.module.js",
"umd": "./dist/index.umd.js",
"require": "./dist/index.cjs",
"import": "./dist/index.modern.js", // microbundle will use this instead of failing
"default": "./dist/index.modern.js"
}
}
}
Given the following exports in package.json
fails with:
Apparently it is first walking inside the ".", then inside "import" and then it fails because "import" is an object without ".", "import" or "module"
It used to work in 0.13.1 but started failing in 0.13.2 and 0.13.3