Unverified Commit 3894bad8 authored by Sukka's avatar Sukka Committed by GitHub

chore(precompile): re-add `watchpack` to the precompile (#60309)

Per @styfle suggestion, #58038 has been split into multiple PRs for
easier review.

- Re-add precompile `watchpack`
- Next.js has stopped bundling the `watchpack` since
https://github.com/vercel/next.js/pull/50792. Currently, `watchpack` is
a direct dependency of Next.js. The PR adds the pre-compile back.
Co-authored-by: 's avatarSteven <steven@ceriously.com>
parent 817a2402
...@@ -98,8 +98,7 @@ ...@@ -98,8 +98,7 @@
"caniuse-lite": "^1.0.30001406", "caniuse-lite": "^1.0.30001406",
"graceful-fs": "^4.2.11", "graceful-fs": "^4.2.11",
"postcss": "8.4.31", "postcss": "8.4.31",
"styled-jsx": "5.1.1", "styled-jsx": "5.1.1"
"watchpack": "2.4.0"
}, },
"peerDependencies": { "peerDependencies": {
"@opentelemetry/api": "^1.1.0", "@opentelemetry/api": "^1.1.0",
......
This diff is collapsed.
...@@ -36,7 +36,7 @@ import fs from 'fs' ...@@ -36,7 +36,7 @@ import fs from 'fs'
import url from 'url' import url from 'url'
import path from 'path' import path from 'path'
import qs from 'querystring' import qs from 'querystring'
import Watchpack from 'watchpack' import Watchpack from 'next/dist/compiled/watchpack'
import { loadEnvConfig } from '@next/env' import { loadEnvConfig } from '@next/env'
import isError from '../../../lib/is-error' import isError from '../../../lib/is-error'
import findUp from 'next/dist/compiled/find-up' import findUp from 'next/dist/compiled/find-up'
...@@ -1870,7 +1870,7 @@ async function startWatcher(opts: SetupOpts) { ...@@ -1870,7 +1870,7 @@ async function startWatcher(opts: SetupOpts) {
const watchTimeChange = const watchTimeChange =
watchTime === undefined || watchTime === undefined ||
(watchTime && watchTime !== meta?.timestamp) (watchTime && watchTime !== meta?.timestamp)
fileWatchTimes.set(fileName, meta.timestamp) fileWatchTimes.set(fileName, meta?.timestamp)
if (envFiles.includes(fileName)) { if (envFiles.includes(fileName)) {
if (watchTimeChange) { if (watchTimeChange) {
......
...@@ -14,7 +14,7 @@ import path from 'path' ...@@ -14,7 +14,7 @@ import path from 'path'
import http from 'http' import http from 'http'
import https from 'https' import https from 'https'
import os from 'os' import os from 'os'
import Watchpack from 'watchpack' import Watchpack from 'next/dist/compiled/watchpack'
import * as Log from '../../build/output/log' import * as Log from '../../build/output/log'
import setupDebug from 'next/dist/compiled/debug' import setupDebug from 'next/dist/compiled/debug'
import { RESTART_EXIT_CODE, checkNodeDebugType, getDebugPort } from './utils' import { RESTART_EXIT_CODE, checkNodeDebugType, getDebugPort } from './utils'
......
...@@ -569,7 +569,13 @@ export async function ncc_next_font(task, opts) { ...@@ -569,7 +569,13 @@ export async function ncc_next_font(task, opts) {
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['watchpack'] = 'watchpack' externals['watchpack'] = 'next/dist/compiled/watchpack'
export async function ncc_watchpack(task, opts) {
await task
.source(relative(__dirname, require.resolve('watchpack')))
.ncc({ packageName: 'watchpack', externals })
.target('src/compiled/watchpack')
}
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['jest-worker'] = 'next/dist/compiled/jest-worker' externals['jest-worker'] = 'next/dist/compiled/jest-worker'
...@@ -2312,6 +2318,7 @@ export async function ncc(task, opts) { ...@@ -2312,6 +2318,7 @@ export async function ncc(task, opts) {
'ncc_terser', 'ncc_terser',
'ncc_text_table', 'ncc_text_table',
'ncc_unistore', 'ncc_unistore',
'ncc_watchpack',
'ncc_web_vitals', 'ncc_web_vitals',
'ncc_web_vitals_attribution', 'ncc_web_vitals_attribution',
'ncc_webpack_bundle5', 'ncc_webpack_bundle5',
......
...@@ -174,10 +174,6 @@ declare module 'next/dist/compiled/babel/preset-env' { ...@@ -174,10 +174,6 @@ declare module 'next/dist/compiled/babel/preset-env' {
const anyType: any const anyType: any
export default anyType export default anyType
} }
declare module 'watchpack' {
const anyType: any
export default anyType
}
declare module 'next/dist/compiled/babel/core' { declare module 'next/dist/compiled/babel/core' {
export * from '@babel/core' export * from '@babel/core'
} }
......
...@@ -844,9 +844,6 @@ importers: ...@@ -844,9 +844,6 @@ importers:
styled-jsx: styled-jsx:
specifier: 5.1.1 specifier: 5.1.1
version: 5.1.1(@babel/core@7.22.5)(react@18.2.0) version: 5.1.1(@babel/core@7.22.5)(react@18.2.0)
watchpack:
specifier: 2.4.0
version: 2.4.0
devDependencies: devDependencies:
'@ampproject/toolbox-optimizer': '@ampproject/toolbox-optimizer':
specifier: 2.8.3 specifier: 2.8.3
...@@ -1427,6 +1424,9 @@ importers: ...@@ -1427,6 +1424,9 @@ importers:
vm-browserify: vm-browserify:
specifier: 1.1.2 specifier: 1.1.2
version: 1.1.2 version: 1.1.2
watchpack:
specifier: 2.4.0
version: 2.4.0
web-vitals: web-vitals:
specifier: 3.0.0 specifier: 3.0.0
version: 3.0.0 version: 3.0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment