mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
perf(rspack,webpack): drop lodash-es
dependency (#30409)
This commit is contained in:
parent
7fb466c0e4
commit
c1b8b921f1
@ -14,7 +14,7 @@ import { tryUseNuxt, useNuxt } from './context'
|
|||||||
import { resolveNuxtModule } from './resolve'
|
import { resolveNuxtModule } from './resolve'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders given template using lodash template during build into the project buildDir
|
* Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
|
||||||
*/
|
*/
|
||||||
export function addTemplate<T> (_template: NuxtTemplate<T> | string) {
|
export function addTemplate<T> (_template: NuxtTemplate<T> | string) {
|
||||||
const nuxt = useNuxt()
|
const nuxt = useNuxt()
|
||||||
@ -44,7 +44,7 @@ export function addServerTemplate (template: NuxtServerTemplate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders given types using lodash template during build into the project buildDir
|
* Renders given types during build to disk in the project `buildDir`
|
||||||
* and register them as types.
|
* and register them as types.
|
||||||
*/
|
*/
|
||||||
export function addTypeTemplate<T> (_template: NuxtTypeTemplate<T>) {
|
export function addTypeTemplate<T> (_template: NuxtTypeTemplate<T>) {
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
||||||
"jiti": "^2.4.2",
|
"jiti": "^2.4.2",
|
||||||
"knitwork": "^1.2.0",
|
"knitwork": "^1.2.0",
|
||||||
"lodash-es": "4.17.21",
|
|
||||||
"magic-string": "^0.30.17",
|
"magic-string": "^0.30.17",
|
||||||
"memfs": "^4.15.1",
|
"memfs": "^4.15.1",
|
||||||
"ohash": "^1.1.4",
|
"ohash": "^1.1.4",
|
||||||
@ -73,7 +72,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/schema": "workspace:*",
|
"@nuxt/schema": "workspace:*",
|
||||||
"@types/lodash-es": "4.17.12",
|
|
||||||
"@types/pify": "5.0.4",
|
"@types/pify": "5.0.4",
|
||||||
"@types/webpack-bundle-analyzer": "4.7.0",
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
||||||
"@types/webpack-hot-middleware": "2.25.9",
|
"@types/webpack-hot-middleware": "2.25.9",
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
|
||||||
"jiti": "^2.4.2",
|
"jiti": "^2.4.2",
|
||||||
"knitwork": "^1.2.0",
|
"knitwork": "^1.2.0",
|
||||||
"lodash-es": "4.17.21",
|
|
||||||
"magic-string": "^0.30.17",
|
"magic-string": "^0.30.17",
|
||||||
"memfs": "^4.15.1",
|
"memfs": "^4.15.1",
|
||||||
"mini-css-extract-plugin": "^2.9.2",
|
"mini-css-extract-plugin": "^2.9.2",
|
||||||
@ -75,7 +74,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/schema": "workspace:*",
|
"@nuxt/schema": "workspace:*",
|
||||||
"@rspack/core": "1.1.8",
|
"@rspack/core": "1.1.8",
|
||||||
"@types/lodash-es": "4.17.12",
|
|
||||||
"@types/pify": "5.0.4",
|
"@types/pify": "5.0.4",
|
||||||
"@types/webpack-bundle-analyzer": "4.7.0",
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
||||||
"@types/webpack-hot-middleware": "2.25.9",
|
"@types/webpack-hot-middleware": "2.25.9",
|
||||||
|
@ -9,6 +9,7 @@ import escapeRegExp from 'escape-string-regexp'
|
|||||||
import { joinURL } from 'ufo'
|
import { joinURL } from 'ufo'
|
||||||
import type { NuxtOptions } from '@nuxt/schema'
|
import type { NuxtOptions } from '@nuxt/schema'
|
||||||
import { isTest } from 'std-env'
|
import { isTest } from 'std-env'
|
||||||
|
import { defu } from 'defu'
|
||||||
import type { WarningFilter } from '../plugins/warning-ignore'
|
import type { WarningFilter } from '../plugins/warning-ignore'
|
||||||
import WarningIgnorePlugin from '../plugins/warning-ignore'
|
import WarningIgnorePlugin from '../plugins/warning-ignore'
|
||||||
import type { WebpackConfigContext } from '../utils/config'
|
import type { WebpackConfigContext } from '../utils/config'
|
||||||
@ -27,7 +28,7 @@ export async function base (ctx: WebpackConfigContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function baseConfig (ctx: WebpackConfigContext) {
|
function baseConfig (ctx: WebpackConfigContext) {
|
||||||
ctx.config = {
|
ctx.config = defu({}, {
|
||||||
name: ctx.name,
|
name: ctx.name,
|
||||||
entry: { app: [resolve(ctx.options.appDir, ctx.options.experimental.asyncEntry ? 'entry.async' : 'entry')] },
|
entry: { app: [resolve(ctx.options.appDir, ctx.options.experimental.asyncEntry ? 'entry.async' : 'entry')] },
|
||||||
module: { rules: [] },
|
module: { rules: [] },
|
||||||
@ -45,7 +46,7 @@ function baseConfig (ctx: WebpackConfigContext) {
|
|||||||
output: getOutput(ctx),
|
output: getOutput(ctx),
|
||||||
stats: statsMap[ctx.nuxt.options.logLevel] ?? statsMap.info,
|
stats: statsMap[ctx.nuxt.options.logLevel] ?? statsMap.info,
|
||||||
...ctx.config,
|
...ctx.config,
|
||||||
}
|
} satisfies Configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
function basePlugins (ctx: WebpackConfigContext) {
|
function basePlugins (ctx: WebpackConfigContext) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import type { Configuration } from 'webpack'
|
import type { Configuration } from 'webpack'
|
||||||
import type { Nuxt, NuxtOptions } from '@nuxt/schema'
|
import type { Nuxt, NuxtOptions } from '@nuxt/schema'
|
||||||
import { logger } from '@nuxt/kit'
|
import { logger } from '@nuxt/kit'
|
||||||
import { cloneDeep } from 'lodash-es'
|
|
||||||
import { toArray } from './index'
|
import { toArray } from './index'
|
||||||
|
|
||||||
export interface WebpackConfigContext {
|
export interface WebpackConfigContext {
|
||||||
@ -63,9 +62,3 @@ export function fileName (ctx: WebpackConfigContext, key: string) {
|
|||||||
|
|
||||||
return fileName
|
return fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWebpackConfig (ctx: WebpackConfigContext): Configuration {
|
|
||||||
// Clone to avoid leaking config between Client and Server
|
|
||||||
// TODO: rewrite webpack implementation to avoid necessity for this
|
|
||||||
return cloneDeep(ctx.config)
|
|
||||||
}
|
|
||||||
|
@ -15,7 +15,7 @@ import { DynamicBasePlugin } from './plugins/dynamic-base'
|
|||||||
import { ChunkErrorPlugin } from './plugins/chunk'
|
import { ChunkErrorPlugin } from './plugins/chunk'
|
||||||
import { createMFS } from './utils/mfs'
|
import { createMFS } from './utils/mfs'
|
||||||
import { client, server } from './configs'
|
import { client, server } from './configs'
|
||||||
import { applyPresets, createWebpackConfigContext, getWebpackConfig } from './utils/config'
|
import { applyPresets, createWebpackConfigContext } from './utils/config'
|
||||||
import { dynamicRequire } from './nitro/plugins/dynamic-require'
|
import { dynamicRequire } from './nitro/plugins/dynamic-require'
|
||||||
|
|
||||||
import { builder, webpack } from '#builder'
|
import { builder, webpack } from '#builder'
|
||||||
@ -28,7 +28,7 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
|
|||||||
const ctx = createWebpackConfigContext(nuxt)
|
const ctx = createWebpackConfigContext(nuxt)
|
||||||
ctx.userConfig = defu(nuxt.options.webpack[`$${preset.name as 'client' | 'server'}`], ctx.userConfig)
|
ctx.userConfig = defu(nuxt.options.webpack[`$${preset.name as 'client' | 'server'}`], ctx.userConfig)
|
||||||
await applyPresets(ctx, preset)
|
await applyPresets(ctx, preset)
|
||||||
return getWebpackConfig(ctx)
|
return ctx.config
|
||||||
}))
|
}))
|
||||||
|
|
||||||
/** Inject rollup plugin for Nitro to handle dynamic imports from webpack chunks */
|
/** Inject rollup plugin for Nitro to handle dynamic imports from webpack chunks */
|
||||||
|
@ -550,9 +550,6 @@ importers:
|
|||||||
knitwork:
|
knitwork:
|
||||||
specifier: ^1.2.0
|
specifier: ^1.2.0
|
||||||
version: 1.2.0
|
version: 1.2.0
|
||||||
lodash-es:
|
|
||||||
specifier: 4.17.21
|
|
||||||
version: 4.17.21
|
|
||||||
magic-string:
|
magic-string:
|
||||||
specifier: ^0.30.17
|
specifier: ^0.30.17
|
||||||
version: 0.30.17
|
version: 0.30.17
|
||||||
@ -626,9 +623,6 @@ importers:
|
|||||||
'@nuxt/schema':
|
'@nuxt/schema':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../schema
|
version: link:../schema
|
||||||
'@types/lodash-es':
|
|
||||||
specifier: 4.17.12
|
|
||||||
version: 4.17.12
|
|
||||||
'@types/pify':
|
'@types/pify':
|
||||||
specifier: 5.0.4
|
specifier: 5.0.4
|
||||||
version: 5.0.4
|
version: 5.0.4
|
||||||
@ -949,9 +943,6 @@ importers:
|
|||||||
knitwork:
|
knitwork:
|
||||||
specifier: ^1.2.0
|
specifier: ^1.2.0
|
||||||
version: 1.2.0
|
version: 1.2.0
|
||||||
lodash-es:
|
|
||||||
specifier: 4.17.21
|
|
||||||
version: 4.17.21
|
|
||||||
magic-string:
|
magic-string:
|
||||||
specifier: ^0.30.17
|
specifier: ^0.30.17
|
||||||
version: 0.30.17
|
version: 0.30.17
|
||||||
@ -1034,9 +1025,6 @@ importers:
|
|||||||
'@rspack/core':
|
'@rspack/core':
|
||||||
specifier: 1.1.8
|
specifier: 1.1.8
|
||||||
version: 1.1.8
|
version: 1.1.8
|
||||||
'@types/lodash-es':
|
|
||||||
specifier: 4.17.12
|
|
||||||
version: 4.17.12
|
|
||||||
'@types/pify':
|
'@types/pify':
|
||||||
specifier: 5.0.4
|
specifier: 5.0.4
|
||||||
version: 5.0.4
|
version: 5.0.4
|
||||||
@ -2620,12 +2608,6 @@ packages:
|
|||||||
'@types/json-schema@7.0.15':
|
'@types/json-schema@7.0.15':
|
||||||
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
|
||||||
|
|
||||||
'@types/lodash-es@4.17.12':
|
|
||||||
resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==}
|
|
||||||
|
|
||||||
'@types/lodash@4.17.7':
|
|
||||||
resolution: {integrity: sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==}
|
|
||||||
|
|
||||||
'@types/mdast@4.0.4':
|
'@types/mdast@4.0.4':
|
||||||
resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}
|
resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==}
|
||||||
|
|
||||||
@ -5302,9 +5284,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
|
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
lodash-es@4.17.21:
|
|
||||||
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
|
||||||
|
|
||||||
lodash.defaults@4.2.0:
|
lodash.defaults@4.2.0:
|
||||||
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
|
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
|
||||||
|
|
||||||
@ -9524,12 +9503,6 @@ snapshots:
|
|||||||
|
|
||||||
'@types/json-schema@7.0.15': {}
|
'@types/json-schema@7.0.15': {}
|
||||||
|
|
||||||
'@types/lodash-es@4.17.12':
|
|
||||||
dependencies:
|
|
||||||
'@types/lodash': 4.17.7
|
|
||||||
|
|
||||||
'@types/lodash@4.17.7': {}
|
|
||||||
|
|
||||||
'@types/mdast@4.0.4':
|
'@types/mdast@4.0.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/unist': 3.0.3
|
'@types/unist': 3.0.3
|
||||||
@ -12763,8 +12736,6 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
p-locate: 5.0.0
|
p-locate: 5.0.0
|
||||||
|
|
||||||
lodash-es@4.17.21: {}
|
|
||||||
|
|
||||||
lodash.defaults@4.2.0: {}
|
lodash.defaults@4.2.0: {}
|
||||||
|
|
||||||
lodash.isarguments@3.1.0: {}
|
lodash.isarguments@3.1.0: {}
|
||||||
|
Loading…
Reference in New Issue
Block a user