feat: init
This commit is contained in:
21
node_modules/@vitejs/plugin-vue-jsx/LICENSE
generated
vendored
Normal file
21
node_modules/@vitejs/plugin-vue-jsx/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
109
node_modules/@vitejs/plugin-vue-jsx/README.md
generated
vendored
Normal file
109
node_modules/@vitejs/plugin-vue-jsx/README.md
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
# @vitejs/plugin-vue-jsx [](https://npmjs.com/package/@vitejs/plugin-vue-jsx)
|
||||
|
||||
Provides Vue 3 JSX & TSX support with HMR.
|
||||
|
||||
```js
|
||||
// vite.config.js
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vueJsx({
|
||||
// options are passed on to @vue/babel-plugin-jsx
|
||||
}),
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### include
|
||||
|
||||
Type: `(string | RegExp)[] | string | RegExp | null`
|
||||
|
||||
Default: `/\.[jt]sx$/`
|
||||
|
||||
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files the plugin should operate on.
|
||||
|
||||
### exclude
|
||||
|
||||
Type: `(string | RegExp)[] | string | RegExp | null`
|
||||
|
||||
Default: `undefined`
|
||||
|
||||
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files to be ignored by the plugin.
|
||||
|
||||
> See [@vue/babel-plugin-jsx](https://github.com/vuejs/jsx-next) for other options.
|
||||
|
||||
### defineComponentName
|
||||
|
||||
Type: `string[]`
|
||||
|
||||
Default: `['defineComponent']`
|
||||
|
||||
The name of the function to be used for defining components. This is useful when you have a custom `defineComponent` function.
|
||||
|
||||
### tsTransform
|
||||
|
||||
Type: `'babel' | 'built-in'`
|
||||
|
||||
Default: `'babel'`
|
||||
|
||||
Defines how `typescript` transformation is handled for `.tsx` files.
|
||||
|
||||
`'babel'` - `typescript` transformation is handled by `@babel/plugin-transform-typescript` during `babel` invocation for JSX transformation.
|
||||
|
||||
`'built-in'` - `babel` is invoked only for JSX transformation and then `typescript` transformation is handled by the same toolchain used for `.ts` files (currently `esbuild`).
|
||||
|
||||
### babelPlugins
|
||||
|
||||
Type: `any[]`
|
||||
|
||||
Default: `undefined`
|
||||
|
||||
Provide additional plugins for `babel` invocation for JSX transformation.
|
||||
|
||||
### tsPluginOptions
|
||||
|
||||
Type: `any`
|
||||
|
||||
Default: `undefined`
|
||||
|
||||
Defines options for `@babel/plugin-transform-typescript` plugin.
|
||||
|
||||
## HMR Detection
|
||||
|
||||
This plugin supports HMR of Vue JSX components. The detection requirements are:
|
||||
|
||||
- The component must be exported.
|
||||
- The component must be declared by calling `defineComponent` or the name specified in `defineComponentName` via a root-level statement, either variable declaration or export declaration.
|
||||
|
||||
### Supported patterns
|
||||
|
||||
```jsx
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
// named exports w/ variable declaration: ok
|
||||
export const Foo = defineComponent({})
|
||||
|
||||
// named exports referencing variable declaration: ok
|
||||
const Bar = defineComponent({ render() { return <div>Test</div> }})
|
||||
export { Bar }
|
||||
|
||||
// default export call: ok
|
||||
export default defineComponent({ render() { return <div>Test</div> }})
|
||||
|
||||
// default export referencing variable declaration: ok
|
||||
const Baz = defineComponent({ render() { return <div>Test</div> }})
|
||||
export default Baz
|
||||
```
|
||||
|
||||
### Non-supported patterns
|
||||
|
||||
```jsx
|
||||
// not using `defineComponent` call
|
||||
export const Bar = { ... }
|
||||
|
||||
// not exported
|
||||
const Foo = defineComponent(...)
|
||||
```
|
||||
22
node_modules/@vitejs/plugin-vue-jsx/dist/index.d.mts
generated
vendored
Normal file
22
node_modules/@vitejs/plugin-vue-jsx/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { VueJSXPluginOptions } from "@vue/babel-plugin-jsx";
|
||||
import { FilterPattern, Plugin } from "vite";
|
||||
|
||||
//#region src/types.d.ts
|
||||
interface FilterOptions {
|
||||
include?: FilterPattern;
|
||||
exclude?: FilterPattern;
|
||||
}
|
||||
interface Options extends VueJSXPluginOptions, FilterOptions {
|
||||
babelPlugins?: any[];
|
||||
/** @default ['defineComponent'] */
|
||||
defineComponentName?: string[];
|
||||
tsPluginOptions?: any;
|
||||
/** @default 'babel' */
|
||||
tsTransform?: 'babel' | 'built-in';
|
||||
}
|
||||
//#endregion
|
||||
//#region src/index.d.ts
|
||||
declare function vueJsxPlugin(options?: Options): Plugin;
|
||||
declare function vueJsxPluginCjs(this: unknown, options: Options): Plugin;
|
||||
//#endregion
|
||||
export { FilterOptions, Options, vueJsxPlugin as default, vueJsxPluginCjs as "module.exports" };
|
||||
209
node_modules/@vitejs/plugin-vue-jsx/dist/index.mjs
generated
vendored
Normal file
209
node_modules/@vitejs/plugin-vue-jsx/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
import crypto from "node:crypto";
|
||||
import path from "node:path";
|
||||
import * as babel from "@babel/core";
|
||||
import { types } from "@babel/core";
|
||||
import jsx from "@vue/babel-plugin-jsx";
|
||||
import { createFilter, normalizePath } from "vite";
|
||||
import { exactRegex, makeIdFiltersToMatchWithQuery } from "@rolldown/pluginutils";
|
||||
|
||||
//#region src/index.ts
|
||||
const ssrRegisterHelperId = "/__vue-jsx-ssr-register-helper";
|
||||
const ssrRegisterHelperCode = `import { useSSRContext } from "vue"\nexport const ssrRegisterHelper = ${ssrRegisterHelper.toString()}`;
|
||||
/**
|
||||
* This function is serialized with toString() and evaluated as a virtual
|
||||
* module during SSR
|
||||
*/
|
||||
function ssrRegisterHelper(comp, filename) {
|
||||
const setup = comp.setup;
|
||||
comp.setup = (props, ctx) => {
|
||||
const ssrContext = useSSRContext();
|
||||
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add(filename);
|
||||
if (setup) return setup(props, ctx);
|
||||
};
|
||||
}
|
||||
function vueJsxPlugin(options = {}) {
|
||||
let root = "";
|
||||
let needHmr = false;
|
||||
let needSourceMap = true;
|
||||
const { include = /\.[jt]sx$/, exclude, babelPlugins = [], defineComponentName = ["defineComponent"], tsPluginOptions = {}, tsTransform, ...babelPluginOptions } = options;
|
||||
const filter = createFilter(include, exclude);
|
||||
return {
|
||||
name: "vite:vue-jsx",
|
||||
config(config) {
|
||||
const parseDefine = (v) => {
|
||||
try {
|
||||
return typeof v === "string" ? JSON.parse(v) : v;
|
||||
} catch (err) {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
const isRolldownVite = this && "rolldownVersion" in this.meta;
|
||||
return {
|
||||
[isRolldownVite ? "oxc" : "esbuild"]: tsTransform === "built-in" ? { exclude: /\.jsx?$/ } : { include: /\.ts$/ },
|
||||
define: {
|
||||
__VUE_OPTIONS_API__: parseDefine(config.define?.__VUE_OPTIONS_API__) ?? true,
|
||||
__VUE_PROD_DEVTOOLS__: parseDefine(config.define?.__VUE_PROD_DEVTOOLS__) ?? false,
|
||||
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: parseDefine(config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__) ?? false
|
||||
},
|
||||
optimizeDeps: isRolldownVite ? { rolldownOptions: { transform: { jsx: "preserve" } } } : {}
|
||||
};
|
||||
},
|
||||
configResolved(config) {
|
||||
needHmr = config.command === "serve" && !config.isProduction;
|
||||
needSourceMap = config.command === "serve" || !!config.build.sourcemap;
|
||||
root = config.root;
|
||||
},
|
||||
resolveId: {
|
||||
filter: { id: exactRegex(ssrRegisterHelperId) },
|
||||
handler(id) {
|
||||
if (id === ssrRegisterHelperId) return id;
|
||||
}
|
||||
},
|
||||
load: {
|
||||
filter: { id: exactRegex(ssrRegisterHelperId) },
|
||||
handler(id) {
|
||||
if (id === ssrRegisterHelperId) return ssrRegisterHelperCode;
|
||||
}
|
||||
},
|
||||
transform: {
|
||||
order: tsTransform === "built-in" ? "pre" : void 0,
|
||||
filter: { id: {
|
||||
include: include ? makeIdFiltersToMatchWithQuery(include) : void 0,
|
||||
exclude: exclude ? makeIdFiltersToMatchWithQuery(exclude) : void 0
|
||||
} },
|
||||
async handler(code, id, opt) {
|
||||
const ssr = opt?.ssr === true;
|
||||
const [filepath] = id.split("?");
|
||||
if (filter(id) || filter(filepath)) {
|
||||
const plugins = [[jsx, babelPluginOptions], ...babelPlugins];
|
||||
if (id.endsWith(".tsx") || filepath.endsWith(".tsx")) if (tsTransform === "built-in") plugins.push([await import("@babel/plugin-syntax-typescript").then((r) => r.default), { isTSX: true }]);
|
||||
else plugins.push([await import("@babel/plugin-transform-typescript").then((r) => r.default), {
|
||||
...tsPluginOptions,
|
||||
isTSX: true,
|
||||
allowExtensions: true
|
||||
}]);
|
||||
if (!ssr && !needHmr) plugins.push(() => {
|
||||
return { visitor: { CallExpression: { enter(_path) {
|
||||
if (isDefineComponentCall(_path.node, defineComponentName)) {
|
||||
const callee = _path.node.callee;
|
||||
callee.name = `/* @__PURE__ */ ${callee.name}`;
|
||||
}
|
||||
} } } };
|
||||
});
|
||||
else plugins.push(() => {
|
||||
return { visitor: { ExportDefaultDeclaration: { enter(_path) {
|
||||
const unwrappedDeclaration = unwrapTypeAssertion(_path.node.declaration);
|
||||
if (isDefineComponentCall(unwrappedDeclaration, defineComponentName)) {
|
||||
const declaration = unwrappedDeclaration;
|
||||
const nodesPath = _path.replaceWithMultiple([types.variableDeclaration("const", [types.variableDeclarator(types.identifier("__default__"), types.callExpression(declaration.callee, declaration.arguments))]), types.exportDefaultDeclaration(types.identifier("__default__"))]);
|
||||
_path.scope.registerDeclaration(nodesPath[0]);
|
||||
}
|
||||
} } } };
|
||||
});
|
||||
const result = babel.transformSync(code, {
|
||||
babelrc: false,
|
||||
ast: true,
|
||||
plugins,
|
||||
sourceMaps: needSourceMap,
|
||||
sourceFileName: id,
|
||||
configFile: false
|
||||
});
|
||||
if (!ssr && !needHmr) {
|
||||
if (!result.code) return;
|
||||
return {
|
||||
code: result.code,
|
||||
map: result.map
|
||||
};
|
||||
}
|
||||
const declaredComponents = [];
|
||||
const hotComponents = [];
|
||||
for (const node of result.ast.program.body) {
|
||||
if (node.type === "VariableDeclaration") {
|
||||
const names = parseComponentDecls(node, defineComponentName);
|
||||
if (names.length) declaredComponents.push(...names);
|
||||
}
|
||||
if (node.type === "ExportNamedDeclaration") {
|
||||
if (node.declaration && node.declaration.type === "VariableDeclaration") hotComponents.push(...parseComponentDecls(node.declaration, defineComponentName).map((name) => ({
|
||||
local: name,
|
||||
exported: name,
|
||||
id: getHash(id + name)
|
||||
})));
|
||||
else if (node.specifiers.length) {
|
||||
for (const spec of node.specifiers) if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") {
|
||||
if (declaredComponents.find((name) => name === spec.local.name)) hotComponents.push({
|
||||
local: spec.local.name,
|
||||
exported: spec.exported.name,
|
||||
id: getHash(id + spec.exported.name)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node.type === "ExportDefaultDeclaration") {
|
||||
if (node.declaration.type === "Identifier") {
|
||||
const _name = node.declaration.name;
|
||||
if (declaredComponents.find((name) => name === _name)) hotComponents.push({
|
||||
local: _name,
|
||||
exported: "default",
|
||||
id: getHash(id + "default")
|
||||
});
|
||||
} else if (isDefineComponentCall(unwrapTypeAssertion(node.declaration), defineComponentName)) hotComponents.push({
|
||||
local: "__default__",
|
||||
exported: "default",
|
||||
id: getHash(id + "default")
|
||||
});
|
||||
}
|
||||
}
|
||||
if (hotComponents.length) {
|
||||
if (needHmr && !ssr && !/\?vue&type=script/.test(id)) {
|
||||
let code = result.code;
|
||||
let callbackCode = ``;
|
||||
for (const { local, exported, id } of hotComponents) {
|
||||
code += `\n${local}.__hmrId = "${id}"\n__VUE_HMR_RUNTIME__.createRecord("${id}", ${local})`;
|
||||
callbackCode += `\n__VUE_HMR_RUNTIME__.reload("${id}", __${exported})`;
|
||||
}
|
||||
const newCompNames = hotComponents.map((c) => `${c.exported}: __${c.exported}`).join(",");
|
||||
code += `\nimport.meta.hot.accept(({${newCompNames}}) => {${callbackCode}\n})`;
|
||||
result.code = code;
|
||||
}
|
||||
if (ssr) {
|
||||
const normalizedId = normalizePath(path.relative(root, id));
|
||||
let ssrInjectCode = `\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"\nconst __moduleId = ${JSON.stringify(normalizedId)}`;
|
||||
for (const { local } of hotComponents) ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)`;
|
||||
result.code += ssrInjectCode;
|
||||
}
|
||||
}
|
||||
if (!result.code) return;
|
||||
return {
|
||||
code: result.code,
|
||||
map: result.map
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function parseComponentDecls(node, fnNames) {
|
||||
const names = [];
|
||||
for (const decl of node.declarations) if (decl.id.type === "Identifier" && isDefineComponentCall(unwrapTypeAssertion(decl.init), fnNames)) names.push(decl.id.name);
|
||||
return names;
|
||||
}
|
||||
function isDefineComponentCall(node, names) {
|
||||
return node && node.type === "CallExpression" && node.callee.type === "Identifier" && names.includes(node.callee.name);
|
||||
}
|
||||
function unwrapTypeAssertion(node) {
|
||||
if (!node) return node;
|
||||
let current = node;
|
||||
while (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSTypeAssertion") current = current.expression;
|
||||
return current;
|
||||
}
|
||||
function getHash(text) {
|
||||
return crypto.hash("sha256", text, "hex").substring(0, 8);
|
||||
}
|
||||
var src_default = vueJsxPlugin;
|
||||
function vueJsxPluginCjs(options) {
|
||||
return vueJsxPlugin.call(this, options);
|
||||
}
|
||||
Object.assign(vueJsxPluginCjs, { default: vueJsxPluginCjs });
|
||||
|
||||
//#endregion
|
||||
export { src_default as default, vueJsxPluginCjs as "module.exports" };
|
||||
67
node_modules/@vitejs/plugin-vue-jsx/package.json
generated
vendored
Normal file
67
node_modules/@vitejs/plugin-vue-jsx/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "@vitejs/plugin-vue-jsx",
|
||||
"version": "5.1.4",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "Evan You",
|
||||
"description": "Provides Vue 3 JSX & TSX support with HMR.",
|
||||
"keywords": [
|
||||
"vite",
|
||||
"vite-plugin",
|
||||
"vue"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"exports": {
|
||||
".": "./dist/index.mjs",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitejs/vite-plugin-vue.git",
|
||||
"directory": "packages/plugin-vue-jsx"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitejs/vite-plugin-vue/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.29.0",
|
||||
"@babel/plugin-syntax-typescript": "^7.28.6",
|
||||
"@babel/plugin-transform-typescript": "^7.28.6",
|
||||
"@rolldown/pluginutils": "^1.0.0-rc.2",
|
||||
"@vue/babel-plugin-jsx": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsdown": "^0.20.1",
|
||||
"vite": "^7.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0",
|
||||
"vue": "^3.0.0"
|
||||
},
|
||||
"tsdown": {
|
||||
"dts": {
|
||||
"tsgo": true
|
||||
}
|
||||
},
|
||||
"compatiblePackages": {
|
||||
"schemaVersion": 1,
|
||||
"rolldown": {
|
||||
"type": "incompatible",
|
||||
"reason": "Uses Vite-specific APIs"
|
||||
},
|
||||
"rollup": {
|
||||
"type": "incompatible",
|
||||
"reason": "Uses Vite-specific APIs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsdown --watch",
|
||||
"build": "tsdown"
|
||||
}
|
||||
}
|
||||
21
node_modules/@vitejs/plugin-vue/LICENSE
generated
vendored
Normal file
21
node_modules/@vitejs/plugin-vue/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
278
node_modules/@vitejs/plugin-vue/README.md
generated
vendored
Normal file
278
node_modules/@vitejs/plugin-vue/README.md
generated
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
# @vitejs/plugin-vue [](https://npmjs.com/package/@vitejs/plugin-vue)
|
||||
|
||||
> Note: as of `vue` 3.2.13+ and `@vitejs/plugin-vue` 1.9.0+, `@vue/compiler-sfc` is no longer required as a peer dependency.
|
||||
|
||||
```js
|
||||
// vite.config.js
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default {
|
||||
plugins: [vue()],
|
||||
}
|
||||
```
|
||||
|
||||
For JSX / TSX support, [`@vitejs/plugin-vue-jsx`](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue-jsx) is also needed.
|
||||
|
||||
## Options
|
||||
|
||||
```ts
|
||||
export interface Options {
|
||||
include?: string | RegExp | (string | RegExp)[]
|
||||
exclude?: string | RegExp | (string | RegExp)[]
|
||||
|
||||
isProduction?: boolean
|
||||
|
||||
/**
|
||||
* Requires @vitejs/plugin-vue@^5.1.0
|
||||
*/
|
||||
features?: {
|
||||
/**
|
||||
* Enable reactive destructure for `defineProps`.
|
||||
* - Available in Vue 3.4 and later.
|
||||
* - **default:** `false` in Vue 3.4 (**experimental**), `true` in Vue 3.5+
|
||||
*/
|
||||
propsDestructure?: boolean
|
||||
/**
|
||||
* Transform Vue SFCs into custom elements.
|
||||
* - `true`: all `*.vue` imports are converted into custom elements
|
||||
* - `string | RegExp`: matched files are converted into custom elements
|
||||
* - **default:** /\.ce\.vue$/
|
||||
*/
|
||||
customElement?: boolean | string | RegExp | (string | RegExp)[]
|
||||
/**
|
||||
* Set to `false` to disable Options API support and allow related code in
|
||||
* Vue core to be dropped via dead-code elimination in production builds,
|
||||
* resulting in smaller bundles.
|
||||
* - **default:** `true`
|
||||
*/
|
||||
optionsAPI?: boolean
|
||||
/**
|
||||
* Set to `true` to enable devtools support in production builds.
|
||||
* Results in slightly larger bundles.
|
||||
* - **default:** `false`
|
||||
*/
|
||||
prodDevtools?: boolean
|
||||
/**
|
||||
* Set to `true` to enable detailed information for hydration mismatch
|
||||
* errors in production builds. Results in slightly larger bundles.
|
||||
* - **default:** `false`
|
||||
*/
|
||||
prodHydrationMismatchDetails?: boolean
|
||||
/**
|
||||
* Customize the component ID generation strategy.
|
||||
* - `'filepath'`: hash the file path (relative to the project root)
|
||||
* - `'filepath-source'`: hash the file path and the source code
|
||||
* - `function`: custom function that takes the file path, source code,
|
||||
* whether in production mode, and the default hash function as arguments
|
||||
* - **default:** `'filepath'` in development, `'filepath-source'` in production
|
||||
*/
|
||||
componentIdGenerator?:
|
||||
| 'filepath'
|
||||
| 'filepath-source'
|
||||
| ((
|
||||
filepath: string,
|
||||
source: string,
|
||||
isProduction: boolean | undefined,
|
||||
getHash: (text: string) => string,
|
||||
) => string)
|
||||
}
|
||||
|
||||
// `script`, `template` and `style` are lower-level compiler options
|
||||
// to pass on to respective APIs of `vue/compiler-sfc`
|
||||
|
||||
script?: Partial<
|
||||
Omit<
|
||||
SFCScriptCompileOptions,
|
||||
| 'id'
|
||||
| 'isProd'
|
||||
| 'inlineTemplate'
|
||||
| 'templateOptions'
|
||||
| 'sourceMap'
|
||||
| 'genDefaultAs'
|
||||
| 'customElement'
|
||||
>
|
||||
>
|
||||
|
||||
template?: Partial<
|
||||
Omit<
|
||||
SFCTemplateCompileOptions,
|
||||
| 'id'
|
||||
| 'source'
|
||||
| 'ast'
|
||||
| 'filename'
|
||||
| 'scoped'
|
||||
| 'slotted'
|
||||
| 'isProd'
|
||||
| 'inMap'
|
||||
| 'ssr'
|
||||
| 'ssrCssVars'
|
||||
| 'preprocessLang'
|
||||
>
|
||||
>
|
||||
|
||||
style?: Partial<
|
||||
Omit<
|
||||
SFCStyleCompileOptions,
|
||||
| 'filename'
|
||||
| 'id'
|
||||
| 'isProd'
|
||||
| 'source'
|
||||
| 'scoped'
|
||||
| 'cssDevSourcemap'
|
||||
| 'postcssOptions'
|
||||
| 'map'
|
||||
| 'postcssPlugins'
|
||||
| 'preprocessCustomRequire'
|
||||
| 'preprocessLang'
|
||||
| 'preprocessOptions'
|
||||
>
|
||||
>
|
||||
|
||||
/**
|
||||
* Use custom compiler-sfc instance. Can be used to force a specific version.
|
||||
*/
|
||||
compiler?: typeof _compiler
|
||||
|
||||
/**
|
||||
* @deprecated moved to `features.customElement`.
|
||||
*/
|
||||
customElements?: boolean | string | RegExp | (string | RegExp)[]
|
||||
}
|
||||
```
|
||||
|
||||
## Asset URL handling
|
||||
|
||||
When `@vitejs/plugin-vue` compiles the `<template>` blocks in SFCs, it also converts any encountered asset URLs into ESM imports.
|
||||
|
||||
For example, the following template snippet:
|
||||
|
||||
```vue
|
||||
<img src="../image.png" />
|
||||
```
|
||||
|
||||
Is the same as:
|
||||
|
||||
```vue
|
||||
<script setup>
|
||||
import _imports_0 from '../image.png'
|
||||
</script>
|
||||
|
||||
<img :src="_imports_0" />
|
||||
```
|
||||
|
||||
By default the following tag/attribute combinations are transformed, and can be configured using the `template.transformAssetUrls` option.
|
||||
|
||||
```js
|
||||
{
|
||||
video: ['src', 'poster'],
|
||||
source: ['src'],
|
||||
img: ['src'],
|
||||
image: ['xlink:href', 'href'],
|
||||
use: ['xlink:href', 'href']
|
||||
}
|
||||
```
|
||||
|
||||
Note that only attribute values that are static strings are transformed. Otherwise, you'd need to import the asset manually, e.g. `import imgUrl from '../image.png'`.
|
||||
|
||||
## Example for passing options to `vue/compiler-sfc`:
|
||||
|
||||
```ts
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
vue({
|
||||
template: {
|
||||
compilerOptions: {
|
||||
// ...
|
||||
},
|
||||
transformAssetUrls: {
|
||||
// ...
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
## Example for transforming custom blocks
|
||||
|
||||
```ts
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import yaml from 'js-yaml'
|
||||
|
||||
const vueI18nPlugin = {
|
||||
name: 'vue-i18n',
|
||||
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 => {
|
||||
Comp.i18n = ${code}
|
||||
}`
|
||||
},
|
||||
}
|
||||
|
||||
export default {
|
||||
plugins: [vue(), vueI18nPlugin],
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
> Requires `vue@^3.2.0` & `@vitejs/plugin-vue@^1.4.0`
|
||||
|
||||
Vue 3.2 introduces the `defineCustomElement` method, which works with SFCs. By default, `<style>` tags inside SFCs are extracted and merged into CSS files during build. However when shipping a library of custom elements, it may be desirable to inline the styles as JavaScript strings and inject them into the custom elements' shadow root instead.
|
||||
|
||||
Starting in 1.4.0, files ending with `*.ce.vue` will be compiled in "custom elements" mode: its `<style>` tags are compiled into inlined CSS strings and attached to the component as its `styles` property:
|
||||
|
||||
```js
|
||||
import { defineCustomElement } from 'vue'
|
||||
import Example from './Example.ce.vue'
|
||||
|
||||
console.log(Example.styles) // ['/* css content */']
|
||||
|
||||
// register
|
||||
customElements.define('my-example', defineCustomElement(Example))
|
||||
```
|
||||
|
||||
Note in custom elements mode there is no need to use `<style scoped>` since the CSS is already scoped inside the shadow DOM.
|
||||
|
||||
The `customElement` plugin option can be used to configure the behavior:
|
||||
|
||||
- `{ customElement: true }` will import all `*.vue` files in custom element mode.
|
||||
- Use a string or regex pattern to change how files should be loaded as Custom Elements (this check is applied after `include` and `exclude` matches).
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
120
node_modules/@vitejs/plugin-vue/dist/index.d.mts
generated
vendored
Normal file
120
node_modules/@vitejs/plugin-vue/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
import { Plugin, ViteDevServer } from "vite";
|
||||
import * as _compiler from "vue/compiler-sfc";
|
||||
import { SFCScriptCompileOptions, SFCStyleCompileOptions, SFCTemplateCompileOptions } from "vue/compiler-sfc";
|
||||
|
||||
//#region src/utils/query.d.ts
|
||||
interface VueQuery {
|
||||
vue?: boolean;
|
||||
src?: string;
|
||||
type?: 'script' | 'template' | 'style' | 'custom';
|
||||
index?: number;
|
||||
lang?: string;
|
||||
raw?: boolean;
|
||||
url?: boolean;
|
||||
scoped?: boolean;
|
||||
id?: string;
|
||||
}
|
||||
declare function parseVueRequest(id: string): {
|
||||
filename: string;
|
||||
query: VueQuery;
|
||||
};
|
||||
//#endregion
|
||||
//#region src/index.d.ts
|
||||
interface Options {
|
||||
include?: string | RegExp | (string | RegExp)[];
|
||||
exclude?: string | RegExp | (string | RegExp)[];
|
||||
/**
|
||||
* In Vite, this option follows Vite's config.
|
||||
*/
|
||||
isProduction?: boolean;
|
||||
script?: Partial<Omit<SFCScriptCompileOptions, 'id' | 'isProd' | 'inlineTemplate' | 'templateOptions' | 'sourceMap' | 'genDefaultAs' | 'customElement' | 'defineModel' | 'propsDestructure'>> & {
|
||||
/**
|
||||
* @deprecated defineModel is now a stable feature and always enabled if
|
||||
* using Vue 3.4 or above.
|
||||
*/
|
||||
defineModel?: boolean;
|
||||
/**
|
||||
* @deprecated moved to `features.propsDestructure`.
|
||||
*/
|
||||
propsDestructure?: boolean;
|
||||
};
|
||||
template?: Partial<Omit<SFCTemplateCompileOptions, 'id' | 'source' | 'ast' | 'filename' | 'scoped' | 'slotted' | 'isProd' | 'inMap' | 'ssr' | 'ssrCssVars' | 'preprocessLang'>>;
|
||||
style?: Partial<Omit<SFCStyleCompileOptions, 'filename' | 'id' | 'isProd' | 'source' | 'scoped' | 'cssDevSourcemap' | 'postcssOptions' | 'map' | 'postcssPlugins' | 'preprocessCustomRequire' | 'preprocessLang' | 'preprocessOptions'>>;
|
||||
/**
|
||||
* Use custom compiler-sfc instance. Can be used to force a specific version.
|
||||
*/
|
||||
compiler?: typeof _compiler;
|
||||
/**
|
||||
* Requires @vitejs/plugin-vue@^5.1.0
|
||||
*/
|
||||
features?: {
|
||||
/**
|
||||
* Enable reactive destructure for `defineProps`.
|
||||
* - Available in Vue 3.4 and later.
|
||||
* - **default:** `false` in Vue 3.4 (**experimental**), `true` in Vue 3.5+
|
||||
*/
|
||||
propsDestructure?: boolean;
|
||||
/**
|
||||
* Transform Vue SFCs into custom elements.
|
||||
* - `true`: all `*.vue` imports are converted into custom elements
|
||||
* - `string | RegExp`: matched files are converted into custom elements
|
||||
* - **default:** /\.ce\.vue$/
|
||||
*/
|
||||
customElement?: boolean | string | RegExp | (string | RegExp)[];
|
||||
/**
|
||||
* Set to `false` to disable Options API support and allow related code in
|
||||
* Vue core to be dropped via dead-code elimination in production builds,
|
||||
* resulting in smaller bundles.
|
||||
* - **default:** `true`
|
||||
*/
|
||||
optionsAPI?: boolean;
|
||||
/**
|
||||
* Set to `true` to enable devtools support in production builds.
|
||||
* Results in slightly larger bundles.
|
||||
* - **default:** `false`
|
||||
*/
|
||||
prodDevtools?: boolean;
|
||||
/**
|
||||
* Set to `true` to enable detailed information for hydration mismatch
|
||||
* errors in production builds. Results in slightly larger bundles.
|
||||
* - **default:** `false`
|
||||
*/
|
||||
prodHydrationMismatchDetails?: boolean;
|
||||
/**
|
||||
* Customize the component ID generation strategy.
|
||||
* - `'filepath'`: hash the file path (relative to the project root)
|
||||
* - `'filepath-source'`: hash the file path and the source code
|
||||
* - `function`: custom function that takes the file path, source code,
|
||||
* whether in production mode, and the default hash function as arguments
|
||||
* - **default:** `'filepath'` in development, `'filepath-source'` in production
|
||||
*/
|
||||
componentIdGenerator?: 'filepath' | 'filepath-source' | ((filepath: string, source: string, isProduction: boolean | undefined, getHash: (text: string) => string) => string);
|
||||
};
|
||||
/**
|
||||
* @deprecated moved to `features.customElement`.
|
||||
*/
|
||||
customElement?: boolean | string | RegExp | (string | RegExp)[];
|
||||
}
|
||||
interface ResolvedOptions extends Omit<Options, 'include' | 'exclude'> {
|
||||
compiler: typeof _compiler;
|
||||
root: string;
|
||||
sourceMap: boolean;
|
||||
cssDevSourcemap: boolean;
|
||||
devServer?: ViteDevServer;
|
||||
devToolsEnabled?: boolean;
|
||||
}
|
||||
interface Api {
|
||||
get options(): ResolvedOptions;
|
||||
set options(value: ResolvedOptions);
|
||||
get include(): string | RegExp | (string | RegExp)[] | undefined;
|
||||
/** include cannot be updated after `options` hook is called */
|
||||
set include(value: string | RegExp | (string | RegExp)[] | undefined);
|
||||
get exclude(): string | RegExp | (string | RegExp)[] | undefined;
|
||||
/** exclude cannot be updated after `options` hook is called */
|
||||
set exclude(value: string | RegExp | (string | RegExp)[] | undefined);
|
||||
version: string;
|
||||
}
|
||||
declare function vuePlugin(rawOptions?: Options): Plugin<Api>;
|
||||
declare function vuePluginCjs(this: unknown, options: Options): Plugin<Api>;
|
||||
//#endregion
|
||||
export { Api, Options, ResolvedOptions, type VueQuery, vuePlugin as default, vuePluginCjs as "module.exports", parseVueRequest };
|
||||
1745
node_modules/@vitejs/plugin-vue/dist/index.mjs
generated
vendored
Normal file
1745
node_modules/@vitejs/plugin-vue/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
65
node_modules/@vitejs/plugin-vue/package.json
generated
vendored
Normal file
65
node_modules/@vitejs/plugin-vue/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "@vitejs/plugin-vue",
|
||||
"version": "6.0.4",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "Evan You",
|
||||
"description": "The official plugin for Vue SFC support in Vite.",
|
||||
"keywords": [
|
||||
"vite",
|
||||
"vite-plugin",
|
||||
"vue"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"exports": {
|
||||
".": "./dist/index.mjs",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitejs/vite-plugin-vue.git",
|
||||
"directory": "packages/plugin-vue"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitejs/vite-plugin-vue/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#readme",
|
||||
"peerDependencies": {
|
||||
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0",
|
||||
"vue": "^3.2.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jridgewell/gen-mapping": "^0.3.13",
|
||||
"@jridgewell/trace-mapping": "^0.3.31",
|
||||
"obug": "^2.1.1",
|
||||
"rollup": "^4.57.1",
|
||||
"slash": "^5.1.0",
|
||||
"source-map-js": "^1.2.1",
|
||||
"tsdown": "^0.20.1",
|
||||
"vite": "^7.3.1",
|
||||
"vue": "^3.5.27"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rolldown/pluginutils": "1.0.0-rc.2"
|
||||
},
|
||||
"compatiblePackages": {
|
||||
"schemaVersion": 1,
|
||||
"rolldown": {
|
||||
"type": "incompatible",
|
||||
"reason": "Uses Vite-specific APIs"
|
||||
},
|
||||
"rollup": {
|
||||
"type": "incompatible",
|
||||
"reason": "Uses Vite-specific APIs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "tsdown --watch",
|
||||
"build": "tsdown"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user