Compare commits

...

4 Commits

Author SHA1 Message Date
renovate[bot] 72dbb262bf
chore(deps): update all non-major dependencies 2024-09-20 21:39:51 +00:00
renovate[bot] fa3efbf918
chore(deps): update all non-major dependencies (3.x) (#29092)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Roe <daniel@roe.dev>
2024-09-20 18:52:06 +01:00
Daniel Roe 9d77fdc802
fix(kit,vite,webpack): resolve postcss paths from each modules dir (#29096) 2024-09-20 18:39:17 +01:00
Daniel Roe 70a622d433
fix(kit): try resolving module path from each node_modules dir 2024-09-20 13:29:57 +01:00
12 changed files with 468 additions and 451 deletions

View File

@ -39,9 +39,9 @@
"@nuxt/ui-templates": "workspace:*",
"@nuxt/vite-builder": "workspace:*",
"@nuxt/webpack-builder": "workspace:*",
"@vue/compiler-core": "3.5.6",
"@vue/compiler-dom": "3.5.6",
"@vue/shared": "3.5.6",
"@vue/compiler-core": "3.5.7",
"@vue/compiler-dom": "3.5.7",
"@vue/shared": "3.5.7",
"@types/node": "20.16.5",
"magic-string": "^0.30.11",
"nuxt": "workspace:*",
@ -51,11 +51,11 @@
"send": ">=0.19.0",
"typescript": "5.6.2",
"ufo": "1.5.4",
"vite": "5.4.6",
"vue": "3.5.6"
"vite": "5.4.7",
"vue": "3.5.7"
},
"devDependencies": {
"@eslint/js": "9.10.0",
"@eslint/js": "9.11.0",
"@nuxt/eslint-config": "0.5.7",
"@nuxt/kit": "workspace:*",
"@nuxt/test-utils": "3.14.2",
@ -76,7 +76,7 @@
"cssnano": "7.0.6",
"destr": "2.0.3",
"devalue": "5.0.0",
"eslint": "9.10.0",
"eslint": "9.11.0",
"eslint-plugin-no-only-tests": "3.3.0",
"eslint-plugin-perfectionist": "3.6.0",
"eslint-typegen": "0.3.2",
@ -88,9 +88,9 @@
"nuxi": "3.13.2",
"nuxt": "workspace:*",
"nuxt-content-twoslash": "0.1.1",
"ofetch": "1.3.4",
"ofetch": "1.4.0",
"pathe": "1.1.2",
"playwright-core": "1.47.1",
"playwright-core": "1.47.2",
"rimraf": "6.0.1",
"semver": "7.6.3",
"sherif": "1.0.0",
@ -101,11 +101,11 @@
"ufo": "1.5.4",
"vitest": "2.1.1",
"vitest-environment-nuxt": "1.0.1",
"vue": "3.5.6",
"vue": "3.5.7",
"vue-router": "4.4.5",
"vue-tsc": "2.1.6"
},
"packageManager": "pnpm@9.10.0",
"packageManager": "pnpm@9.11.0",
"engines": {
"node": "^16.10.0 || >=18.0.0"
},

View File

@ -54,7 +54,7 @@
"lodash-es": "4.17.21",
"nitropack": "2.9.7",
"unbuild": "latest",
"vite": "5.4.6",
"vite": "5.4.7",
"vitest": "2.1.1",
"webpack": "5.94.0"
},

View File

