-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Not exactly a bug, but I would strongly suggest to provide modern package.json export fields alongside the "legacy" fields like main
and types
.
I see the two issues here currently:
- legacy fields allow you to import from deep paths, which likely was never intended as a "public API" of the package. This for example is technically working, but likely not intended as it exposes the whole internal
lib
file structure, so any change there would be a breaking one for users of these kind of imports:
import type { ModuleFederationOptions } from '@module-federation/vite/lib/utils/normalizeModuleFederationOptions';
- The package is defined as
type: 'module'
, but the ESM build (lib/index.esm.js
) is not even referenced in the package.json, thus not being used anywhere AFAICT. Insteadmain
points to the CJS build (lib/index.cjs
), which defies the purpose oftype: 'module'
. Or do I miss something?
I would suggest to use explicit export fields, pointing to CJS, ESM and d.ts outputs, but denying any imports other than from the index modules.
Side node: as visible in the example above, we had a need to import ModuleFederationOptions
type, but with the proposed changes we wouldn't be able to import than from the deep path, so re-exporting this from index would be helpful also!
Happy to provide a PR if you agree on these changes!
Version
6.2.7
Reproduction
n/a
Relevant log output
Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working