Skip to content

Conditionally import 'window' package when globalThis is missing #4

@davejsdev

Description

@davejsdev

Proposal

Summary

The window package adds unnecessary weight in browser contexts. We can conditionally import this based on if it's a node or browser env.

I'm not sure the best approach here that preserves the types of globalThis though. There are a few possible options. Right now, I'm considering having separate entry points depending on the env:

import { ... } from 'cssom-gen'; // default is the browser version

import { ... } from 'cssom-gen/node'; // sub-path for node imports

There's also conditional imports, but that's potentially messy supporting both CJS/ESM. I don't like it much.

Open to suggestions or PRs from anyone!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions