Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump styled-jsx and remove manual types creation #39506

Merged
merged 1 commit into from Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/package.json
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
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.