Skip to content

Commit aa20eaa

Browse files
authored
refactor(bundler-webpack): replace webpack-5-chain with webpack-v5-chain (#1650)
1 parent 523e202 commit aa20eaa

23 files changed

+46
-51
lines changed

packages/bundler-webpack/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
"vue-loader": "^17.4.2",
6161
"vue-router": "catalog:",
6262
"webpack": "^5.99.7",
63-
"webpack-5-chain": "^8.0.2",
6463
"webpack-dev-server": "^5.2.1",
65-
"webpack-merge": "^6.0.1"
64+
"webpack-merge": "^6.0.1",
65+
"webpack-v5-chain": "^1.0.0"
6666
},
6767
"publishConfig": {
6868
"access": "public"

packages/bundler-webpack/src/build/createClientConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'
55
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
66
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
77
import type { Module } from 'webpack'
8-
import type Config from 'webpack-5-chain'
8+
import type { Config } from 'webpack-v5-chain'
99
import { createClientBaseConfig } from '../config/index.js'
1010
import type { WebpackBundlerOptions } from '../types.js'
1111
import { createClientPlugin } from './createClientPlugin.js'

packages/bundler-webpack/src/build/createServerConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createRequire } from 'node:module'
22
import type { App } from '@vuepress/core'
3-
import type Config from 'webpack-5-chain'
3+
import type { Config } from 'webpack-v5-chain'
44
import { createBaseConfig } from '../config/index.js'
55
import type { WebpackBundlerOptions } from '../types.js'
66

