From a5644cf4cabd7c854be4b7d134d939f3df20c5e4 Mon Sep 17 00:00:00 2001 From: Horu <73709188+HigherOrderLogic@users.noreply.github.com> Date: Thu, 7 Nov 2024 06:44:21 +1100 Subject: [PATCH] fix(rspack): update `webpackbar` with support for rspack (#29823) --- packages/rspack/builder.mjs | 2 + packages/rspack/package.json | 2 +- packages/webpack/builder.d.ts | 1 + packages/webpack/builder.mjs | 1 + packages/webpack/package.json | 2 +- packages/webpack/src/presets/base.ts | 15 ++++---- pnpm-lock.yaml | 55 +++++++++++----------------- 7 files changed, 35 insertions(+), 43 deletions(-) diff --git a/packages/rspack/builder.mjs b/packages/rspack/builder.mjs index 14b2475188..642ad78f1d 100644 --- a/packages/rspack/builder.mjs +++ b/packages/rspack/builder.mjs @@ -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 diff --git a/packages/rspack/package.json b/packages/rspack/package.json index b201a1fe02..7a1c27e184 100644 --- a/packages/rspack/package.json +++ b/packages/rspack/package.json @@ -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:*", diff --git a/packages/webpack/builder.d.ts b/packages/webpack/builder.d.ts index a7924b945d..5180da54ed 100644 --- a/packages/webpack/builder.d.ts +++ b/packages/webpack/builder.d.ts @@ -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' } diff --git a/packages/webpack/builder.mjs b/packages/webpack/builder.mjs index 4de1c41293..e33279fea9 100644 --- a/packages/webpack/builder.mjs +++ b/packages/webpack/builder.mjs @@ -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' diff --git a/packages/webpack/package.json b/packages/webpack/package.json index aee7712b8b..bc41ddbba0 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -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:*", diff --git a/packages/webpack/src/presets/base.ts b/packages/webpack/src/presets/base.ts index 48ae42c14c..1671f74ddc 100644 --- a/packages/webpack/src/presets/base.ts +++ b/packages/webpack/src/presets/base.ts @@ -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) }, }, }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1e5483153c..16073cc522 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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: {}