Skip to content

Commit

Permalink
Remove precopied styled-jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Aug 11, 2022
1 parent 4049cd7 commit f0a883c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/next/build/babel/preset.ts
Expand Up @@ -185,8 +185,8 @@ export default (
],
[
isTest && options['styled-jsx'] && options['styled-jsx']['babel-test']
? require('next/dist/styled-jsx/babel-test')
: require('next/dist/styled-jsx/babel'),
? require('styled-jsx/babel-test')
: require('styled-jsx/babel'),
styledJsxOptions(options['styled-jsx']),
],
require('./plugins/amp-attributes'),
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack-config.ts
Expand Up @@ -686,8 +686,8 @@ export default async function getBaseWebpackConfig(
'react-dom/server$': `${reactDomDir}/server`,
'react-dom/server.browser$': `${reactDomDir}/server.browser`,
'react-dom/client$': `${reactDomDir}/client`,
'styled-jsx/style$': require.resolve(`next/dist/styled-jsx/style`),
'styled-jsx$': require.resolve(`next/dist/styled-jsx`),
'styled-jsx/style$': require.resolve(`styled-jsx/style`),
'styled-jsx$': require.resolve(`styled-jsx`),

...customAppAliases,
...customErrorAlias,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack/require-hook.ts
Expand Up @@ -7,8 +7,8 @@ export default function loadRequireHook(aliases: [string, string][] = []) {
[
...aliases,
// Use `require.resolve` explicitly to make them statically analyzable
['styled-jsx', require.resolve('next/dist/styled-jsx')],
['styled-jsx/style', require.resolve('next/dist/styled-jsx/style')],
['styled-jsx', require.resolve('styled-jsx')],
['styled-jsx/style', require.resolve('styled-jsx/style')],
].map(([request, replacement]) => [request, replacement])
)

Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/render.tsx
Expand Up @@ -28,7 +28,7 @@ import type { UnwrapPromise } from '../lib/coalesced-function'
import type { ReactReadableStream } from './node-web-streams-helper'

import React from 'react'
import { StyleRegistry, createStyleRegistry } from 'next/dist/styled-jsx'
import { StyleRegistry, createStyleRegistry } from 'styled-jsx'
import {
GSP_NO_RETURNED_VALUE,
GSSP_COMPONENT_MEMBER_ERROR,
Expand Down
12 changes: 1 addition & 11 deletions packages/next/taskfile.js
Expand Up @@ -44,14 +44,11 @@ export async function copy_regenerator_runtime(task, opts) {

// eslint-disable-next-line camelcase
export async function copy_styled_jsx_assets(task, opts) {
// we copy the styled-jsx assets and types so that we can reference them
// we copy the styled-jsx types so that we can reference them
// in the next-env.d.ts file so it doesn't matter if the styled-jsx
// package is hoisted out of Next.js' node_modules or not
const styledJsxPath = dirname(require.resolve('styled-jsx/package.json'))
const typeFiles = glob.sync('*.d.ts', { cwd: styledJsxPath })
const jsFiles = glob.sync('**/{index,style,babel,babel-test}.js', {
cwd: styledJsxPath,
})
const outputDir = join(__dirname, 'dist/styled-jsx')
// Separate type files into different folders to avoid conflicts between
// dev dep `styled-jsx` and `next/dist/styled-jsx` for duplicated declare modules
Expand All @@ -62,13 +59,6 @@ export async function copy_styled_jsx_assets(task, opts) {
const content = await fs.readFile(join(styledJsxPath, file), 'utf8')
await fs.writeFile(join(typesDir, file), content)
}

for (const file of jsFiles) {
const content = await fs.readFile(join(styledJsxPath, file), 'utf8')
const distFile = join(outputDir, file)
await fs.ensureDir(dirname(distFile))
await fs.writeFile(distFile, content)
}
}

const externals = {
Expand Down
4 changes: 0 additions & 4 deletions packages/next/types/misc.d.ts
Expand Up @@ -284,10 +284,6 @@ declare module 'next/dist/compiled/postcss-scss' {
import m from 'postcss-scss'
export = m
}
declare module 'next/dist/styled-jsx' {
import m from 'styled-jsx'
export = m
}

declare module 'next/dist/compiled/text-table' {
function textTable(
Expand Down
1 change: 1 addition & 0 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 f0a883c

Please sign in to comment.