Skip to content

Commit 6b941b7

Browse files
committed
fix: playground build
1 parent a20811c commit 6b941b7

File tree

7 files changed

+100
-51
lines changed

7 files changed

+100
-51
lines changed

playground/empty-module.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Empty module for webpack fallback
2+
module.exports = {}

playground/next.config.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

playground/next.config.mjs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import bundleAnalyzer from '@next/bundle-analyzer'
2+
import { createRequire } from 'node:module'
3+
4+
const isViz = process.env.ANALYZE === 'true'
5+
6+
const req = createRequire(import.meta.url)
7+
8+
const withBundleAnalyzer = bundleAnalyzer({
9+
enabled: isViz,
10+
})
11+
12+
/** @type {import('next').NextConfig} */
13+
const nextConfig = {
14+
webpack: (config, { isServer, webpack }) => {
15+
// aliases for resolving packages in the project
16+
config.resolve.alias = {
17+
...config.resolve.alias,
18+
'@vue/compiler-sfc': '@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js',
19+
lightningcss: 'lightningcss-wasm',
20+
}
21+
22+
if (!isServer) {
23+
// Use NormalModuleReplacementPlugin to handle node: scheme imports
24+
config.plugins.push(
25+
// Create empty module replacements for disabled modules
26+
new webpack.NormalModuleReplacementPlugin(/^node:fs\/promises$/, (resource) => {
27+
resource.request = req.resolve('./empty-module.js')
28+
}),
29+
new webpack.NormalModuleReplacementPlugin(/^node:fs$/, (resource) => {
30+
resource.request = req.resolve('./empty-module.js')
31+
}),
32+
new webpack.NormalModuleReplacementPlugin(/^node:os$/, req.resolve('os-browserify/browser')),
33+
new webpack.NormalModuleReplacementPlugin(/^node:path$/, req.resolve('path-browserify')),
34+
new webpack.NormalModuleReplacementPlugin(/^node:util$/, req.resolve('util')),
35+
new webpack.NormalModuleReplacementPlugin(/^node:crypto$/, (resource) => {
36+
resource.request = req.resolve('./empty-module.js')
37+
}),
38+
new webpack.NormalModuleReplacementPlugin(/^node:buffer$/, (resource) => {
39+
resource.request = req.resolve('./empty-module.js')
40+
}),
41+
new webpack.NormalModuleReplacementPlugin(/^node:stream$/, (resource) => {
42+
resource.request = req.resolve('./empty-module.js')
43+
}),
44+
new webpack.NormalModuleReplacementPlugin(/^node:url$/, (resource) => {
45+
resource.request = req.resolve('./empty-module.js')
46+
}),
47+
new webpack.NormalModuleReplacementPlugin(/^node:assert$/, (resource) => {
48+
resource.request = req.resolve('./empty-module.js')
49+
}),
50+
new webpack.NormalModuleReplacementPlugin(/^node:events$/, (resource) => {
51+
resource.request = req.resolve('./empty-module.js')
52+
}),
53+
new webpack.NormalModuleReplacementPlugin(/^node:process$/, req.resolve('process/browser')),
54+
)
55+
56+
config.resolve.fallback = {
57+
...config.resolve.fallback,
58+
// Node.js built-in modules - disable for browser
59+
perf_hooks: false,
60+
fs: false,
61+
// Legacy module names (keep existing)
62+
module: req.resolve('./module.shim.ts'),
63+
os: req.resolve('os-browserify/browser'),
64+
path: req.resolve('path-browserify'),
65+
util: req.resolve('util'),
66+
process: req.resolve('process/browser'),
67+
crypto: false,
68+
buffer: false,
69+
stream: false,
70+
url: false,
71+
assert: false,
72+
events: false,
73+
}
74+
}
75+
76+
config.module.rules.push({
77+
resourceQuery: /raw/,
78+
loader: 'raw-loader',
79+
})
80+
81+
return config
82+
},
83+
reactStrictMode: true,
84+
typescript: {
85+
ignoreBuildErrors: isViz,
86+
},
87+
}
88+
89+
export default withBundleAnalyzer(nextConfig)

playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"sucrase": "3.35.0",
4949
"ts-pattern": "5.8.0",
5050
"typescript": "5.8.3",
51-
"usehooks-ts": "3.1.1",
51+
"usehooks-ts": "2.14.0",
5252
"util": "0.12.5",
5353
"zod": "3.22.4"
5454
},

playground/src/dts/@pandacss_dev.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as _pandacss_types from '@pandacss/types';
12
import { Config, RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig, Parts, SystemStyleObject, PatternConfig, Preset, CssKeyframes, GlobalStyleObject, GlobalFontface, PropertyConfig, PandaPlugin, ThemeVariant, Tokens, SemanticTokens, CompositionStyles, TextStyles, LayerStyles } from '@pandacss/types';
23
export { CompositionStyles, Config, CssKeyframes, GlobalStyleObject, HooksApiInterface, LayerStyles, PatternConfig, PatternProperties, Preset, PropertyConfig, RecipeConfig, RecipeVariantRecord, SemanticTokens, SlotRecipeConfig, SlotRecipeVariantRecord, SystemStyleObject, TextStyles, Tokens } from '@pandacss/types';
34

playground/src/dts/@pandacss_types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export interface ArtifactContent {
281281
file: string;
282282
code: string | undefined;
283283
}
284-
export type ArtifactId = "helpers" | "keyframes" | "design-tokens" | "types" | "css-fn" | "cva" | "sva" | "cx" | "create-recipe" | "recipes" | "recipes-index" | "patterns" | "patterns-index" | "jsx-is-valid-prop" | "jsx-helpers" | "jsx-factory" | "jsx-patterns" | "jsx-patterns-index" | "css-index" | "themes" | "package.json" | "types-jsx" | "types-entry" | "types-styles" | "types-conditions" | "types-gen" | "types-gen-system" | `recipes.${string}` | `patterns.${string}`;
284+
export type ArtifactId = "helpers" | "keyframes" | "design-tokens" | "types" | "css-fn" | "cva" | "sva" | "cx" | "create-recipe" | "recipes" | "recipes-index" | "patterns" | "patterns-index" | "jsx-is-valid-prop" | "jsx-helpers" | "jsx-factory" | "jsx-patterns" | "jsx-create-style-context" | "jsx-patterns-index" | "css-index" | "themes" | "package.json" | "types-jsx" | "types-entry" | "types-styles" | "types-conditions" | "types-gen" | "types-gen-system" | `recipes.${string}` | `patterns.${string}`;
285285
export type CssArtifactType = "preflight" | "tokens" | "static" | "global" | "keyframes";
286286
export type Artifact = {
287287
id: ArtifactId;

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)