Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

CSS not loaded when using import() to load a React component #222

@peeke

Description

@peeke

I have a use case, where I want to separate a part of the codebase from the bundle. I can effectively do so by using

const VacatureMap = React.lazy(() => import('/components/vacature-map/VacatureMap'))

...

{mapboxSupported && <React.Suspense fallback={<Spinner />}>
  <VacatureMap />
</React.Suspense>}

This works, however the styles from VacatureMap.css are not appended to the document.

Possibly related to css-modules/css-modules#232

Some context: I'm having trouble compiling mapbox-gl with babel so it doesn't break IE11 (or some other older browsers). I have successfully compiled it with babel, but that takes the build in Jenkins from 3 to 17 mins, just to show a 'Not supported' notice. I'd rather import the included supported check, which works without compiling with babel, then only load the map when there's support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions