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

build: don't mark CSS files as external #852

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Conversation

emersion
Copy link
Member

When a file marked as external is imported, it's not included in the JS library bundle: the JS import is left as-is. This is desirable for regular JS dependencies such as react and maplibre-gl, but is undesirable for non-standard imports such as CSS files.

Indeed, CSS imports from our JS library bundle cause pain for downstream users, because they are forced to configure their build system to support CSS imports (these aren't standard JS, e.g. webpack doesn't support this by default). Moreover, this makes it impossible to use the library without a build system (e.g. importing it directly from pure HTML/JS files).

Make users responsible for including the CSS one way or another. Our stories do this using CSS imports already, but other downstream consumers might prefer to use a <link> or similar.

To test, build the project and check whether the first line in ui-speedspacechart/dist/index.esm.js contains a CSS import. It should not.

Fixes: 6dd85a7 ("build: fix unresolved dependencies")
Supersedes #837

When a file marked as external is imported, it's not included in
the JS library bundle: the JS import is left as-is. This is desirable
for regular JS dependencies such as react and maplibre-gl, but is
undesirable for non-standard imports such as CSS files.

Indeed, CSS imports from our JS library bundle cause pain for
downstream users, because they are forced to configure their build
system to support CSS imports (these aren't standard JS, e.g. webpack
doesn't support this by default). Moreover, this makes it impossible
to use the library without a build system (e.g. importing it directly
from pure HTML/JS files).

Make users responsible for including the CSS one way or another. Our
stories do this using CSS imports already, but other downstream
consumers might prefer to use a <link> or similar.

Signed-off-by: Simon Ser <[email protected]>
Fixes: 6dd85a7 ("build: fix unresolved dependencies")
@emersion emersion requested review from Yohh and Math-R January 22, 2025 11:18
@emersion emersion requested a review from a team as a code owner January 22, 2025 11:18
Copy link
Contributor

@Math-R Math-R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@emersion emersion self-assigned this Jan 23, 2025
@emersion emersion added this pull request to the merge queue Jan 23, 2025
Merged via the queue into dev with commit e846a65 Jan 23, 2025
6 checks passed
@emersion emersion deleted the emr/no-external-css branch January 23, 2025 11:10
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.

3 participants