Skip to content

Add support for sideEffects hint in resolveId #2593

@lukastaegert

Description

@lukastaegert

Feature Use Case

Taken from #2415 (comment)
Many packages include hints in their package.json files if executing the module without any imports does have any side-effects. Having this information could have a serious positive effect of bundle size while improving bundling performance. As rollup itself does not read package.json files, rollup would need to provide a way for plugins to provide that information.

Feature Proposal

My suggestion is to extend the resolveId hook to have the following form:

type ResolveIdReturnValue = string | false | null | undefined | {id: string | false, sideEffects boolean}
resolveId: (importee: string, importer: string) => ResolveIdReturnValue | Promise<ResolveIdReturnValue>

In case sideEffects: false is provided as additional information, rollup would not include any code from the module unless exports from this module are included. Not sure how easily this could be implemented internally.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions