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

feat: Tailwind deps #234

Merged
merged 1 commit into from
May 1, 2024
Merged

feat: Tailwind deps #234

merged 1 commit into from
May 1, 2024

Conversation

tlgimenes
Copy link
Contributor

@tlgimenes tlgimenes commented May 1, 2024

This PR makes the TailwindCSS plugin be able to resolve libraries to include components into it's building process.

How does it work?

And advanced feature of tailwind is being able to receive the JSX file content directly, instead of only the file path. This allow us to pass any content we wish (not only those presents on the filesystem).

Using the aforementioned feature, I created a file resolver, where for all .tsx files present on the local project's filesystem, I parse the file into an AST, grab the import statements, and resolve these imports using the project's import map. Then, I do this process recursively up until all files on the import graph are visited. This is very similar to how we process the project's schema.

Finally, I create an array with all file contents and pass it to the tailwind engine.

The nice side effect is that this doesn't depend on any deco abstraction. This is a file-only abstraction

@tlgimenes tlgimenes merged commit ba608d4 into main May 1, 2024
2 checks passed
@tlgimenes tlgimenes deleted the feat/tailwind-deps branch May 1, 2024 14:44
const imports = new Set<string>();

visit(program, {
// Resovles static "import from" statements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Resovles static "import from" statements
// Resolves static "import from" statements

import { initLoader, parsePath } from "deco/engine/schema/parser.ts";
import { join, toFileUrl } from "std/path/mod.ts";

const visit = (program: any, visitor: Record<string, (node: any) => void>) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does worth to:

import type { ParsedSource } from "deco/engine/schema/deps.ts";

or at least

type ParsedSource = ReturnType<typeof parsePath>

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

Successfully merging this pull request may close these issues.

2 participants