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' import webpack from '@rspack/core'
export { default as WebpackBarPlugin } from 'webpackbar/rspack'
export const builder = 'rspack' export const builder = 'rspack'
export { webpack } export { webpack }
export const MiniCssExtractPlugin = webpack.CssExtractRspackPlugin export const MiniCssExtractPlugin = webpack.CssExtractRspackPlugin

View File

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

View File

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

View File

@ -1,3 +1,4 @@
export const builder = 'webpack' export const builder = 'webpack'
export { default as webpack } from 'webpack' export { default as webpack } from 'webpack'
export { default as MiniCssExtractPlugin } from 'mini-css-extract-plugin' 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-bundle-analyzer": "^4.10.2",
"webpack-dev-middleware": "^7.4.2", "webpack-dev-middleware": "^7.4.2",
"webpack-hot-middleware": "^2.26.1", "webpack-hot-middleware": "^2.26.1",
"webpackbar": "^6.0.1" "webpackbar": "^7.0.0"
}, },
"devDependencies": { "devDependencies": {
"@nuxt/schema": "workspace:*", "@nuxt/schema": "workspace:*",

View File

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

View File

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