Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No './300.css' exports subpath defined in https://ga.jspm.io/npm:@fontsource/[email protected]/ #2565

Open
schlichtanders opened this issue Mar 22, 2024 · 3 comments

Comments

@schlichtanders
Copy link

Hi there, first time I am trying to migrate to import maps using jspm, but it fails on my fontsource imports

$ jspm link frontend/index.html -o frontend/index.html
Error: No './300.css' exports subpath defined in https://ga.jspm.io/npm:@fontsource/[email protected]/ resolving @fontsource/comfortaa/300.css imported from file:///home/myhome/myproject/index.js., linking HTML file "./index.html"

The respective import is import "@fontsource/comfortaa/300.css"; and works totally well with npm and build with parcel.
What workaround exist to make this work with jspm?

@guybedford
Copy link
Member

The issue here is that importing CSS files is not a standard, unless you use the with { type: 'css' } attribute.

We could add non-standard support for CSS imports to be supported as injecting the CSS into the page, the problem is that it's not clear who is responsible for the injection - the package being imported, or the package doing the importing.

Strictly speaking, on the importer side, because there is no with { type: 'css' } we don't strictly know we are importing CSS, unless we rely on the file extension, but even then you could have an exports map mapping an arbitrary path ./x.css: ./x.js or even ./x: ./x.css so this doesn't seem reliable.

On the exporter side, this might make more sense as the place to put it, but that would mean that every .css file would be exposed as a JS file that injects the CSS for that file, which seems like it would be very costly to me in having a weird rewriting across packages.

My personal preference would be the standard CSS import.... if libraries would ever get on board with it.

@schlichtanders
Copy link
Author

can you give an example how to use with { type: 'css' } as a workaround? I am happy with adding this

@guybedford
Copy link
Member

JSPM does not currently support the with { type: 'css' } attribute. We will add support for it as soon as there are published packages that need it.

Yes, this is a circular argument, but that is also the nature of innovation under constraints.

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

No branches or pull requests

2 participants