Skip to content

Commit

Permalink
fix(unplugin): use peerDependencies & fix config change HMR
Browse files Browse the repository at this point in the history
  • Loading branch information
astahmer committed Mar 22, 2024
1 parent e4d1dbf commit de44963
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-walls-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandabox/unplugin': patch
---

fix(unplugin): use peerDependencies & fix config change HMR
14 changes: 6 additions & 8 deletions packages/unplugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@
},
"dependencies": {
"@pandabox/postcss-plugins": "workspace:^",
"@pandacss/config": "^0.33.0",
"@pandacss/core": "^0.33.0",
"@pandacss/extractor": "^0.33.0",
"@pandacss/node": "^0.33.0",
"@pandacss/shared": "^0.33.0",
"@rollup/pluginutils": "^5.1.0",
"magic-string": "^0.30.7",
"postcss": "^8.4.35",
Expand All @@ -92,9 +87,9 @@
"devDependencies": {
"@nuxt/kit": "^3.10.3",
"@nuxt/schema": "^3.10.3",
"@pandacss/preset-base": "^0.33.0",
"@pandacss/preset-panda": "^0.33.0",
"@pandacss/types": "^0.33.0",
"@pandacss/preset-base": "^0.36.0",
"@pandacss/preset-panda": "^0.36.0",
"@pandacss/types": "^0.36.0",
"@types/node": "^20.11.21",
"chalk": "^5.3.0",
"esno": "^4.0.0",
Expand All @@ -108,6 +103,9 @@
"webpack": "^5.90.3"
},
"peerDependencies": {
"@pandacss/config": ">=0.36.0",
"@pandacss/core": ">=0.36.0",
"@pandacss/node": ">=0.36.0",
"@nuxt/kit": "^3",
"@nuxt/schema": "^3",
"esbuild": "*",
Expand Down
16 changes: 8 additions & 8 deletions packages/unplugin/src/plugin/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,15 @@ export const unpluginFactory: UnpluginFactory<PandaPluginOptions | undefined> =
async configureServer(server) {
const ctx = await getCtx()

const sources = new Set([ctx.panda.conf.path, ...(ctx.panda.config.dependencies ?? [])])
const sources = new Set(
[ctx.panda.conf.path, ...(ctx.panda.conf.dependencies ?? []), ...(ctx.panda.config.dependencies ?? [])].map(
(f) => ensureAbsolute(f, ctx.root),
),
)
sources.forEach((file) => server.watcher.add(file))
server.watcher.on('change', async (filePath) => {

server.watcher.on('change', async (file) => {
const filePath = ensureAbsolute(file, ctx.root)
if (!sources.has(filePath)) return

await ctx.reloadContext()
Expand All @@ -136,12 +142,6 @@ export const unpluginFactory: UnpluginFactory<PandaPluginOptions | undefined> =
}
}

// Parse/Invalidate all files with new config
ctx.files.forEach((_content, file) => {
invalidate(file)
ctx.panda.project.parseSourceFile(file)
})

// Invalidate CSS
invalidate(outfile)
})
Expand Down
196 changes: 178 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de44963

Please sign in to comment.