Skip to content

Commit

Permalink
fix(postcss): correct windows paths for webpack (#1999)
Browse files Browse the repository at this point in the history
* fix(postcss): correct windows paths for webpack

* chore: add changeset

* chore(postcss): improve tests for normalization

* refactor: normalize paths

---------

Co-authored-by: Segun Adebayo <[email protected]>
  • Loading branch information
mewdriller and segunadebayo authored Jan 15, 2024
1 parent fee015f commit ee9341d
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .changeset/tender-bottles-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@pandacss/postcss': patch
'@pandacss/node': patch
'@pandacss/types': patch
---

Fix issue in windows environments where HMR doesn't work in webpack projects.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@changesets/cli": "2.26.2",
"chokidar": "^3.5.3",
"concurrently": "^8.2.0",
"cross-env": "^7.0.3",
"happy-dom": "^12.1.6",
"husky": "8.0.3",
"lint-staged": "13.2.3",
Expand Down
9 changes: 3 additions & 6 deletions packages/node/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { optimizeCss } from '@pandacss/core'
import { ConfigNotFoundError } from '@pandacss/error'
import { logger } from '@pandacss/logger'
import { existsSync, statSync } from 'fs'
import { resolve } from 'pathe'
import { normalize, resolve } from 'pathe'
import type { Message, Root } from 'postcss'
import { codegen } from './codegen'
import { loadConfigAndCreateContext } from './config'
Expand Down Expand Up @@ -175,7 +175,6 @@ export class Builder {
write = (root: Root) => {
const ctx = this.getContextOrThrow()
const sheet = ctx.createSheet()
ctx.appendLayerParams(sheet)
ctx.appendBaselineCss(sheet)
const css = ctx.getCss(sheet)

Expand All @@ -193,13 +192,11 @@ export class Builder {

for (const fileOrGlob of ctx.config.include) {
const dependency = parseDependency(fileOrGlob)
if (dependency) {
fn(dependency)
}
if (dependency) fn(dependency)
}

for (const file of this.configDependencies) {
fn({ type: 'dependency', file: ctx.runtime.path.resolve(file) })
fn({ type: 'dependency', file: normalize(resolve(file)) })
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/node/src/parse-dependency.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isGlob from 'is-glob'
import { resolve } from 'pathe'
import { resolve, normalize } from 'pathe'
import type { Message } from 'postcss'
import { parseGlob } from './parse-glob'

Expand All @@ -12,13 +12,13 @@ export function parseDependency(fileOrGlob: string) {

if (isGlob(fileOrGlob)) {
const { base, glob } = parseGlob(fileOrGlob)
message = { type: 'dir-dependency', dir: resolve(base), glob }
message = { type: 'dir-dependency', dir: normalize(resolve(base)), glob }
} else {
message = { type: 'dependency', file: resolve(fileOrGlob) }
message = { type: 'dependency', file: normalize(resolve(fileOrGlob)) }
}

if (message.type === 'dir-dependency' && process.env.ROLLUP_WATCH === 'true') {
message = { type: 'dependency', file: resolve(message.dir) }
message = { type: 'dependency', file: normalize(resolve(message.dir)) }
}

return message
Expand Down
2 changes: 1 addition & 1 deletion packages/studio/styled-system/jsx/is-valid-prop.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"prepare": "ncp node_modules/csstype/index.d.ts src/csstype.d.ts",
"dev": "tsx scripts/watch.ts",
"build": "PANDA_BUILD=1 tsx scripts/postbuild.ts && tsx scripts/build.ts"
"build": "cross-env PANDA_BUILD=1 tsx scripts/postbuild.ts && tsx scripts/build.ts"
},
"sideEffects": false,
"homepage": "https://panda-css.com",
Expand Down
Loading

3 comments on commit ee9341d

@vercel
Copy link

@vercel vercel bot commented on ee9341d Jan 15, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

panda-docs – ./website

panda-css.com
panda-docs-git-main-chakra-ui.vercel.app
panda-docs-chakra-ui.vercel.app
panda-docs.vercel.app

@vercel
Copy link

@vercel vercel bot commented on ee9341d Jan 15, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

panda-studio – ./

panda-studio-chakra-ui.vercel.app
panda-app.vercel.app
panda-studio-git-main-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on ee9341d Jan 15, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.