fix(rspack): update webpackbar with support for rspack (#29823)

This commit is contained in:
Horu 2024-11-07 06:44:21 +11:00 committed by GitHub
parent 16fab77784
commit a5644cf4ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 35 additions and 43 deletions

View File

@ -1,5 +1,7 @@
import webpack from '@rspack/core'
export { default as WebpackBarPlugin } from 'webpackbar/rspack'
export const builder = 'rspack'
export { webpack }
export const MiniCssExtractPlugin = webpack.CssExtractRspackPlugin

View File

@ -72,7 +72,7 @@
"webpack-dev-middleware": "^7.4.2",
"webpack-hot-middleware": "^2.26.1",
"webpack-virtual-modules": "^0.6.2",
"webpackbar": "^6.0.1"
"webpackbar": "^7.0.0"
},
"devDependencies": {
"@nuxt/schema": "workspace:*",

View File

@ -3,6 +3,7 @@ declare module '#builder' {
import type MiniCssExtractPlugin from 'mini-css-extract-plugin'
export const webpack: typeof Webpack
export const WebpackBarPlugin: typeof import('webpackbar').default
export const MiniCssExtractPlugin: typeof MiniCssExtractPlugin
export const builder: 'webpack' | 'rspack'
}

View File

@ -1,3 +1,4 @@
export const builder = 'webpack'
export { default as webpack } from 'webpack'
export { default as MiniCssExtractPlugin } from 'mini-css-extract-plugin'
export { default as WebpackBarPlugin } from 'webpackbar'

View File

@ -72,7 +72,7 @@
"webpack-bundle-analyzer": "^4.10.2",
"webpack-dev-middleware": "^7.4.2",
"webpack-hot-middleware": "^2.26.1",
"webpackbar": "^6.0.1"
"webpackbar": "^7.0.0"
},
"devDependencies": {
"@nuxt/schema": "workspace:*",

View File

@ -1,7 +1,6 @@
import { normalize, resolve } from 'pathe'
// @ts-expect-error missing types
import TimeFixPlugin from 'time-fix-plugin'
import WebpackBar from 'webpackbar'
import type { Configuration } from 'webpack'
import { logger } from '@nuxt/kit'
// @ts-expect-error missing types
@ -15,7 +14,7 @@ import WarningIgnorePlugin from '../plugins/warning-ignore'
import type { WebpackConfigContext } from '../utils/config'
import { applyPresets, fileName } from '../utils/config'
import { builder, webpack } from '#builder'
import { WebpackBarPlugin, builder, webpack } from '#builder'
export async function base (ctx: WebpackConfigContext) {
await applyPresets(ctx, [
@ -88,7 +87,7 @@ function basePlugins (ctx: WebpackConfigContext) {
server: 'orange',
modern: 'blue',
}
ctx.config.plugins.push(new WebpackBar({
ctx.config.plugins.push(new WebpackBarPlugin({
name: ctx.name,
color: colors[ctx.name as keyof typeof colors],
reporters: ['stats'],
@ -101,18 +100,18 @@ function basePlugins (ctx: WebpackConfigContext) {
ctx.nuxt.callHook(`${builder}:change`, shortPath)
}
},
done: ({ state }) => {
if (state.hasErrors) {
done: (_, { stats }) => {
if (stats.hasErrors()) {
ctx.nuxt.callHook(`${builder}:error`)
} else {
logger.success(`${state.name} ${state.message}`)
logger.success(`Finished building ${stats.compilation.name ?? 'Nuxt app'}`)
}
},
allDone: () => {
ctx.nuxt.callHook(`${builder}:done`)
},
progress ({ statesArray }) {
ctx.nuxt.callHook(`${builder}:progress`, statesArray)
progress: ({ webpackbar }) => {
ctx.nuxt.callHook(`${builder}:progress`, webpackbar.statesArray)
},
},
},

View File

@ -638,8 +638,8 @@ importers:
specifier: ^0.6.2
version: 0.6.2
webpackbar:
specifier: ^6.0.1
version: 6.0.1(webpack@5.96.1)
specifier: ^7.0.0
version: 7.0.0(@rspack/core@1.0.14)(webpack@5.96.1)
devDependencies:
'@nuxt/schema':
specifier: workspace:*
@ -1088,8 +1088,8 @@ importers:
specifier: ^2.26.1
version: 2.26.1
webpackbar:
specifier: ^6.0.1
version: 6.0.1(webpack@5.96.1)
specifier: ^7.0.0
version: 7.0.0(@rspack/core@1.0.14)(webpack@5.96.1)
devDependencies:
'@nuxt/schema':
specifier: workspace:*
@ -3478,6 +3478,10 @@ packages:
resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==}
engines: {node: '>=12'}
ansis@3.3.2:
resolution: {integrity: sha512-cFthbBlt+Oi0i9Pv/j6YdVWJh54CtjGACaMPCIrEV4Ha7HWsIjXDwseYV79TIL0B4+KfSwD5S70PeQDkPUd1rA==}
engines: {node: '>=15'}
anymatch@3.1.3:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
@ -4521,10 +4525,6 @@ packages:
picomatch:
optional: true
figures@3.2.0:
resolution: {integrity: sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==}
engines: {node: '>=8'}
file-entry-cache@8.0.0:
resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
engines: {node: '>=16.0.0'}
@ -5457,9 +5457,6 @@ packages:
resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==}
hasBin: true
markdown-table@2.0.0:
resolution: {integrity: sha512-Ezda85ToJUBhM6WGaG6veasyym+Tbs3cMAw/ZhOPqXiYsr0jgocBV3j3nx+4lk47plLlIqjwuTm/ywVI+zjJ/A==}
markdown-table@3.0.3:
resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==}
@ -6573,10 +6570,6 @@ packages:
remark-stringify@11.0.0:
resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}
repeat-string@1.6.1:
resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==}
engines: {node: '>=0.10'}
require-directory@2.1.1:
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
engines: {node: '>=0.10.0'}
@ -7695,11 +7688,17 @@ packages:
webpack-cli:
optional: true
webpackbar@6.0.1:
resolution: {integrity: sha512-TnErZpmuKdwWBdMoexjio3KKX6ZtoKHRVvLIU0A47R0VVBDtx3ZyOJDktgYixhoJokZTYTt1Z37OkO9pnGJa9Q==}
webpackbar@7.0.0:
resolution: {integrity: sha512-aS9soqSO2iCHgqHoCrj4LbfGQUboDCYJPSFOAchEK+9psIjNrfSWW4Y0YEz67MKURNvMmfo0ycOg9d/+OOf9/Q==}
engines: {node: '>=14.21.3'}
peerDependencies:
'@rspack/core': '*'
webpack: 3 || 4 || 5
peerDependenciesMeta:
'@rspack/core':
optional: true
webpack:
optional: true
whatwg-mimetype@3.0.0:
resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==}
@ -10515,6 +10514,8 @@ snapshots:
ansi-styles@6.2.1: {}
ansis@3.3.2: {}
anymatch@3.1.3:
dependencies:
normalize-path: 3.0.0
@ -11712,10 +11713,6 @@ snapshots:
optionalDependencies:
picomatch: 4.0.2
figures@3.2.0:
dependencies:
escape-string-regexp: 1.0.5
file-entry-cache@8.0.0:
dependencies:
flat-cache: 4.0.1
@ -12696,10 +12693,6 @@ snapshots:
punycode.js: 2.3.1
uc.micro: 2.1.0
markdown-table@2.0.0:
dependencies:
repeat-string: 1.6.1
markdown-table@3.0.3: {}
markdownlint-cli@0.42.0:
@ -14229,8 +14222,6 @@ snapshots:
mdast-util-to-markdown: 2.1.2
unified: 11.0.5
repeat-string@1.6.1: {}
require-directory@2.1.1: {}
require-from-string@2.0.2: {}
@ -15571,17 +15562,15 @@ snapshots:
- esbuild
- uglify-js
webpackbar@6.0.1(webpack@5.96.1):
webpackbar@7.0.0(@rspack/core@1.0.14)(webpack@5.96.1):
dependencies:
ansi-escapes: 4.3.2
chalk: 4.1.2
ansis: 3.3.2
consola: 3.2.3
figures: 3.2.0
markdown-table: 2.0.0
pretty-time: 1.1.0
std-env: 3.7.0
optionalDependencies:
'@rspack/core': 1.0.14
webpack: 5.96.1
wrap-ansi: 7.0.0
whatwg-mimetype@3.0.0: {}