Closed AlphaNecron closed 9 months ago
Using "type": "module"
in the root project will break TypeScript path mapping, so manually removing "type": "module"
in panda/package.json
is the last resort. However, this hack is transient and will be overwritten when doing panda codegen
again.
Hi @AlphaNecron,
You can solve this with the codegen:done
hook we expose, so it's always correct.
import { defineConfig } from '@pandacss/dev'
import { writeFileSync } from 'fs'
export default defineConfig({
// ...
emitPackage: true,
hooks: {
'codegen:done'() {
const pkgPath = './node_modules/styled-system/package.json'
const pkgJson = require(pkgPath)
delete pkgJson.type
writeFileSync(pkgPath, JSON.stringify(pkgJson, null, 2), 'utf-8')
},
},
})
Thanks! Didn't even know this does exist.
Description
LSP throws importing error with
emitPackage: true
inpanda.config.ts
and CommonJS project. However, removing"type": "module"
innode_modules/panda/package.json
, which is set by default by the generator, does the trick. Better marktype: module
as optional by adding a field in config when generating artifact package may address this issue.Link to Reproduction
none
Steps to reproduce
"type": "CommonJS"
to project'spackage.json
emitPackage
totrue
inpanda.config.ts
panda codegen
JS Framework
React TS
Panda CSS Version
0.29.1
Browser
No response
Operating System
Additional Information
TypeScript version:
5.3.3
Here's my
panda.config.ts
, trimmed redundant fields btw:My
tsconfig.json
as well: