You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(pkg-wrapper): fall back to package root entry when subpath resolves to an unlexable bundle
After 60d02d4 taught pickEntry() to follow subpath specifiers into the
exports map, packages like vue map 'vue/dist/vue.runtime.esm-browser.prod.js'
to a single-line minified file that es-module-lexer rejects with a parse
error. inspectPkg then degraded to default-only re-export and downstream
'import { version } from vue' crashed shared-modules's postBuild.
The fix retries with the package's bare specifier (root entry) when the
first lex attempt throws. The root entry is the lean ESM build whose
named-export surface is a superset of (or identical to) the deep subpath's,
so the federation wrapper still emits a complete static names list. The
bundler ultimately resolves to the deep subpath via the host's import map,
so the wrapper only needs to satisfy the lexer.
Adds a synthetic 'minified-subpath-pkg' fixture with an intentionally
unterminated-template dist/* target that exercises the fallback path; the
test asserts no warning is logged when the retry succeeds.
| Specifier-level `uses` map duplicates facts that already exist (source imports declare needs; `dependencies` declares ranges) | Maintainer |**Adopted**: `uses` reduced to a module-name array referencing the mount table; the external-dependency graph is generated by lookup (lexed specifiers × used modules' supply), never hand-declared (§4.1, §7) |
451
+
| Overlapping supply in layered base chains (base and vue-base both provide vue) is the normal case, not an error — merge semantics needed | Maintainer |**Adopted**: `E_MULTIPLE_PROVIDERS` replaced by deterministic election (own > nearer > later array entry) with whole-closure rewiring and per-layer version validation — MF's runtime share-scope negotiation solved statically at link time (§4.1, §7) |
// Deep-subpath specifiers like `pkg:vue/dist/vue.runtime.esm-browser.prod.js`
416
+
// can resolve to minified single-line bundles that es-module-lexer
417
+
// can't parse. The package's root entry typically declares the same
418
+
// (or a superset of) named API surface, so retry there — the
419
+
// federation wrapper just needs a static names list that the bundler
420
+
// also sees, and the bundler resolves the actual deep subpath itself
421
+
// via the import-map alias the host sets.
422
+
constbaseSpec=bareSpecOf(spec);
423
+
if(baseSpec&&baseSpec!==spec){
424
+
try{
425
+
returnlexFile(resolveFromRoot(root,baseSpec));
426
+
}catch{
427
+
// fall through to the original error reporting below
428
+
}
429
+
}
430
+
constmessage=
431
+
firstErrorinstanceofError
432
+
? firstError.message
433
+
: String(firstError);
414
434
console.warn(
415
435
`[esmx:pkg-wrapper] failed to enumerate named exports of "${spec}" (${message}); only its default export will be re-exported, so named imports of this federated package may fail at runtime.`
416
436
);
417
437
return{names: [],hasDefault: false};
418
438
}
419
439
}
420
440
441
+
/**
442
+
* Extract the bare package name from a deep specifier:
0 commit comments