mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 07:05:11 +00:00
chore: use tinyglobby
internally (#28686)
This commit is contained in:
parent
6ab3afc8bc
commit
8cb4bccc79
@ -72,7 +72,6 @@
|
|||||||
"eslint-plugin-no-only-tests": "3.3.0",
|
"eslint-plugin-no-only-tests": "3.3.0",
|
||||||
"eslint-plugin-perfectionist": "3.2.0",
|
"eslint-plugin-perfectionist": "3.2.0",
|
||||||
"eslint-typegen": "0.3.1",
|
"eslint-typegen": "0.3.1",
|
||||||
"globby": "14.0.2",
|
|
||||||
"h3": "1.12.0",
|
"h3": "1.12.0",
|
||||||
"happy-dom": "15.0.0",
|
"happy-dom": "15.0.0",
|
||||||
"jiti": "1.21.6",
|
"jiti": "1.21.6",
|
||||||
@ -88,6 +87,7 @@
|
|||||||
"semver": "7.6.3",
|
"semver": "7.6.3",
|
||||||
"std-env": "3.7.0",
|
"std-env": "3.7.0",
|
||||||
"tinyexec": "0.2.0",
|
"tinyexec": "0.2.0",
|
||||||
|
"tinyglobby": "0.2.2",
|
||||||
"typescript": "5.5.4",
|
"typescript": "5.5.4",
|
||||||
"ufo": "1.5.4",
|
"ufo": "1.5.4",
|
||||||
"vitest": "2.0.5",
|
"vitest": "2.0.5",
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
import { join, resolve } from 'node:path'
|
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { promises as fsp } from 'node:fs'
|
import { promises as fsp } from 'node:fs'
|
||||||
import { globby } from 'globby'
|
import { glob } from 'tinyglobby'
|
||||||
|
|
||||||
const templatesRoot = fileURLToPath(new URL('..', import.meta.url))
|
const templatesRoot = fileURLToPath(new URL('..', import.meta.url))
|
||||||
|
|
||||||
const r = (...path: string[]) => resolve(join(templatesRoot, ...path))
|
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
const templates = await globby(r('dist/templates/*.js'))
|
const templates = await glob(['dist/templates/*.js'], { cwd: templatesRoot })
|
||||||
for (const file of templates) {
|
for (const file of templates) {
|
||||||
const { template } = await import(file)
|
const { template } = await import(file)
|
||||||
const updated = template({
|
const updated = template({
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { readFileSync, rmdirSync, unlinkSync, writeFileSync } from 'node:fs'
|
import { readFileSync, rmdirSync, unlinkSync, writeFileSync } from 'node:fs'
|
||||||
import { copyFile } from 'node:fs/promises'
|
import { copyFile } from 'node:fs/promises'
|
||||||
import { basename, dirname, join, resolve } from 'pathe'
|
import { basename, dirname, join } from 'pathe'
|
||||||
import type { Plugin } from 'vite'
|
import type { Plugin } from 'vite'
|
||||||
// @ts-expect-error https://github.com/GoogleChromeLabs/critters/pull/151
|
// @ts-expect-error https://github.com/GoogleChromeLabs/critters/pull/151
|
||||||
import Critters from 'critters'
|
import Critters from 'critters'
|
||||||
import { genObjectFromRawEntries } from 'knitwork'
|
import { genObjectFromRawEntries } from 'knitwork'
|
||||||
import htmlMinifier from 'html-minifier'
|
import htmlMinifier from 'html-minifier'
|
||||||
import { globby } from 'globby'
|
import { glob } from 'tinyglobby'
|
||||||
import { camelCase } from 'scule'
|
import { camelCase } from 'scule'
|
||||||
|
|
||||||
import genericMessages from '../templates/messages.json'
|
import genericMessages from '../templates/messages.json'
|
||||||
@ -25,7 +25,10 @@ export const RenderPlugin = () => {
|
|||||||
enforce: 'post',
|
enforce: 'post',
|
||||||
async writeBundle () {
|
async writeBundle () {
|
||||||
const critters = new Critters({ path: outputDir })
|
const critters = new Critters({ path: outputDir })
|
||||||
const htmlFiles = await globby(resolve(outputDir, 'templates/**/*.html'), { absolute: true })
|
const htmlFiles = await glob(['templates/**/*.html'], {
|
||||||
|
cwd: outputDir,
|
||||||
|
absolute: true,
|
||||||
|
})
|
||||||
|
|
||||||
const templateExports: Array<{
|
const templateExports: Array<{
|
||||||
exportName: string
|
exportName: string
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
"@types/lodash-es": "4.17.12",
|
"@types/lodash-es": "4.17.12",
|
||||||
"@unocss/reset": "0.62.3",
|
"@unocss/reset": "0.62.3",
|
||||||
"critters": "0.0.24",
|
"critters": "0.0.24",
|
||||||
"globby": "14.0.2",
|
|
||||||
"html-minifier": "4.0.0",
|
"html-minifier": "4.0.0",
|
||||||
"html-validate": "8.21.0",
|
"html-validate": "8.21.0",
|
||||||
"jiti": "1.21.6",
|
"jiti": "1.21.6",
|
||||||
@ -32,6 +31,7 @@
|
|||||||
"prettier": "3.3.3",
|
"prettier": "3.3.3",
|
||||||
"scule": "1.3.0",
|
"scule": "1.3.0",
|
||||||
"tinyexec": "0.2.0",
|
"tinyexec": "0.2.0",
|
||||||
|
"tinyglobby": "0.2.2",
|
||||||
"unocss": "0.62.3",
|
"unocss": "0.62.3",
|
||||||
"vite": "5.4.2"
|
"vite": "5.4.2"
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,6 @@ importers:
|
|||||||
eslint-typegen:
|
eslint-typegen:
|
||||||
specifier: 0.3.1
|
specifier: 0.3.1
|
||||||
version: 0.3.1(eslint@9.9.1(jiti@1.21.6))
|
version: 0.3.1(eslint@9.9.1(jiti@1.21.6))
|
||||||
globby:
|
|
||||||
specifier: 14.0.2
|
|
||||||
version: 14.0.2
|
|
||||||
h3:
|
h3:
|
||||||
specifier: 1.12.0
|
specifier: 1.12.0
|
||||||
version: 1.12.0
|
version: 1.12.0
|
||||||
@ -144,6 +141,9 @@ importers:
|
|||||||
tinyexec:
|
tinyexec:
|
||||||
specifier: 0.2.0
|
specifier: 0.2.0
|
||||||
version: 0.2.0
|
version: 0.2.0
|
||||||
|
tinyglobby:
|
||||||
|
specifier: 0.2.2
|
||||||
|
version: 0.2.2
|
||||||
typescript:
|
typescript:
|
||||||
specifier: 5.5.4
|
specifier: 5.5.4
|
||||||
version: 5.5.4
|
version: 5.5.4
|
||||||
@ -603,9 +603,6 @@ importers:
|
|||||||
critters:
|
critters:
|
||||||
specifier: 0.0.24
|
specifier: 0.0.24
|
||||||
version: 0.0.24
|
version: 0.0.24
|
||||||
globby:
|
|
||||||
specifier: 14.0.2
|
|
||||||
version: 14.0.2
|
|
||||||
html-minifier:
|
html-minifier:
|
||||||
specifier: 4.0.0
|
specifier: 4.0.0
|
||||||
version: 4.0.0
|
version: 4.0.0
|
||||||
@ -633,6 +630,9 @@ importers:
|
|||||||
tinyexec:
|
tinyexec:
|
||||||
specifier: 0.2.0
|
specifier: 0.2.0
|
||||||
version: 0.2.0
|
version: 0.2.0
|
||||||
|
tinyglobby:
|
||||||
|
specifier: 0.2.2
|
||||||
|
version: 0.2.2
|
||||||
unocss:
|
unocss:
|
||||||
specifier: 0.62.3
|
specifier: 0.62.3
|
||||||
version: 0.62.3(@unocss/webpack@0.62.2(rollup@4.21.0)(webpack@5.94.0(esbuild@0.23.1)))(postcss@8.4.41)(rollup@4.21.0)(vite@5.4.2(@types/node@20.16.1)(sass@1.69.4)(terser@5.27.0))
|
version: 0.62.3(@unocss/webpack@0.62.2(rollup@4.21.0)(webpack@5.94.0(esbuild@0.23.1)))(postcss@8.4.41)(rollup@4.21.0)(vite@5.4.2(@types/node@20.16.1)(sass@1.69.4)(terser@5.27.0))
|
||||||
|
@ -2,7 +2,7 @@ import { execSync } from 'node:child_process'
|
|||||||
import { promises as fsp } from 'node:fs'
|
import { promises as fsp } from 'node:fs'
|
||||||
import { $fetch } from 'ofetch'
|
import { $fetch } from 'ofetch'
|
||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import { globby } from 'globby'
|
import { glob } from 'tinyglobby'
|
||||||
import { exec } from 'tinyexec'
|
import { exec } from 'tinyexec'
|
||||||
import { determineSemverChange, getGitDiff, loadChangelogConfig, parseCommits } from 'changelogen'
|
import { determineSemverChange, getGitDiff, loadChangelogConfig, parseCommits } from 'changelogen'
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ export async function loadPackage (dir: string) {
|
|||||||
|
|
||||||
export async function loadWorkspace (dir: string) {
|
export async function loadWorkspace (dir: string) {
|
||||||
const workspacePkg = await loadPackage(dir)
|
const workspacePkg = await loadPackage(dir)
|
||||||
const pkgDirs = (await globby(['packages/*'], { onlyDirectories: true })).sort()
|
const pkgDirs = (await glob(['packages/*'], { onlyDirectories: true })).sort()
|
||||||
|
|
||||||
const packages: Package[] = []
|
const packages: Package[] = []
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url'
|
|||||||
import fsp from 'node:fs/promises'
|
import fsp from 'node:fs/promises'
|
||||||
import { beforeAll, describe, expect, it } from 'vitest'
|
import { beforeAll, describe, expect, it } from 'vitest'
|
||||||
import { exec } from 'tinyexec'
|
import { exec } from 'tinyexec'
|
||||||
import { globby } from 'globby'
|
import { glob } from 'tinyglobby'
|
||||||
import { join } from 'pathe'
|
import { join } from 'pathe'
|
||||||
|
|
||||||
describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM_CI)('minimal nuxt application', () => {
|
describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM_CI)('minimal nuxt application', () => {
|
||||||
@ -18,7 +18,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
|||||||
// Identical behaviour between inline/external vue options as this should only affect the server build
|
// Identical behaviour between inline/external vue options as this should only affect the server build
|
||||||
for (const outputDir of ['.output', '.output-inline']) {
|
for (const outputDir of ['.output', '.output-inline']) {
|
||||||
it('default client bundle size', async () => {
|
it('default client bundle size', async () => {
|
||||||
const clientStats = await analyzeSizes('**/*.js', join(rootDir, outputDir, 'public'))
|
const clientStats = await analyzeSizes(['**/*.js'], join(rootDir, outputDir, 'public'))
|
||||||
expect.soft(roundToKilobytes(clientStats.totalBytes)).toMatchInlineSnapshot(`"108k"`)
|
expect.soft(roundToKilobytes(clientStats.totalBytes)).toMatchInlineSnapshot(`"108k"`)
|
||||||
expect(clientStats.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(`
|
expect(clientStats.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(`
|
||||||
[
|
[
|
||||||
@ -34,7 +34,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
|||||||
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||||
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"211k"`)
|
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"211k"`)
|
||||||
|
|
||||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
|
||||||
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1351k"`)
|
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1351k"`)
|
||||||
|
|
||||||
const packages = modules.files
|
const packages = modules.files
|
||||||
@ -74,7 +74,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
|||||||
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
|
||||||
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"535k"`)
|
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"535k"`)
|
||||||
|
|
||||||
const modules = await analyzeSizes('node_modules/**/*', serverDir)
|
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
|
||||||
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"82.1k"`)
|
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"82.1k"`)
|
||||||
|
|
||||||
const packages = modules.files
|
const packages = modules.files
|
||||||
@ -94,8 +94,8 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
async function analyzeSizes (pattern: string | string[], rootDir: string) {
|
async function analyzeSizes (pattern: string[], rootDir: string) {
|
||||||
const files: string[] = await globby(pattern, { cwd: rootDir })
|
const files: string[] = await glob(pattern, { cwd: rootDir })
|
||||||
let totalBytes = 0
|
let totalBytes = 0
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const path = join(rootDir, file)
|
const path = join(rootDir, file)
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { rm } from 'node:fs/promises'
|
import { rm } from 'node:fs/promises'
|
||||||
|
|
||||||
import { globby } from 'globby'
|
import { glob } from 'tinyglobby'
|
||||||
|
|
||||||
import { exec } from 'tinyexec'
|
import { exec } from 'tinyexec'
|
||||||
|
|
||||||
async function initTesting () {
|
async function initTesting () {
|
||||||
const dirs = await globby('*', {
|
const dirs = await glob(['*'], {
|
||||||
onlyDirectories: true,
|
onlyDirectories: true,
|
||||||
cwd: fileURLToPath(new URL('./fixtures', import.meta.url)),
|
cwd: fileURLToPath(new URL('./fixtures', import.meta.url)),
|
||||||
absolute: true,
|
absolute: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user