@vitejs/plugin-vue
Advanced tools
Comparing version 4.2.3 to 4.5.1
@@ -14,2 +14,3 @@ import { ViteDevServer, Plugin } from 'vite'; | ||
scoped?: boolean; | ||
id?: string; | ||
} | ||
@@ -25,3 +26,3 @@ declare function parseVueRequest(id: string): { | ||
isProduction?: boolean; | ||
script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins' | 'defineModel' | 'propsDestructure' | 'fs' | 'reactivityTransform'>>; | ||
script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins' | 'globalTypeFiles' | 'defineModel' | 'propsDestructure' | 'fs' | 'reactivityTransform' | 'hoistStatic'>>; | ||
template?: Partial<Pick<SFCTemplateCompileOptions, 'compiler' | 'compilerOptions' | 'preprocessOptions' | 'preprocessCustomRequire' | 'transformAssetUrls'>>; | ||
@@ -46,2 +47,6 @@ style?: Partial<Pick<SFCStyleCompileOptions, 'trim'>>; | ||
* | ||
* @deprecated the Reactivity Transform proposal has been dropped. This | ||
* feature will be removed from Vue core in 3.4. If you intend to continue | ||
* using it, disable this and switch to the [Vue Macros implementation](https://vue-macros.sxzz.moe/features/reactivity-transform.html). | ||
* | ||
* @default false | ||
@@ -65,2 +70,2 @@ */ | ||
export { Options, ResolvedOptions, VueQuery, vuePlugin as default, parseVueRequest }; | ||
export { type Options, type ResolvedOptions, type VueQuery, vuePlugin as default, parseVueRequest }; |
{ | ||
"name": "@vitejs/plugin-vue", | ||
"version": "4.2.3", | ||
"version": "4.5.1", | ||
"license": "MIT", | ||
@@ -14,3 +14,2 @@ "author": "Evan You", | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
@@ -20,8 +19,2 @@ "require": "./dist/index.cjs" | ||
}, | ||
"scripts": { | ||
"dev": "unbuild --stub", | ||
"build": "unbuild && pnpm run patch-cjs", | ||
"patch-cjs": "tsx ../../scripts/patchCJS.ts", | ||
"prepublishOnly": "npm run build" | ||
}, | ||
"engines": { | ||
@@ -40,15 +33,20 @@ "node": "^14.18.0 || >=16.0.0" | ||
"peerDependencies": { | ||
"vite": "^4.0.0", | ||
"vite": "^4.0.0 || ^5.0.0", | ||
"vue": "^3.2.25" | ||
}, | ||
"devDependencies": { | ||
"@jridgewell/gen-mapping": "^0.3.2", | ||
"@jridgewell/trace-mapping": "^0.3.17", | ||
"@jridgewell/gen-mapping": "^0.3.3", | ||
"@jridgewell/trace-mapping": "^0.3.20", | ||
"debug": "^4.3.4", | ||
"rollup": "^3.17.2", | ||
"slash": "^5.0.0", | ||
"source-map": "^0.6.1", | ||
"vite": "^4.3.5", | ||
"vue": "^3.3.0-beta.5" | ||
"rollup": "^3.29.4", | ||
"slash": "^5.1.0", | ||
"source-map-js": "^1.0.2", | ||
"vite": "^4.5.0", | ||
"vue": "^3.3.8" | ||
}, | ||
"scripts": { | ||
"dev": "unbuild --stub", | ||
"build": "unbuild && pnpm run patch-cjs", | ||
"patch-cjs": "tsx ../../scripts/patchCJS.ts" | ||
} | ||
} | ||
} |
@@ -26,3 +26,14 @@ # @vitejs/plugin-vue [![npm](https://img.shields.io/npm/v/@vitejs/plugin-vue.svg)](https://npmjs.com/package/@vitejs/plugin-vue) | ||
// options to pass on to vue/compiler-sfc | ||
script?: Partial<Pick<SFCScriptCompileOptions, 'babelParserPlugins'>> | ||
script?: Partial< | ||
Pick< | ||
SFCScriptCompileOptions, | ||
| 'babelParserPlugins' | ||
| 'globalTypeFiles' | ||
| 'defineModel' | ||
| 'propsDestructure' | ||
| 'fs' | ||
| 'reactivityTransform' | ||
> | ||
> | ||
template?: Partial< | ||
@@ -133,8 +144,11 @@ Pick< | ||
transform(code, id) { | ||
// if .vue file don't have <i18n> block, just return | ||
if (!/vue&type=i18n/.test(id)) { | ||
return | ||
} | ||
// parse yaml | ||
if (/\.ya?ml$/.test(id)) { | ||
code = JSON.stringify(yaml.load(code.trim())) | ||
} | ||
// mount the value on the i18n property of the component instance | ||
return `export default Comp => { | ||
@@ -151,2 +165,26 @@ Comp.i18n = ${code} | ||
Create a file named `Demo.vue`, add `lang="yaml"` to the `<i18n>` blocks, then you can use the syntax of `YAML`: | ||
```vue | ||
<template>Hello</template> | ||
<i18n lang="yaml"> | ||
message: 'world' | ||
fullWord: 'hello world' | ||
</i18n> | ||
``` | ||
`message` is mounted on the i18n property of the component instance, you can use like this: | ||
```vue | ||
<script setup lang="ts"> | ||
import Demo from 'components/Demo.vue' | ||
</script> | ||
<template> | ||
<Demo /> {{ Demo.i18n.message }} | ||
<div>{{ Demo.i18n.fullWord }}</div> | ||
</template> | ||
``` | ||
## Using Vue SFCs as Custom Elements | ||
@@ -153,0 +191,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
183014
8
5513
215