packages/bundler-webpack/src/config/createBaseConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { App } from '@vuepress/core'
2-
import Config from 'webpack-5-chain'
2+
import { Config } from 'webpack-v5-chain'
33
import type { WebpackBundlerOptions } from '../types.js'
44
import { handleDevtool } from './handleDevtool.js'
55
import { handleEntry } from './handleEntry.js'
@@ -21,7 +21,7 @@ export const createBaseConfig = async ({
2121
isBuild: boolean
2222
isServer: boolean
2323
}): Promise<Config> => {
24-
// create new webpack-5-chain config
24+
// create new webpack-v5-chain config
2525
const config = new Config()
2626

2727
/**

packages/bundler-webpack/src/config/createClientBaseConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { App } from '@vuepress/core'
2-
import type Config from 'webpack-5-chain'
2+
import type { Config } from 'webpack-v5-chain'
33
import type { WebpackBundlerOptions } from '../types.js'
44
import { createBaseConfig } from './createBaseConfig.js'
55

packages/bundler-webpack/src/config/handleDevtool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { App } from '@vuepress/core'
2-
import type Config from 'webpack-5-chain'
2+
import type { Config } from 'webpack-v5-chain'
33

44
/**
55
* Set webpack devtool

packages/bundler-webpack/src/config/handleEntry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { App } from '@vuepress/core'
22
import { fs } from '@vuepress/utils'
3-
import type Config from 'webpack-5-chain'
3+
import type { Config } from 'webpack-v5-chain'
44

55
/**
66
* Set webpack entry

packages/bundler-webpack/src/config/handleMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { App } from '@vuepress/core'
2-
import type Config from 'webpack-5-chain'
2+
import type { Config } from 'webpack-v5-chain'
33

44
/**
55
* Set webpack mode

packages/bundler-webpack/src/config/handleModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type Config from 'webpack-5-chain'
1+
import type { Config } from 'webpack-v5-chain'
22
import type { WebpackBundlerOptions } from '../types.js'
33
import { handleModuleAssets } from './handleModuleAssets.js'
44
import { handleModuleJs } from './handleModuleJs.js'

packages/bundler-webpack/src/config/handleModuleAssets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type Config from 'webpack-5-chain'
1+
import type { Config } from 'webpack-v5-chain'
22

33
/**
44
* Set webpack config to handle assets files

packages/bundler-webpack/src/config/handleModuleJs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createRequire } from 'node:module'
2-
import type Config from 'webpack-5-chain'
2+
import type { Config } from 'webpack-v5-chain'
33
import type { WebpackBundlerOptions } from '../types.js'
44
import { resolveEsbuildLoaderOptions } from './resolveEsbuildLoaderOptions.js'
55

packages/bundler-webpack/src/config/handleModulePug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type Config from 'webpack-5-chain'
1+
import type { Config } from 'webpack-v5-chain'
22

33
/**
44
* Set webpack module to handle pug files

packages/bundler-webpack/src/config/handleModuleStyles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createRequire } from 'node:module'
22
import autoprefixer from 'autoprefixer'
33
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
4-
import type Config from 'webpack-5-chain'
4+
import type { Config } from 'webpack-v5-chain'
55
import type {
66
StylePreprocessorLoaderOptions,
77
WebpackBundlerOptions,

packages/bundler-webpack/src/config/handleModuleTs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createRequire } from 'node:module'
2-
import type Config from 'webpack-5-chain'
2+
import type { Config } from 'webpack-v5-chain'
33
import { resolveEsbuildLoaderOptions } from './resolveEsbuildLoaderOptions.js'
44

55
const require = createRequire(import.meta.url)

packages/bundler-webpack/src/config/handleModuleVue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createRequire } from 'node:module'
22
import type { VueLoaderOptions } from 'vue-loader'
33
import { VueLoaderPlugin } from 'vue-loader'
4-
import type Config from 'webpack-5-chain'
4+
import type { Config } from 'webpack-v5-chain'
55
import type { WebpackBundlerOptions } from '../types.js'
66

77
const require = createRequire(import.meta.url)

packages/bundler-webpack/src/config/handleNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type Config from 'webpack-5-chain'
1+
import type { Config } from 'webpack-v5-chain'
22

33
/**
44
* Set webpack node config
55
*/
66
export const handleNode = ({ config }: { config: Config }): void => {
77
// do not polyfill or mock node globals and modules
8-
config.node.merge({
8+
config.node({
99
__filename: false,
1010
__dirname: false,
1111
global: false,

packages/bundler-webpack/src/config/handleOtherOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createRequire } from 'node:module'
22
import type { App } from '@vuepress/core'
3-
import type Config from 'webpack-5-chain'
3+
import type { Config } from 'webpack-v5-chain'
44

55
const require = createRequire(import.meta.url)
66

packages/bundler-webpack/src/config/handlePluginDefine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { App } from '@vuepress/core'
22
import webpack from 'webpack'
3-
import type Config from 'webpack-5-chain'
3+
import type { Config } from 'webpack-v5-chain'
44

55
/**
66
* Set webpack DefinePlugin

packages/bundler-webpack/src/config/handleResolve.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { App } from '@vuepress/core'
2-
import type Config from 'webpack-5-chain'
2+
import type { Config } from 'webpack-v5-chain'
33

44
/**
55
* Set webpack resolve
@@ -19,15 +19,10 @@ export const handleResolve = async ({
1919
.set('@temp', app.dir.temp())
2020
.set('@internal', app.dir.temp('internal'))
2121

22-
// extensions
23-
config.merge({
24-
resolve: {
25-
extensionAlias: {
26-
'.js': ['.js', '.ts'],
27-
'.mjs': ['.mjs', '.mts'],
28-
},
29-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.json'],
30-
},
22+
// extensionAlias
23+
config.resolve.extensionAlias.merge({
24+
'.js': ['.js', '.ts'],
25+
'.mjs': ['.mjs', '.mts'],
3126
})
3227

3328
// extensions

packages/bundler-webpack/src/dev/createDevConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { App } from '@vuepress/core'
22
import HtmlPlugin from 'html-webpack-plugin'
33
import webpack from 'webpack'
4-
import type Config from 'webpack-5-chain'
4+
import type { Config } from 'webpack-v5-chain'
55
import { createClientBaseConfig } from '../config/index.js'
66
import type { WebpackBundlerOptions } from '../types.js'
77

packages/bundler-webpack/src/resolveWebpackConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Configuration } from 'webpack'
2-
import type Config from 'webpack-5-chain'
32
import { merge } from 'webpack-merge'
3+
import type { Config } from 'webpack-v5-chain'
44
import type { WebpackBundlerOptions } from './types.js'
55

66
export const resolveWebpackConfig = ({
@@ -17,7 +17,7 @@ export const resolveWebpackConfig = ({
1717
// allow modifying webpack config via `chainWebpack`
1818
options.chainWebpack?.(config, isServer, isBuild)
1919

20-
// generate webpack config from webpack-5-chain
20+
// generate webpack config from webpack-v5-chain
2121
const webpackConfig = config.toConfig()
2222

2323
// allow modifying webpack config via `configureWebpack`

packages/bundler-webpack/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type {
44
LoaderContext,
55
Configuration as WebpackConfiguration,
66
} from 'webpack'
7-
import type WebpackChainConfig from 'webpack-5-chain'
87
import type WebpackDevServer from 'webpack-dev-server'
8+
import type { Config as WebpackChainConfig } from 'webpack-v5-chain'
99

1010
export type {
1111
VueLoaderOptions,
@@ -28,7 +28,7 @@ export interface WebpackBundlerOptions extends BundlerOptions {
2828
) => WebpackConfiguration | void
2929

3030
/**
31-
* use webpack-5-chain to set webpack config
31+
* use webpack-v5-chain to set webpack config
3232
*/
3333
chainWebpack?: (
3434
config: WebpackChainConfig,

pnpm-lock.yaml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)