chore: upgrade unplugin to 0.10.x (#8271)

This commit is contained in:
Anthony Fu 2022-10-18 17:36:06 +08:00 committed by GitHub
parent 6567ac375d
commit e18da780a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 19 deletions

View File

@ -71,7 +71,7 @@
"unctx": "^2.0.2",
"unenv": "^0.6.2",
"unimport": "^0.6.8",
"unplugin": "^0.9.6",
"unplugin": "^0.10.0",
"untyped": "^0.5.0",
"vue": "^3.2.41",
"vue-bundle-renderer": "^0.4.3",

View File

@ -7,6 +7,7 @@ import { resolvePath } from '@nuxt/kit'
import defu from 'defu'
import fsExtra from 'fs-extra'
import { dynamicEventHandler } from 'h3'
import type { Plugin } from 'rollup'
import { distDir } from '../dirs'
import { ImportProtectionPlugin } from './plugins/import-protection'
@ -121,14 +122,16 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
}
// Register nuxt protection patterns
nitroConfig.rollupConfig!.plugins!.push(ImportProtectionPlugin.rollup({
rootDir: nuxt.options.rootDir,
patterns: [
...['#app', /^#build(\/|$)/]
.map(p => [p, 'Vue app aliases are not allowed in server routes.']) as [RegExp | string, string][]
],
exclude: [/core[\\/]runtime[\\/]nitro[\\/]renderer/]
}))
nitroConfig.rollupConfig!.plugins!.push(
ImportProtectionPlugin.rollup({
rootDir: nuxt.options.rootDir,
patterns: [
...['#app', /^#build(\/|$)/]
.map(p => [p, 'Vue app aliases are not allowed in server routes.']) as [RegExp | string, string][]
],
exclude: [/core[\\/]runtime[\\/]nitro[\\/]renderer/]
}) as Plugin
)
// Extend nitro config with hook
await nuxt.callHook('nitro:config', nitroConfig)

View File

@ -4,6 +4,7 @@ import { join } from 'pathe'
import { createCommonJS, findExports } from 'mlly'
import * as VueFunctions from 'vue'
import { createUnimport, Import } from 'unimport'
import { Plugin } from 'vite'
import { TransformPlugin } from '../src/imports/transform'
import { defaultPresets } from '../src/imports/presets'
@ -18,9 +19,9 @@ describe('imports:transform', () => {
imports
})
const transformPlugin = TransformPlugin.raw({ ctx, options: { transform: { exclude: [/node_modules/] } } }, { framework: 'rollup' })
const transformPlugin = TransformPlugin.raw({ ctx, options: { transform: { exclude: [/node_modules/] } } }, { framework: 'rollup' }) as Plugin
const transform = async (source: string) => {
const result = await transformPlugin.transform!.call({ error: null, warn: null } as any, source, '')
const result = await (transformPlugin.transform! as Function).call({ error: null, warn: null } as any, source, '')
return typeof result === 'string' ? result : result?.code
}

View File

@ -47,7 +47,7 @@
"rollup": "^2.79.1",
"rollup-plugin-visualizer": "^5.8.3",
"ufo": "^0.8.6",
"unplugin": "^0.9.6",
"unplugin": "^0.10.0",
"vite": "~3.1.8",
"vite-node": "^0.24.3",
"vite-plugin-checker": "^0.5.1",

View File

@ -45,7 +45,7 @@
"style-resources-loader": "^1.5.0",
"time-fix-plugin": "^2.0.7",
"ufo": "^0.8.6",
"unplugin": "^0.9.6",
"unplugin": "^0.10.0",
"url-loader": "^4.1.1",
"vue-bundle-renderer": "^0.4.3",
"vue-loader": "^17.0.0",

View File

@ -443,7 +443,7 @@ importers:
unctx: ^2.0.2
unenv: ^0.6.2
unimport: ^0.6.8
unplugin: ^0.9.6
unplugin: ^0.10.0
untyped: ^0.5.0
vue: 3.2.41
vue-bundle-renderer: ^0.4.3
@ -486,7 +486,7 @@ importers:
unctx: 2.0.2
unenv: 0.6.2
unimport: 0.6.8
unplugin: 0.9.6
unplugin: 0.10.0
untyped: 0.5.0
vue: 3.2.41
vue-bundle-renderer: 0.4.3
@ -601,7 +601,7 @@ importers:
rollup-plugin-visualizer: ^5.8.3
ufo: ^0.8.6
unbuild: ^0.9.4
unplugin: ^0.9.6
unplugin: ^0.10.0
vite: ^3.1.8
vite-node: ^0.24.3
vite-plugin-checker: ^0.5.1
@ -636,7 +636,7 @@ importers:
rollup: 2.79.1
rollup-plugin-visualizer: 5.8.3_rollup@2.79.1
ufo: 0.8.6
unplugin: 0.9.6
unplugin: 0.10.0
vite: 3.1.8
vite-node: 0.24.3
vite-plugin-checker: 0.5.1_vite@3.1.8
@ -686,7 +686,7 @@ importers:
time-fix-plugin: ^2.0.7
ufo: ^0.8.6
unbuild: ^0.9.4
unplugin: ^0.9.6
unplugin: ^0.10.0
url-loader: ^4.1.1
vue: 3.2.41
vue-bundle-renderer: ^0.4.3
@ -727,7 +727,7 @@ importers:
style-resources-loader: 1.5.0_webpack@5.74.0
time-fix-plugin: 2.0.7_webpack@5.74.0
ufo: 0.8.6
unplugin: 0.9.6
unplugin: 0.10.0
url-loader: 4.1.1_u4acmn7fe6yqgbrqzialkgh5lu
vue-bundle-renderer: 0.4.3
vue-loader: 17.0.0_webpack@5.74.0
@ -8394,6 +8394,15 @@ packages:
- vite
dev: true
/unplugin/0.10.0:
resolution: {integrity: sha512-QIoQDNxTceO8QneUMQc96qabJnPVijU9SnaWWAH60HqpkCQSFXTcDAcr8qM4Y7Nq8Q3NafyX3lG5S1g62+KD6g==}
dependencies:
acorn: 8.8.0
chokidar: 3.5.3
webpack-sources: 3.2.3
webpack-virtual-modules: 0.4.5
dev: false
/unplugin/0.9.6:
resolution: {integrity: sha512-YYLtfoNiie/lxswy1GOsKXgnLJTE27la/PeCGznSItk+8METYZErO+zzV9KQ/hXhPwzIJsfJ4s0m1Rl7ZCWZ4Q==}
dependencies: