Skip to content

Commit

Permalink
Remove VFS code
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed May 13, 2024
1 parent 4fa7604 commit 19a0366
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
4 changes: 2 additions & 2 deletions import_map.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"imports": {
"deco-sites/std/": "./",
"deco/": "https://denopkg.com/deco-cx/deco@1.62.2/",
"deco/": "https://denopkg.com/deco-cx/deco@1.66.0/",
"partytown/": "https://deno.land/x/[email protected]/",
"$fresh/": "https://deno.land/x/[email protected]/",
"preact": "https://esm.sh/[email protected]",
Expand All @@ -11,4 +11,4 @@
"@preact/signals-core": "https://esm.sh/@preact/[email protected]",
"std/": "https://deno.land/[email protected]/"
}
}
}
40 changes: 14 additions & 26 deletions plugins/tailwind/mod.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Plugin } from "$fresh/server.ts";
import { resolveDeps } from "./deno.ts";
import { Context } from "deco/deco.ts";
import { VFS } from "deco/runtime/fs/mod.ts";
import { walk } from "std/fs/walk.ts";
import { join, toFileUrl } from "std/path/mod.ts";
import { bundle, Config, loadTailwindConfig } from "./bundler.ts";
import { resolveDeps } from "./deno.ts";
export type { Config } from "./bundler.ts";

const root: string = Deno.cwd();
Expand Down Expand Up @@ -102,35 +101,24 @@ export const plugin = (config?: Config): Plugin => {
const ctx = Context.active();

const withReleaseContent = async (config: Config) => {
const ctx = Context.active();
const allTsxFiles = new Map<string, string>();

const vfs = ctx.fs;
if (!vfs || !(vfs instanceof VFS)) {
// init search graph with local FS
const roots = new Set<string>();

for await (
const entry of walk(Deno.cwd(), {
includeDirs: false,
includeFiles: true,
})
) {
if (entry.path.endsWith(".tsx") || entry.path.includes("/apps/")) {
roots.add(toFileUrl(entry.path).href);
}
}

await resolveDeps([...roots.values()], allTsxFiles);
} else {
// init search graph with virtual FS
for (const [path, file] of Object.entries(vfs.fileSystem)) {
if (path.endsWith(".tsx") && file.content) {
allTsxFiles.set(path, file.content);
}
// init search graph with local FS
const roots = new Set<string>();

for await (
const entry of walk(Deno.cwd(), {
includeDirs: false,
includeFiles: true,
})
) {
if (entry.path.endsWith(".tsx") || entry.path.includes("/apps/")) {
roots.add(toFileUrl(entry.path).href);
}
}

await resolveDeps([...roots.values()], allTsxFiles);

return {
...config,
content: [...allTsxFiles.values()].map((content) => ({
Expand Down

0 comments on commit 19a0366

Please sign in to comment.