vite-plugin-vue-layouts-next
Advanced tools
Comparing version
@@ -1,10 +0,1 @@ | ||
/** | ||
* @deprecated | ||
*/ | ||
declare module 'layouts-generated' { | ||
import type { RouteRecordRaw } from 'vue-router' | ||
export function setupLayouts(routes: RouteRecordRaw[]): RouteRecordRaw[] | ||
} | ||
declare module 'virtual:generated-layouts' { | ||
@@ -11,0 +2,0 @@ import type { Router, RouteRecordRaw } from 'vue-router' |
@@ -99,3 +99,3 @@ // src/index.ts | ||
} | ||
var debug = Debug("vite-plugin-layouts"); | ||
var debug = Debug("vite-plugin-layouts-next"); | ||
function resolveDirs(dirs, root) { | ||
@@ -142,3 +142,3 @@ if (dirs === null) | ||
for (const file of __.files) { | ||
const path = __.path.substr(0, 1) === "/" ? `${__.path}/${file}` : `/${__.path}/${file}`; | ||
const path = __.path.startsWith("/") ? `${__.path}/${file}` : `/${__.path}/${file}`; | ||
const parsed = parse(file); | ||
@@ -227,3 +227,3 @@ const name = join(parsed.dir, parsed.name).replace(/\\/g, "/"); | ||
// src/index.ts | ||
var MODULE_IDS = ["layouts-generated", "virtual:generated-layouts"]; | ||
var MODULE_ID = "virtual:generated-layouts"; | ||
var MODULE_ID_VIRTUAL = "/@vite-plugin-vue-layouts-next/generated-layouts"; | ||
@@ -257,3 +257,3 @@ function defaultImportMode(name) { | ||
const options = resolveOptions(userOptions); | ||
let layoutDirs; | ||
let layoutsDirs; | ||
let pagesDirs; | ||
@@ -265,3 +265,3 @@ return { | ||
config = _config; | ||
layoutDirs = resolveDirs(options.layoutsDirs, config.root); | ||
layoutsDirs = resolveDirs(options.layoutsDirs, config.root); | ||
pagesDirs = resolveDirs(options.pagesDirs, config.root); | ||
@@ -284,3 +284,3 @@ }, | ||
path = normalizePath2(path); | ||
if (pagesDirs.length === 0 || pagesDirs.some((dir) => path.startsWith(dir)) || layoutDirs.some((dir) => path.startsWith(dir))) { | ||
if (pagesDirs.length === 0 || pagesDirs.some((dir) => path.startsWith(dir)) || layoutsDirs.some((dir) => path.startsWith(dir))) { | ||
debug("reload", path); | ||
@@ -302,3 +302,3 @@ const module = moduleGraph.getModuleById(MODULE_ID_VIRTUAL); | ||
resolveId(id) { | ||
return MODULE_IDS.includes(id) || MODULE_IDS.some((i) => id.startsWith(i)) ? MODULE_ID_VIRTUAL : null; | ||
return id === MODULE_ID || id.startsWith(MODULE_ID) ? MODULE_ID_VIRTUAL : null; | ||
}, | ||
@@ -308,4 +308,4 @@ async load(id) { | ||
const container = []; | ||
for (const dir of layoutDirs) { | ||
const layoutsDirPath = dir.substr(0, 1) === "/" ? normalizePath2(dir) : normalizePath2(resolve2(config.root, dir)); | ||
for (const dir of layoutsDirs) { | ||
const layoutsDirPath = dir.startsWith("/") ? normalizePath2(dir) : normalizePath2(resolve2(config.root, dir)); | ||
debug("Loading Layout Dir: %O", layoutsDirPath); | ||
@@ -332,8 +332,7 @@ const _f = await getFilesFromPath(layoutsDirPath, options); | ||
resolveId(id) { | ||
const MODULE_ID = MODULE_IDS.find((MODULE_ID2) => id === MODULE_ID2); | ||
if (MODULE_ID) | ||
if (id === MODULE_ID) | ||
return `\0${MODULE_ID}`; | ||
}, | ||
load(id) { | ||
if (MODULE_IDS.some((MODULE_ID) => id === `\0${MODULE_ID}`)) { | ||
if (id === `\0${MODULE_ID}`) { | ||
return createVirtualModuleCode({ | ||
@@ -350,3 +349,3 @@ layoutDir, | ||
const keys = Object.keys(options); | ||
if (keys.length > 2 || keys.some((key) => !["layoutDirs", "defaultLayout"].includes(key))) | ||
if (keys.length > 2 || keys.some((key) => !["layoutsDirs", "defaultLayout"].includes(key))) | ||
return false; | ||
@@ -353,0 +352,0 @@ if (options.layoutsDirs && (Array.isArray(options.layoutsDirs) || options.layoutsDirs.includes("*"))) |
{ | ||
"name": "vite-plugin-vue-layouts-next", | ||
"type": "module", | ||
"version": "0.1.5", | ||
"packageManager": "pnpm@10.11.1", | ||
"version": "1.0.0", | ||
"packageManager": "pnpm@10.12.4", | ||
"description": "Router-based layout plugin for Vite and Vue, supports the latest versions.", | ||
@@ -25,3 +25,3 @@ "author": "loicduong <npm@relate.dev>", | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs" | ||
"types": "./dist/index.d.ts" | ||
}, | ||
@@ -33,5 +33,5 @@ "./client": { | ||
}, | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
@@ -43,20 +43,16 @@ "client.d.ts", | ||
"dev": "npm run build -- --watch", | ||
"build": "tsup src/index.ts --dts --format cjs,esm", | ||
"prepublishOnly": "npm run build", | ||
"build": "tsup src/index.ts --dts --format esm", | ||
"release": "npx bumpp --commit --tag --push && npm publish", | ||
"example:dev": "npm -C examples/spa run dev", | ||
"example:build": "npm -C examples/spa run build", | ||
"example:serve": "npm -C examples/spa run serve", | ||
"example:dev-ssg": "npm -C examples/ssg run dev", | ||
"example:build-ssg": "npm -C examples/ssg run build", | ||
"example:serve-ssg": "npm -C examples/ssg run serve", | ||
"example:dev-client": "npm -C examples/client-side run dev", | ||
"example:build-client": "npm -C examples/client-side run build", | ||
"example:serve-client": "npm -C examples/client-side run serve", | ||
"example:dev-unplugin": "npm -C examples/unplugin-vue-router run dev", | ||
"example:build-unplugin": "npm -C examples/unplugin-vue-router run build", | ||
"example:serve-unplugin": "npm -C examples/unplugin-vue-router run serve", | ||
"example:dev-vitesse": "npm -C examples/vitesse run dev", | ||
"example:build-vitesse": "npm -C examples/vitesse run build", | ||
"example:serve-vitesse": "npm -C examples/vitesse run preview", | ||
"example:spa:dev": "npm -C examples/spa run dev", | ||
"example:spa:build": "npm -C examples/spa run build", | ||
"example:spa:preview": "npm -C examples/spa run preview", | ||
"example:ssg:dev": "npm -C examples/ssg run dev", | ||
"example:ssg:build": "npm -C examples/ssg run build", | ||
"example:ssg:preview": "npm -C examples/ssg run preview", | ||
"example:client:dev": "npm -C examples/client-side run dev", | ||
"example:client:build": "npm -C examples/client-side run build", | ||
"example:client:preview": "npm -C examples/client-side run preview", | ||
"example:unplugin:dev": "npm -C examples/unplugin-vue-router run dev", | ||
"example:unplugin:build": "npm -C examples/unplugin-vue-router run build", | ||
"example:unplugin:preview": "npm -C examples/unplugin-vue-router run preview", | ||
"lint": "eslint", | ||
@@ -66,3 +62,3 @@ "lint:fix": "eslint --fix" | ||
"peerDependencies": { | ||
"vite": "^4.0.0 || ^5.0.0 || ^6.0.0", | ||
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0", | ||
"vue": "^3.2.4", | ||
@@ -76,15 +72,15 @@ "vue-router": "^4.0.11" | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^4.14.1", | ||
"@antfu/eslint-config": "^4.16.1", | ||
"@types/debug": "^4.1.12", | ||
"@types/node": "^22.15.30", | ||
"@types/node": "^24.0.8", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^9.28.0", | ||
"eslint": "^9.30.0", | ||
"eslint-plugin-format": "^1.0.1", | ||
"rollup": "^4.42.0", | ||
"rollup": "^4.44.1", | ||
"tsup": "^8.5.0", | ||
"typescript": "^5.8.3", | ||
"vite": "^6.3.5", | ||
"vue": "^3.5.16", | ||
"vite": "^7.0.0", | ||
"vue": "^3.5.17", | ||
"vue-router": "^4.5.1" | ||
} | ||
} |
@@ -19,4 +19,2 @@ # vite-plugin-vue-layouts-next | ||
See the [Vitesse starter template](https://github.com/antfu/vitesse) for a working example with [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts) and it also works similarly with this. | ||
```html | ||
@@ -34,6 +32,13 @@ <route lang="yaml"> | ||
```bash | ||
# npm | ||
npm install -D vite-plugin-vue-layouts-next | ||
# yarn | ||
yarn add -D vite-plugin-vue-layouts-next | ||
# pnpm | ||
pnpm add -D vite-plugin-vue-layouts-next | ||
``` | ||
Add to your `vite.config.js`: | ||
Add to your `vite.config.ts`: | ||
@@ -44,6 +49,7 @@ ```js | ||
import Layouts from 'vite-plugin-vue-layouts-next' | ||
import { defineConfig } from 'vite' | ||
export default { | ||
export default defineConfig({ | ||
plugins: [Vue(), Pages(), Layouts()], | ||
} | ||
}) | ||
``` | ||
@@ -111,6 +117,7 @@ | ||
```js | ||
// vite.config.js | ||
// vite.config.ts | ||
import Layouts from 'vite-plugin-vue-layouts-next' | ||
import { defineConfig } from 'vite' | ||
export default { | ||
export default defineConfig({ | ||
plugins: [ | ||
@@ -123,3 +130,3 @@ Layouts({ | ||
], | ||
} | ||
}) | ||
``` | ||
@@ -247,3 +254,3 @@ | ||
```html | ||
<script setup> | ||
<script setup lang="ts"> | ||
import { useRouter } from 'vue-router' | ||
@@ -265,3 +272,3 @@ </script> | ||
```html | ||
<script setup> | ||
<script setup lang="ts"> | ||
import { defineEmit } from 'vue' | ||
@@ -280,3 +287,3 @@ const emit = defineEmit(['setColor']) | ||
```html | ||
<script setup> | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
@@ -304,6 +311,7 @@ | ||
```js | ||
// vite.config.js | ||
// vite.config.ts | ||
import { ClientSideLayout } from 'vite-plugin-vue-layouts-next' | ||
import { defineConfig } from 'vite' | ||
export default { | ||
export default defineConfig({ | ||
plugins: [ | ||
@@ -316,3 +324,3 @@ ClientSideLayout({ | ||
], | ||
} | ||
}) | ||
``` |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
-100%317
2.59%23485
-38.26%6
-25%392
-48.49%