From e18da780a86cc0cde5cc4db0d9ca1a8cc0fe30d2 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 18 Oct 2022 17:36:06 +0800 Subject: [PATCH] chore: upgrade unplugin to 0.10.x (#8271) --- packages/nuxt/package.json | 2 +- packages/nuxt/src/core/nitro.ts | 19 +++++++++++-------- packages/nuxt/test/auto-imports.test.ts | 5 +++-- packages/vite/package.json | 2 +- packages/webpack/package.json | 2 +- pnpm-lock.yaml | 21 +++++++++++++++------ 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 9442ab0d19..954894d968 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -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", diff --git a/packages/nuxt/src/core/nitro.ts b/packages/nuxt/src/core/nitro.ts index 58310c1226..c8e59f8717 100644 --- a/packages/nuxt/src/core/nitro.ts +++ b/packages/nuxt/src/core/nitro.ts @@ -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) diff --git a/packages/nuxt/test/auto-imports.test.ts b/packages/nuxt/test/auto-imports.test.ts index de4a5c10c4..eaa33a5fa9 100644 --- a/packages/nuxt/test/auto-imports.test.ts +++ b/packages/nuxt/test/auto-imports.test.ts @@ -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 } diff --git a/packages/vite/package.json b/packages/vite/package.json index c6a43cac40..d9459926ae 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -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", diff --git a/packages/webpack/package.json b/packages/webpack/package.json index f26da4d1fa..f400c1750e 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 399ea7d3fb..27ed846a43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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: