Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
chore: upgrade unplugin to 0.10.x (#8271)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 18, 2022
1 parent 6567ac3 commit e18da78
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 11 additions & 8 deletions packages/nuxt/src/core/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions packages/nuxt/test/auto-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 15 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e18da78

Please sign in to comment.