Skip to content

Add a compile hint for unsupported stylesheet imports - #5

Open
MohammedAlkindi wants to merge 1 commit into
mcp-use:mainfrom
MohammedAlkindi:fix/actionable-error-for-css-import
Open

MohammedAlkindi wants to merge 1 commit into
mcp-use:mainfrom
MohammedAlkindi:fix/actionable-error-for-css-import

Conversation

@MohammedAlkindi

Copy link
Copy Markdown

.css is in SUPPORTED_FILE_EXTENSIONS and getLoader has a dedicated case ".css", but the build() call sets write: false with no outdir or outfile. esbuild cannot emit CSS without an output path, so any stylesheet import fails the whole build.

The model receives Cannot import "user-file:/src/styles.css" into a JavaScript file without an output path configured, which names a build option it cannot see and gives it nothing to act on. This adds a hint branch alongside the existing ones, pointing at inline style objects.

I did not change whether CSS is supported, since that is your call. Worth knowing if you take it up: adding outdir does make it build, but compileProjectBundle reads outputFiles[0] only, so the emitted CSS is dropped and the styles silently never apply. That trades a loud failure for a quiet one.

Evidence is a standalone esbuild reproduction against these exact build options: TSX alone compiles, a .png dataurl import compiles, .css fails. There is no test suite here, so no automated fail-before.

Disclosure: AI-assisted. I ran that reproduction myself, confirmed the new predicate matches the real error text, and tsc --noEmit is clean.

The bundler runs with write disabled and no output path, so esbuild
refuses any CSS import and fails the whole build. The message names an
internal build option rather than anything in the generated project, so
the model has nothing to act on and tends to retry the same import.

Add a hint pointing at inline style objects, alongside the existing
compile hints. This does not change whether stylesheets are supported.
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.

1 participant