Skip to content

local @import statement isn't stripped when placed after @source #922

@ntjess

Description

@ntjess

Reproduction link or steps

https://stackblitz.com/edit/github-on9qlarn?file=dist%2Fstyle.css

  1. Minimal package.json with @tsdown/css and tsdown installed
  2. empty index.ts
  3. style.css that imports from arbitrary content in ./theme.css:
@source "../index.ts";

@import "./theme.css";
  1. tsdown.config.ts that makes ./src/assets/style.css an entrypoint / exposed to the bundler

What is expected?

According to https://tsdown.dev/options/css,

All imported CSS is bundled into a single output file with @import statements removed.

Meaning there should be no @import ./theme.css present in the bundled style.css.

What is actually happening?

The local import is still present, meaning the browser raises errors when actually importing the stylesheet:

/* contents of dist/style.css */
@source "../index.ts";

@import './theme.css';

Any additional comments?

If we swap the statement order (e.g., place @import before @source), everything works as expected and the import statement is not present in the output.

Metadata

Metadata

Assignees

No one assigned

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions