Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silent-laws-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

Fixed tailwind class changes not getting applied via HMR in filesystem routes.
49 changes: 1 addition & 48 deletions packages/start/src/config/fs-routes/tree-shake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type * as Babel from "@babel/core";
import type { NodePath, PluginObj, PluginPass } from "@babel/core";
import type { Binding } from "@babel/traverse";
import { basename } from "pathe";
import type { Plugin, ResolvedConfig, ViteDevServer } from "vite";
import type { Plugin } from "vite";

type State = Omit<PluginPass, "opts"> & {
opts: { pick: string[] };
Expand Down Expand Up @@ -280,10 +280,6 @@ function treeShakeTransform({ types: t }: typeof Babel): PluginObj<State> {
}

export function treeShake(): Plugin {
let config: ResolvedConfig;
const cache: Record<string, any> = {};
let server: ViteDevServer;

async function transform(id: string, code: string) {
const [path, queryString] = id.split("?");
const query = new URLSearchParams(queryString);
Expand All @@ -308,46 +304,6 @@ export function treeShake(): Plugin {
return {
name: "tree-shake",
enforce: "pre",
configResolved(resolvedConfig) {
config = resolvedConfig;
},
configureServer(s) {
server = s;
},
async handleHotUpdate(ctx) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's the story about why we needed this again

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's a What did the removed code do? section in the PR description 😅

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh right 🤪

if (cache[ctx.file]) {
const mods = [];
const newCode = await ctx.read();
for (const [id, code] of Object.entries(cache[ctx.file])) {
const transformed = await transform(id, newCode);
if (!transformed) continue;

const { code: transformedCode } = transformed;

if (transformedCode !== code) {
const mod = server.moduleGraph.getModuleById(id);
if (mod) mods.push(mod);
}

cache[ctx.file] ??= {};
cache[ctx.file][id] = transformedCode;
// server.moduleGraph.setModuleSource(id, code);
}

return mods;
}
// const mods = [];
// [...server.moduleGraph.urlToModuleMap.entries()].forEach(([url, m]) => {
// if (m.file === ctx.file && m.id.includes("pick=")) {
// if (!m.id.includes("pick=loader")) {
// mods.push(m);
// }
// }
// });
// return mods;
// // this.router.updateRoute(ctx.path);
// }
},
async transform(code, id) {
const [path, queryString] = id.split("?");
if (!path) return;
Expand All @@ -358,9 +314,6 @@ export function treeShake(): Plugin {
const transformed = await transform(id, code);
if (!transformed?.code) return;

cache[path] ??= {};
cache[path][id] = transformed.code;

return {
code: transformed.code,
map: transformed.map,
Expand Down
Loading