Skip to content

Commit

Permalink
refactor: update ts-morph to 24.0 to match TS 5.6.2 (#3036)
Browse files Browse the repository at this point in the history
* chore: update ts-morph to 24.0 to support TS 5.6.2

* chore: typecheck

* idk

* fix: types

* refactor: playground

* docs: fix

* chore: update

* docs: fix

* chore: weird

* revert: prev

* docs: fix build script

* docs: update

* docs: reword changelog

---------

Co-authored-by: Segun Adebayo <[email protected]>
  • Loading branch information
astahmer and segunadebayo authored Dec 31, 2024
1 parent e7636b3 commit d68ad1f
Show file tree
Hide file tree
Showing 37 changed files with 7,511 additions and 6,168 deletions.
12 changes: 12 additions & 0 deletions .changeset/twenty-badgers-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@pandacss/extractor': minor
'@pandacss/config': minor
'@pandacss/parser': minor
'@pandacss/types': minor
'@pandacss/node': minor
---

**[BREAKING]**: Fix issue where Next.js build might fail intermittently due to version mismatch between internal
`ts-morph` and userland `typescript`.

> The current version of TS supported is `5.6.2`
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"lint-staged": "15.2.11",
"mdx-local-link-checker": "2.1.1",
"rimraf": "5.0.10",
"ts-morph": "21.0.1",
"ts-morph": "24.0.0",
"tsup": "8.0.2",
"tsx": "4.7.1",
"typescript": "5.3.3",
"typescript": "5.6.2",
"vite-tsconfig-paths": "4.3.1",
"vitest": "1.5.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"escalade": "3.1.2",
"merge-anything": "5.1.7",
"microdiff": "1.3.2",
"typescript": "5.3.3"
"typescript": "5.6.2"
},
"devDependencies": {
"pkg-types": "1.0.3"
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/plugins/optimize-lightningcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default function optimizeLightCss(code: string | Root, options: OptimizeO

const codeStr = typeof code === 'string' ? code : code.toString()
const result = transform({
code: Buffer.from(codeStr),
// https://stackoverflow.com/questions/78790943/in-typescript-5-6-buffer-is-not-assignable-to-arraybufferview-or-uint8arr
code: Buffer.from(codeStr) as any as Uint8Array,
minify,
sourceMap: false,
filename: 'styles.css',
Expand Down
2 changes: 1 addition & 1 deletion packages/extractor/__tests__/extract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { default as ExtractSample } from './samples/ExtractSample?raw'

const project = createProject()

let sourceFile: SourceFile
let sourceFile: SourceFile | undefined
afterEach(() => {
if (!sourceFile) return

Expand Down
2 changes: 1 addition & 1 deletion packages/extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"dependencies": {
"@pandacss/shared": "workspace:*",
"ts-evaluator": "1.2.0",
"ts-morph": "21.0.1"
"ts-morph": "24.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"pluralize": "8.0.0",
"postcss": "8.4.49",
"prettier": "3.2.5",
"ts-morph": "21.0.1",
"ts-morph": "24.0.0",
"ts-pattern": "5.0.8",
"tsconfck": "3.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@pandacss/types": "workspace:*",
"@vue/compiler-sfc": "3.4.19",
"magic-string": "0.30.17",
"ts-morph": "21.0.1",
"ts-morph": "24.0.0",
"ts-pattern": "5.0.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/vue-to-tsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const NodeTypes = {
export const vueToTsx = (code: string) => {
try {
const parsed = parse(code)
const fileStr = new MagicString(`<template>${parsed.descriptor.template?.content}</template>` ?? '')
const fileStr = new MagicString(`<template>${parsed.descriptor.template?.content}</template>`)

const rewriteProp = (prop: BaseElementNode['props'][number]) => {
if (
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/src/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ export function traverse(obj: any, callback: CallbackFn, options: TraverseOption
const keys = Object.keys(currentItem.value)
for (let i = keys.length - 1; i >= 0; i--) {
const key = keys[i]
const value = currentItem.value[key]
const value = (currentItem.value as Record<string, unknown>)[key]

const path = currentItem.path ? currentItem.path + separator + key : key
const paths = currentItem.paths.concat(key)

stack.push({
value,
value: value as Record<string, unknown>,
path,
paths,
depth: currentItem.depth + 1,
parent: currentItem.value,
parent: currentItem.value as Record<string, unknown>,
key,
})
}
Expand Down
4 changes: 2 additions & 2 deletions packages/studio/styled-system/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
outline: auto;
}

[hidden] {
[hidden]:where(:not([hidden='until-found'])) {
display: none !important;
}
}
Expand Down Expand Up @@ -1421,4 +1421,4 @@
padding-inline: var(--spacing-8);
}
}
}
}
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"microdiff": "1.3.2",
"ncp": "2.0.0",
"pkg-types": "1.0.3",
"ts-morph": "21.0.1"
"ts-morph": "24.0.0"
}
}
3 changes: 2 additions & 1 deletion packages/types/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import fs from 'fs'
import path from 'path'

Expand All @@ -19,7 +20,7 @@ export const main = () => {
files.forEach((file) => {
const destFile = path.join('dist', file.endsWith('.d.ts') ? file : toDts(file))
getOrCreateDir('dist')
const content = fs.readFileSync(path.join('src', file))
const content = fs.readFileSync(path.join('src', file as string))
fs.writeFileSync(destFile, content)
})
}
Expand Down
25 changes: 0 additions & 25 deletions playground/fs.shim.ts

This file was deleted.

6 changes: 3 additions & 3 deletions playground/module.shim.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Empty implementation for Rollup alias
// eslint-disable-next-line @typescript-eslint/no-empty-function
export const createRequire = () => {};
export const createRequire = () => {
void 0
}
15 changes: 8 additions & 7 deletions playground/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path')
const isViz = process.env.ANALYZE === 'true'

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: isViz,
})
Expand All @@ -10,19 +10,20 @@ const nextConfig = {
// aliases for resolving packages in the project
config.resolve.alias = {
...config.resolve.alias,
process: 'process/browser',
os: 'os-browserify',
path: 'path-browserify',
util: 'util',
module: path.join(__dirname, './module.shim.ts'),
fs: path.join(__dirname, './fs.shim.ts'),
'@vue/compiler-sfc': '@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js',
lightningcss: 'lightningcss-wasm',
}

if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
perf_hooks: false,
fs: false,
module: require.resolve('./module.shim.ts'),
os: require.resolve('os-browserify/browser'),
path: require.resolve('path-browserify'),
util: require.resolve('util'),
process: require.resolve('process/browser'),
}
}

Expand Down
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"react-live-runner": "1.0.7",
"sucrase": "3.35.0",
"ts-pattern": "5.0.8",
"typescript": "5.3.3",
"typescript": "5.6.2",
"usehooks-ts": "2.14.0",
"util": "0.12.5",
"zod": "3.22.4"
Expand Down
Loading

0 comments on commit d68ad1f

Please sign in to comment.