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

Use more precompiled deps in react-dev-overlay #60959

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export async function ncc_node_fetch(task, opts) {
}

externals['anser'] = 'next/dist/compiled/anser'
externals['next/dist/compiled/anser'] = 'next/dist/compiled/anser'
export async function ncc_node_anser(task, opts) {
await task
.source(relative(__dirname, require.resolve('anser')))
Expand All @@ -257,6 +258,8 @@ export async function ncc_node_anser(task, opts) {
}

externals['stacktrace-parser'] = 'next/dist/compiled/stacktrace-parser'
externals['next/dist/compiled/stacktrace-parser'] =
'next/dist/compiled/stacktrace-parser'
export async function ncc_node_stacktrace_parser(task, opts) {
await task
.source(relative(__dirname, require.resolve('stacktrace-parser')))
Expand All @@ -265,6 +268,8 @@ export async function ncc_node_stacktrace_parser(task, opts) {
}

externals['data-uri-to-buffer'] = 'next/dist/compiled/data-uri-to-buffer'
externals['next/dist/compiled/data-uri-to-buffer'] =
'next/dist/compiled/data-uri-to-buffer'
export async function ncc_node_data_uri_to_buffer(task, opts) {
await task
.source(relative(__dirname, require.resolve('data-uri-to-buffer')))
Expand All @@ -273,6 +278,7 @@ export async function ncc_node_data_uri_to_buffer(task, opts) {
}

externals['css.escape'] = 'next/dist/compiled/css.escape'
externals['next/dist/compiled/css.escape'] = 'next/dist/compiled/css.escape'
export async function ncc_node_cssescape(task, opts) {
await task
.source(relative(__dirname, require.resolve('css.escape')))
Expand All @@ -281,6 +287,7 @@ export async function ncc_node_cssescape(task, opts) {
}

externals['shell-quote'] = 'next/dist/compiled/shell-quote'
externals['next/dist/compiled/shell-quote'] = 'next/dist/compiled/shell-quote'
export async function ncc_node_shell_quote(task, opts) {
await task
.source(relative(__dirname, require.resolve('shell-quote')))
Expand All @@ -289,6 +296,7 @@ export async function ncc_node_shell_quote(task, opts) {
}

externals['platform'] = 'next/dist/compiled/platform'
externals['next/dist/compiled/platform'] = 'next/dist/compiled/platform'
export async function ncc_node_platform(task, opts) {
await task
.source(relative(__dirname, require.resolve('platform')))
Expand Down Expand Up @@ -1133,6 +1141,8 @@ const babelCorePackages = {
'@babel/core/lib/transformation/plugin-pass':
'next/dist/compiled/babel/core-lib-plugin-pass',
}
externals['next/dist/compiled/babel/code-frame'] =
'next/dist/compiled/babel/code-frame'

Object.assign(externals, babelCorePackages)

Expand Down Expand Up @@ -1942,6 +1952,7 @@ export async function ncc_string_hash(task, opts) {
}
// eslint-disable-next-line camelcase
externals['strip-ansi'] = 'next/dist/compiled/strip-ansi'
externals['next/dist/compiled/strip-ansi'] = 'next/dist/compiled/strip-ansi'
export async function ncc_strip_ansi(task, opts) {
await task
.source(relative(__dirname, require.resolve('strip-ansi')))
Expand Down
13 changes: 1 addition & 12 deletions packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@
"dev": "tsc -d -w -p tsconfig.json",
"typescript": "tsec --noEmit -p tsconfig.json"
},
"dependencies": {
"@babel/code-frame": "7.22.5",
"@types/babel__code-frame": "7.0.3",
"anser": "1.4.9",
"css.escape": "1.5.1",
"data-uri-to-buffer": "3.0.1",
"picocolors": "1.0.0",
"platform": "1.3.6",
"shell-quote": "1.7.3",
"stacktrace-parser": "0.1.10",
"strip-ansi": "6.0.1"
},
"dependencies": {},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dev-overlay/src/internal/bus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { StackFrame } from 'stacktrace-parser'
// @ts-ignore Package Exists
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'

export const TYPE_BUILD_OK = 'build-ok'
export const TYPE_BUILD_ERROR = 'build-error'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import Anser from 'anser'
// @ts-ignore Package exists
import Anser from 'next/dist/compiled/anser'
import * as React from 'react'
import type { StackFrame } from 'stacktrace-parser'
import stripAnsi from 'strip-ansi'
// @ts-ignore Package Exists
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'
// @ts-ignore Package Exists
import stripAnsi from 'next/dist/compiled/strip-ansi'
import { getFrameSource } from '../../helpers/stack-frame'

export type CodeFrameProps = { stackFrame: StackFrame; codeFrame: string }
Expand Down Expand Up @@ -93,7 +96,7 @@ export const CodeFrame: React.FC<CodeFrameProps> = function CodeFrame({
</p>
</div>
<pre>
{decoded.map((entry, index) => (
{decoded.map((entry: any, index: any) => (
<span
key={`frame-${index}`}
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
// Entrypoint: ally.js/maintain/tab-focus

import _platform from 'platform'
import cssEscape from 'css.escape'
import _platform from 'next/dist/compiled/platform'
import cssEscape from 'next/dist/compiled/css.escape'

// input may be undefined, selector-tring, Node, NodeList, HTMLCollection, array of Nodes
// yes, to some extent this is a bad replica of jQuery's constructor function
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Anser from 'anser'
// @ts-ignore Package exists
import Anser from 'next/dist/compiled/anser'
import * as React from 'react'

export type TerminalProps = { content: string }
Expand All @@ -17,7 +18,7 @@ export const Terminal: React.FC<TerminalProps> = function Terminal({
return (
<div data-nextjs-terminal>
<pre>
{decoded.map((entry, index) => (
{decoded.map((entry: any, index: any) => (
<span
key={`terminal-entry-${index}`}
style={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react'
import type { StackFrame } from 'stacktrace-parser'
// @ts-ignore Package Exists
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'
import { CodeFrame } from '../components/CodeFrame'
import type { ReadyRuntimeError } from '../helpers/getErrorByType'
import { noop as css } from '../helpers/noop-template'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MimeBuffer } from 'data-uri-to-buffer'
import dataUriToBuffer from 'data-uri-to-buffer'
// @ts-ignore Package Exists
import dataUriToBuffer from 'next/dist/compiled/data-uri-to-buffer'
import { getSourceMapUrl } from './getSourceMapUrl'

export function getRawSourceMap(fileContents: string): unknown | null {
Expand All @@ -8,7 +8,7 @@ export function getRawSourceMap(fileContents: string): unknown | null {
return null
}

let buffer: MimeBuffer
let buffer
try {
buffer = dataUriToBuffer(sourceUrl)
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import pc from 'picocolors'
// @ts-ignore Package Exists
import pc from 'next/dist/lib/picocolors'
import child_process from 'child_process'
import fs from 'fs'
import os from 'os'
import path from 'path'
// @ts-ignore
import shellQuote from 'shell-quote'
import shellQuote from 'next/dist/compiled/shell-quote'

function isTerminalEditor(editor: string) {
switch (editor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { StackFrame } from 'stacktrace-parser'
import { parse } from 'stacktrace-parser'
// @ts-ignore Package Exists
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'
// @ts-ignore Package Exists
import { parse } from 'next/dist/compiled/stacktrace-parser'

export function getFilesystemFrame(frame: StackFrame): StackFrame {
const f: StackFrame = { ...frame }
Expand Down Expand Up @@ -49,7 +51,7 @@ export function getServerError(error: Error, type: ErrorType): Error {
try {
n.stack = `${n.toString()}\n${parse(error.stack!)
.map(getFilesystemFrame)
.map((f) => {
.map((f: any) => {
let str = ` at ${f.methodName}`
if (f.file) {
let loc = f.file
Expand Down
8 changes: 5 additions & 3 deletions packages/react-dev-overlay/src/internal/helpers/parseStack.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { StackFrame } from 'stacktrace-parser'
import { parse } from 'stacktrace-parser'
// @ts-ignore Package Exists
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'
// @ts-ignore Package Exists
import { parse } from 'next/dist/compiled/stacktrace-parser'

const regexNextStatic = /\/_next(\/static\/.+)/

export function parseStack(stack: string): StackFrame[] {
const frames = parse(stack)
return frames.map((frame) => {
return frames.map((frame: any) => {
try {
const url = new URL(frame.file!)
const res = regexNextStatic.exec(url.pathname)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { StackFrame } from 'stacktrace-parser'
// @ts-ignore Package Exists
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'
import type { OriginalStackFrameResponse } from '../../middleware'

export type OriginalStackFrame =
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dev-overlay/src/middleware-turbopack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { OriginalStackFrameResponse } from './middleware'

import fs, { constants as FS } from 'fs/promises'
import url from 'url'
import { codeFrameColumns } from '@babel/code-frame'
// @ts-ignore Package exists
import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'
import { launchEditor } from './internal/helpers/launchEditor'

interface Project {
Expand Down
6 changes: 4 additions & 2 deletions packages/react-dev-overlay/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { codeFrameColumns } from '@babel/code-frame'
// @ts-ignore Package exists
import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'
import { constants as FS, promises as fs } from 'fs'
import type { IncomingMessage, ServerResponse } from 'http'
import path from 'path'
// @ts-ignore Package exists
import { SourceMapConsumer } from 'next/dist/compiled/source-map08'
import type { StackFrame } from 'stacktrace-parser'
// @ts-ignore Package exists
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'
import url from 'url'
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down
43 changes: 8 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.