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

support non-JavaScript file formats for import maps #1310

Open
thescientist13 opened this issue Nov 12, 2024 · 0 comments
Open

support non-JavaScript file formats for import maps #1310

thescientist13 opened this issue Nov 12, 2024 · 0 comments
Assignees
Labels
CLI feature New feature or request
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Nov 12, 2024

Type of Change

Feature

Summary

Per discussions in #1301 (comment), it was reported that trying to use bare specifiers for CSS Module Scripts was not working and giving an error in the console

import SpectrumCard from "@spectrum-css/card" with { type: "css" };

Screenshot 2024-11-11 at 9 05 56 PM

Details

After digging in a little bit, the reason is now pretty obvious. When building up the import map, we specifically only look for JavaScript files from node_modules to add to the import map
https://github.com/ProjectEvergreen/greenwood/blob/master/packages/cli/src/lib/walker-package-ranger.js#L122

The solution here is to be more accommodating to non-JavaScript files like CSS and JSON in particular, now that we have added support Import Attributes


In the meantime, "deep linking" to the file works

import SpectrumCard from "../path/to/node_modules/@spectrum-css/card/dist/index.css" with { type: "css" };
@thescientist13 thescientist13 added CLI feature New feature or request labels Nov 12, 2024
@thescientist13 thescientist13 added this to the 1.0 milestone Nov 12, 2024
@thescientist13 thescientist13 changed the title enable non-JavaScript file formats for import maps support non-JavaScript file formats for import maps Nov 12, 2024
@thescientist13 thescientist13 pinned this issue Nov 13, 2024
@thescientist13 thescientist13 self-assigned this Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI feature New feature or request
Projects
Development

No branches or pull requests

1 participant