@ -86,26 +86,29 @@ export async function loadNuxtModuleInstance (nuxtModule: string | NuxtModule, n
// Import if input is string
if (typeof nuxtModule === 'string') {
const paths = [join(nuxtModule, 'nuxt'), join(nuxtModule, 'module'), nuxtModule, join(nuxt.options.rootDir, nuxtModule)]
let error: unknown
for (const path of paths) {
try {
const src = jiti.esmResolve(path)
nuxtModule = await jiti.import(src) as NuxtModule
// nuxt-module-builder generates a module.json with metadata including the version
const moduleMetadataPath = join(dirname(src), 'module.json')
if (existsSync(moduleMetadataPath)) {
buildTimeModuleMeta = JSON.parse(await fsp.readFile(moduleMetadataPath, 'utf-8'))
for (const parentURL of nuxt.options.modulesDir) {
for (const path of paths) {
try {
const src = jiti.esmResolve(path, { parentURL })
nuxtModule = await jiti.import(src) as NuxtModule
// nuxt-module-builder generates a module.json with metadata including the version
const moduleMetadataPath = join(dirname(src), 'module.json')
if (existsSync(moduleMetadataPath)) {
buildTimeModuleMeta = JSON.parse(await fsp.readFile(moduleMetadataPath, 'utf-8'))
}
break
} catch (error: unknown) {
const code = (error as Error & { code?: string }).code
if (code === 'MODULE_NOT_FOUND' || code === 'ERR_PACKAGE_PATH_NOT_EXPORTED' || code === 'ERR_MODULE_NOT_FOUND' || code === 'ERR_UNSUPPORTED_DIR_IMPORT') {
continue
}
logger.error(`Error while importing module \`${nuxtModule}\`: ${error}`)
throw error
}
break
} catch (_err: unknown) {
error = _err
continue
}
}
if (typeof nuxtModule !== 'function' && error) {
logger.error(`Error while importing module \`${nuxtModule}\`: ${error}`)
throw error
if (typeof nuxtModule !== 'string') { break }
}
}

View File

@ -60,7 +60,7 @@
},
"dependencies": {
"@nuxt/devalue": "^2.0.2",
"@nuxt/devtools": "^1.4.2",
"@nuxt/devtools": "^1.5.0",
"@nuxt/kit": "workspace:*",
"@nuxt/schema": "workspace:*",
"@nuxt/telemetry": "^2.6.0",
@ -69,7 +69,7 @@
"@unhead/shared": "^1.11.6",
"@unhead/ssr": "^1.11.6",
"@unhead/vue": "^1.11.6",
"@vue/shared": "^3.5.6",
"@vue/shared": "^3.5.7",
"acorn": "8.12.1",
"c12": "^1.11.2",
"chokidar": "^3.6.0",
@ -97,7 +97,7 @@
"nitropack": "^2.9.7",
"nuxi": "^3.13.2",
"nypm": "^0.3.11",
"ofetch": "^1.3.4",
"ofetch": "^1.4.0",
"ohash": "^1.1.4",
"pathe": "^1.1.2",
"perfect-debounce": "^1.0.0",
@ -119,7 +119,7 @@
"unplugin-vue-router": "^0.10.8",
"unstorage": "^1.12.0",
"untyped": "^1.4.2",
"vue": "^3.5.6",
"vue": "^3.5.7",
"vue-bundle-renderer": "^2.1.0",
"vue-devtools-stub": "^0.1.0",
"vue-router": "^4.4.5"
@ -130,9 +130,9 @@
"@parcel/watcher": "2.4.1",
"@types/estree": "1.0.6",
"@vitejs/plugin-vue": "5.1.4",
"@vue/compiler-sfc": "3.5.6",
"@vue/compiler-sfc": "3.5.7",
"unbuild": "latest",
"vite": "5.4.6",
"vite": "5.4.7",
"vitest": "2.1.1"
},
"peerDependencies": {

View File

@ -42,20 +42,20 @@
"@unhead/schema": "1.11.6",
"@vitejs/plugin-vue": "5.1.4",
"@vitejs/plugin-vue-jsx": "4.0.1",
"@vue/compiler-core": "3.5.6",
"@vue/compiler-sfc": "3.5.6",
"@vue/compiler-core": "3.5.7",
"@vue/compiler-sfc": "3.5.7",
"@vue/language-core": "2.1.6",
"c12": "1.11.2",
"esbuild-loader": "4.2.2",
"h3": "1.12.0",
"ignore": "6.0.2",
"nitropack": "2.9.7",
"ofetch": "1.3.4",
"ofetch": "1.4.0",
"unbuild": "latest",
"unctx": "2.3.1",
"unenv": "1.10.0",
"vite": "5.4.6",
"vue": "3.5.6",
"vite": "5.4.7",
"vue": "3.5.7",
"vue-bundle-renderer": "2.1.0",
"vue-loader": "17.4.2",
"vue-router": "4.4.5",

View File

@ -32,6 +32,6 @@
"tinyexec": "0.3.0",
"tinyglobby": "0.2.6",
"unocss": "0.62.4",
"vite": "5.4.6"
"vite": "5.4.7"
}
}

View File

@ -29,7 +29,7 @@
"@types/estree": "1.0.6",
"rollup": "4.22.2",
"unbuild": "latest",
"vue": "3.5.6"
"vue": "3.5.7"
},
"dependencies": {
"@nuxt/kit": "workspace:*",
@ -62,7 +62,7 @@
"ufo": "^1.5.4",
"unenv": "^1.10.0",
"unplugin": "^1.14.1",
"vite": "^5.4.6",
"vite": "^5.4.7",
"vite-node": "^2.1.1",
"vite-plugin-checker": "^0.8.0",
"vue-bundle-renderer": "^2.1.0"

View File

@ -27,11 +27,16 @@ export async function resolveCSSOptions (nuxt: Nuxt): Promise<ViteConfig['css']>
const pluginOptions = postcssOptions.plugins[pluginName]
if (!pluginOptions) { continue }
const path = jiti.esmResolve(pluginName)
const pluginFn = (await jiti.import(path)) as (opts: Record<string, any>) => Plugin
if (typeof pluginFn === 'function') {
css.postcss.plugins.push(pluginFn(pluginOptions))
} else {
let pluginFn: ((opts: Record<string, any>) => Plugin) | undefined
for (const parentURL of nuxt.options.modulesDir) {
pluginFn = await jiti.import(pluginName, { parentURL, try: true }) as (opts: Record<string, any>) => Plugin
if (typeof pluginFn === 'function') {
css.postcss.plugins.push(pluginFn(pluginOptions))
break
}
}
if (typeof pluginFn !== 'function') {
console.warn(`[nuxt] could not import postcss plugin \`${pluginName}\`. Please report this as a bug.`)
}
}

View File

@ -77,7 +77,7 @@
"@types/webpack-bundle-analyzer": "4.7.0",
"@types/webpack-hot-middleware": "2.25.9",
"unbuild": "latest",
"vue": "3.5.6"
"vue": "3.5.7"
},
"peerDependencies": {
"vue": "^3.3.4"

View File

@ -49,11 +49,16 @@ export async function getPostcssConfig (nuxt: Nuxt) {
const pluginOptions = postcssOptions.plugins[pluginName]
if (!pluginOptions) { continue }
const path = jiti.esmResolve(pluginName)
const pluginFn = (await jiti.import(path)) as (opts: Record<string, any>) => Plugin
if (typeof pluginFn === 'function') {
plugins.push(pluginFn(pluginOptions))
} else {
let pluginFn: ((opts: Record<string, any>) => Plugin) | undefined
for (const parentURL of nuxt.options.modulesDir) {
pluginFn = await jiti.import(pluginName, { parentURL, try: true }) as (opts: Record<string, any>) => Plugin
if (typeof pluginFn === 'function') {
plugins.push(pluginFn(pluginOptions))
break
}
}
if (typeof pluginFn !== 'function') {
console.warn(`[nuxt] could not import postcss plugin \`${pluginName}\`. Please report this as a bug.`)
}
}

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"212k"`)
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1383k"`)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"1384k"`)
const packages = modules.files
.filter(m => m.endsWith('package.json'))
@ -77,7 +77,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
const serverDir = join(rootDir, '.output-inline/server')
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"560k"`)
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot(`"561k"`)
const modules = await analyzeSizes(['node_modules/**/*'], serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot(`"84.1k"`)