evanw / evanw/esbuild

How to use esbuild with css import assertions/attributes

Open
#3,384 29 comments 7 reactions 0 assignees View on GitHub
css
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I've code where some librarys import css without a assertion or a with attribute:

import aaSheet from "aa.css";

this works, but if I have this code:

import bbSheet from "bb.css" assert {type: 'css'};

or this:

import bbSheet from "bb.css" with {type: 'css'};

then the type of bbSheet hast to be a CSSStyleSheet, but esbuild does not create one.
And I don't know in the onResolveCallback if the "assert" or "with" attribute is present (the assert keyword was changed to with, but it should be nearly the same), so I don't know how I could create a plugin

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing esbuild's handling of JavaScript import assertions and import attributes, including the onResolveCallback behavior described in the issue. Determine the intended output for CSS imports with type: 'css', and consider how completion would be verified for both assert and with syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, go, javascript
Domain
build-system, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.