Commit a525b54b authored by Jiachi Liu's avatar Jiachi Liu

Upgrade precompiled glob

parent 3f19ee59
...@@ -156,7 +156,6 @@ ...@@ -156,7 +156,6 @@
"@types/cookie": "0.3.3", "@types/cookie": "0.3.3",
"@types/cross-spawn": "6.0.0", "@types/cross-spawn": "6.0.0",
"@types/fs-extra": "8.1.0", "@types/fs-extra": "8.1.0",
"@types/glob": "7.1.1",
"@types/html-validator": "5.0.3", "@types/html-validator": "5.0.3",
"@types/http-proxy": "1.17.3", "@types/http-proxy": "1.17.3",
"@types/jest": "29.5.5", "@types/jest": "29.5.5",
...@@ -211,7 +210,7 @@ ...@@ -211,7 +210,7 @@
"fs-extra": "9.0.0", "fs-extra": "9.0.0",
"get-port": "5.1.1", "get-port": "5.1.1",
"get-port-please": "3.1.1", "get-port-please": "3.1.1",
"glob": "7.1.6", "glob": "9.3.5",
"globals": "16.4.0", "globals": "16.4.0",
"gzip-size": "5.1.1", "gzip-size": "5.1.1",
"html-validator": "5.1.18", "html-validator": "5.1.18",
......
...@@ -199,7 +199,6 @@ ...@@ -199,7 +199,6 @@
"@types/debug": "4.1.5", "@types/debug": "4.1.5",
"@types/express-serve-static-core": "4.17.33", "@types/express-serve-static-core": "4.17.33",
"@types/fresh": "0.5.0", "@types/fresh": "0.5.0",
"@types/glob": "7.1.1",
"@types/jsonwebtoken": "9.0.0", "@types/jsonwebtoken": "9.0.0",
"@types/lodash": "4.14.198", "@types/lodash": "4.14.198",
"@types/lodash.curry": "4.1.6", "@types/lodash.curry": "4.1.6",
...@@ -263,7 +262,7 @@ ...@@ -263,7 +262,7 @@
"events": "3.3.0", "events": "3.3.0",
"find-up": "4.1.0", "find-up": "4.1.0",
"fresh": "0.5.2", "fresh": "0.5.2",
"glob": "7.1.7", "glob": "9.3.5",
"gzip-size": "5.1.1", "gzip-size": "5.1.1",
"http-proxy": "1.18.1", "http-proxy": "1.18.1",
"http-proxy-agent": "5.0.0", "http-proxy-agent": "5.0.0",
......
...@@ -547,18 +547,7 @@ export async function collectBuildTraces({ ...@@ -547,18 +547,7 @@ export async function collectBuildTraces({
const globOrig = const globOrig =
require('next/dist/compiled/glob') as typeof import('next/dist/compiled/glob') require('next/dist/compiled/glob') as typeof import('next/dist/compiled/glob')
const glob = (pattern: string): Promise<string[]> => { const glob = (pattern: string): Promise<string[]> => {
return new Promise((resolve, reject) => { return globOrig(pattern, { cwd: dir, nodir: true, dot: true })
globOrig(
pattern,
{ cwd: dir, nodir: true, dot: true },
(err, files) => {
if (err) {
return reject(err)
}
resolve(files)
}
)
})
} }
const { entryNameFilesMap } = buildTraceContext?.chunksTrace || {} const { entryNameFilesMap } = buildTraceContext?.chunksTrace || {}
......
...@@ -1953,23 +1953,17 @@ export default async function build( ...@@ -1953,23 +1953,17 @@ export default async function build(
} }
if (config.experimental.optimizeCss) { if (config.experimental.optimizeCss) {
const globOrig = const globOrig = require('next/dist/compiled/glob')
require('next/dist/compiled/glob') as typeof import('next/dist/compiled/glob') const globFiles = (
pattern: string,
const cssFilePaths = await new Promise<string[]>( options: any
(resolve, reject) => { ): Promise<string[]> => {
globOrig( return globOrig(pattern, options)
'**/*.css',
{ cwd: path.join(distDir, 'static') },
(err, files) => {
if (err) {
return reject(err)
}
resolve(files)
}
)
} }
)
const cssFilePaths = await globFiles('**/*.css', {
cwd: path.join(distDir, 'static'),
})
serverFilesManifest.files.push( serverFilesManifest.files.push(
...cssFilePaths.map((filePath) => ...cssFilePaths.map((filePath) =>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import crypto from 'crypto' import crypto from 'crypto'
import { promisify } from 'util' import glob from 'next/dist/compiled/glob'
import globOriginal from 'next/dist/compiled/glob'
import { Sema } from 'next/dist/compiled/async-sema' import { Sema } from 'next/dist/compiled/async-sema'
import type { NextConfigComplete } from '../server/config-shared' import type { NextConfigComplete } from '../server/config-shared'
import { getNextConfigEnv, getStaticEnv } from './static-env' import { getNextConfigEnv, getStaticEnv } from './static-env'
const glob = promisify(globOriginal)
export async function inlineStaticEnv({ export async function inlineStaticEnv({
distDir, distDir,
config, config,
......
...@@ -8,14 +8,7 @@ import type { PageExtensions } from '../build/page-extensions-type' ...@@ -8,14 +8,7 @@ import type { PageExtensions } from '../build/page-extensions-type'
const globOrig = const globOrig =
require('next/dist/compiled/glob') as typeof import('next/dist/compiled/glob') require('next/dist/compiled/glob') as typeof import('next/dist/compiled/glob')
const glob = (cwd: string, pattern: string): Promise<string[]> => { const glob = (cwd: string, pattern: string): Promise<string[]> => {
return new Promise((resolve, reject) => { return globOrig(pattern, { cwd })
globOrig(pattern, { cwd }, (err, files) => {
if (err) {
return reject(err)
}
resolve(files)
})
})
} }
function getRootLayout(isTs: boolean) { function getRootLayout(isTs: boolean) {
......
This diff is collapsed.
...@@ -5,11 +5,10 @@ import { ...@@ -5,11 +5,10 @@ import {
ExecSyncOptionsWithStringEncoding, ExecSyncOptionsWithStringEncoding,
} from 'child_process' } from 'child_process'
import { existsSync } from 'fs' import { existsSync } from 'fs'
import globOrig from 'glob' import glob from 'glob'
import { join } from 'path' import { join } from 'path'
import { promisify } from 'util'
export const glob = promisify(globOrig) export { glob }
export const NEXT_DIR = join(__dirname, '..') export const NEXT_DIR = join(__dirname, '..')
......
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