Skip to content

Commit

Permalink
Bump styled-jsx and remove manual types creation (#39506)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Aug 11, 2022
1 parent d158c0c commit 7f54585
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
"string-hash": "1.1.3",
"string_decoder": "1.3.0",
"strip-ansi": "6.0.0",
"styled-jsx": "5.0.3",
"styled-jsx": "5.0.4",
"tar": "6.1.11",
"taskr": "1.1.0",
"terser": "5.14.1",
Expand Down
22 changes: 1 addition & 21 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,13 @@ export async function copy_styled_jsx_assets(task, opts) {
// Separate type files into different folders to avoid conflicts between
// dev dep `styled-jsx` and `next/dist/styled-jsx` for duplicated declare modules
const typesDir = join(outputDir, 'types')
let typeReferences = ''
let globalTypesContent = ''

await fs.ensureDir(outputDir)
await fs.ensureDir(typesDir)

for (const file of typeFiles) {
const fileNoExt = file.replace(/\.d\.ts/, '')
let content = await fs.readFile(join(styledJsxPath, file), 'utf8')

if (file === 'index.d.ts') {
const styledJsxIdx = content.indexOf(`declare module 'styled-jsx' {`)
globalTypesContent = content.substring(0, styledJsxIdx)
content = content
.substring(styledJsxIdx)
.replace('React.', `import('react').`)
}

const content = await fs.readFile(join(styledJsxPath, file), 'utf8')
await fs.writeFile(join(typesDir, file), content)
typeReferences += `/// <reference types="./${fileNoExt}" />\n`
}

await fs.writeFile(
join(typesDir, 'global.d.ts'),
`${typeReferences}\n${globalTypesContent}`
)

for (const file of jsFiles) {
const content = await fs.readFile(join(styledJsxPath, file), 'utf8')
const distFile = join(outputDir, file)
Expand Down
11 changes: 6 additions & 5 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 7f54585

Please sign in to comment.