Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose dist paths as root paths via package.json export field #3274

Merged
merged 3 commits into from
May 26, 2021

Conversation

pskelin
Copy link
Contributor

@pskelin pskelin commented May 19, 2021

Overview

Enable writing imports like
import "@ui5/webcomponents/Button.js"
instead of
import "@ui5/webcomponents/dist/Button.js"

The dist folder is a development artefact and is not relevant for application developers, so this becomes a more developer friendly way of consuming ui5 webcomponents.

This feature relies on the package.json exports field and should be considered only if it is supported. The original import paths with dist remain available and are the only official imports. Users of this features must take care that their build tool has the necessary support and that multiple copies of the same module do not end up in the final bundle in case they are referenced by both import paths and the build tool does not handle this correctly (checked to work correctly with rollup and webpack at this time)

if for example app developers write imports like

import "@ui5/webcomponents/Button.js"
import "@ui5/webcomponents/ToggleButton.js"

since ToggleButton internally imports
import "@ui5/webcomponents/dist/Button.js"

there should be just one copy of the Button module even if it is imported by both paths.

Remarks

Other files that are not actual modules but are used by tools via require.resolve to get the correct monorepo folder need to also be exposed in the exports field (examples are the .hbs files in src for template includes, the .port file used by the tests and the bundle files used by rollup)

resolves #3208
alternative considered in #3292

@pskelin pskelin changed the title expose dist paths as root paths via package.json export field feat: expose dist paths as root paths via package.json export field May 20, 2021
@pskelin pskelin merged commit bd34a5e into master May 26, 2021
@pskelin pskelin deleted the package-export-dist branch May 26, 2021 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "exports" to get rid of "dist" from import paths
2 participants