Skip to content

Broken CSS Modules when code splitting enabled #18244

Closed
@gwer

Description

@gwer

What version of Bun is running?

1.2.5+013fdddc6

What platform is your computer?

Linux 6.11.10-300.fc41.x86_64 x86_64

What steps can reproduce the bug?

To reproduce the bug you need to build at least two entrypoints, imported CSS Modules and enabled code splitting.

styles.module.css:

.wrapper {
  display: block;
}

index.ts, index2.ts (they may have the same content):

import styles from './styles.module.css';

console.log(styles);

The build command:

bun build ./index.ts ./index2.ts --outdir ./out --splitting

What is the expected behavior?

Expected output is something like this:

// styles.module.css
var styles_module_default = {
  wrapper: "wrapper_-MSaAA"
};

// index.ts
console.log(styles_module_default);

What do you see instead?

Both entrypoints are build as follows:

// index.ts
console.log(styles_module_default);

The definition of styles_module_default is missing.

Additional information

If there is only one entrypoint or code splitting is disabled, everything works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbundlerSomething to do with the bundlercssCSS parser, bundler-related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions