mirror of
https://github.com/developit/microbundle.git
synced 2026-01-18 13:56:35 +00:00
* Fix exports walk (#852) Fixes #852 * Create eight-toes-pump.md * traverse default exports in type:module packages
This commit is contained in:
parent
5d0465b39b
commit
5e93a0e4cc
5
.changeset/eight-toes-pump.md
Normal file
5
.changeset/eight-toes-pump.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"microbundle": patch
|
||||
---
|
||||
|
||||
Fix crash when traversing `"exports"` objects (#852)
|
||||
@ -260,9 +260,12 @@ function replaceName(filename, name) {
|
||||
);
|
||||
}
|
||||
|
||||
function walk(exports) {
|
||||
function walk(exports, includeDefault) {
|
||||
if (!exports) return null;
|
||||
if (typeof exports === 'string') return exports;
|
||||
return walk(exports['.'] || exports.import || exports.module);
|
||||
let p = exports['.'] || exports.import || exports.module;
|
||||
if (!p && includeDefault) p = exports.default;
|
||||
return walk(p, includeDefault);
|
||||
}
|
||||
|
||||
function getMain({ options, entry, format }) {
|
||||
@ -296,7 +299,7 @@ function getMain({ options, entry, format }) {
|
||||
mainNoExtension,
|
||||
);
|
||||
mainsByFormat.modern = replaceName(
|
||||
(pkg.exports && walk(pkg.exports)) ||
|
||||
(pkg.exports && walk(pkg.exports, pkg.type === 'module')) ||
|
||||
(pkg.syntax && pkg.syntax.esmodules) ||
|
||||
pkg.esmodule ||
|
||||
'x.modern.js',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user