@pracht/vite-plugin 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.mjs +10 -7
- package/dist/pages-router.mjs +9 -1
- package/package.json +4 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jovi De Croock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.mjs
CHANGED
|
@@ -75,12 +75,15 @@ async function pracht(options = {}) {
|
|
|
75
75
|
const prachtPlugin = {
|
|
76
76
|
name: "pracht",
|
|
77
77
|
enforce: "pre",
|
|
78
|
-
config() {
|
|
78
|
+
config(_config, env) {
|
|
79
|
+
const isEdge = resolved.adapter.id === "vercel" || resolved.adapter.id === "cloudflare";
|
|
80
|
+
const isSSRBuild = env.isSsrBuild;
|
|
79
81
|
return {
|
|
80
82
|
appType: "custom",
|
|
81
83
|
build: { rollupOptions: { output: { manualChunks(id) {
|
|
82
84
|
if (id.includes("node_modules/preact") || id.includes("node_modules/preact-suspense")) return "vendor";
|
|
83
|
-
} } } }
|
|
85
|
+
} } } },
|
|
86
|
+
...isEdge && isSSRBuild ? { ssr: { noExternal: true } } : {}
|
|
84
87
|
};
|
|
85
88
|
},
|
|
86
89
|
configResolved(config) {
|
|
@@ -225,14 +228,14 @@ function createPrachtServerModuleSource(options = {}, buildOptions = {}) {
|
|
|
225
228
|
function createPrachtRegistryModuleSource(options = {}) {
|
|
226
229
|
const resolved = resolveOptions(options);
|
|
227
230
|
const isPagesMode = !!resolved.pagesDir;
|
|
228
|
-
const routeGlob = isPagesMode ? `${resolved.pagesDir}/**/*.{ts,tsx,js,jsx,md}` : `${resolved.routesDir}/**/*.{ts,tsx,js,jsx,md}`;
|
|
229
|
-
const shellGlob = isPagesMode ? `${resolved.pagesDir}/**/_app.{ts,tsx,js,jsx}` : `${resolved.shellsDir}/**/*.{ts,tsx,js,jsx,md}`;
|
|
231
|
+
const routeGlob = isPagesMode ? `${resolved.pagesDir}/**/*.{ts,tsx,js,jsx,md,mdx}` : `${resolved.routesDir}/**/*.{ts,tsx,js,jsx,md,mdx}`;
|
|
232
|
+
const shellGlob = isPagesMode ? `${resolved.pagesDir}/**/_app.{ts,tsx,js,jsx}` : `${resolved.shellsDir}/**/*.{ts,tsx,js,jsx,md,mdx}`;
|
|
230
233
|
return [
|
|
231
234
|
`export const routeModules = import.meta.glob(${JSON.stringify(routeGlob)});`,
|
|
232
235
|
`export const shellModules = import.meta.glob(${JSON.stringify(shellGlob)});`,
|
|
233
|
-
`export const middlewareModules = import.meta.glob(${JSON.stringify(`${resolved.middlewareDir}/**/*.{ts,tsx,js,jsx
|
|
234
|
-
`export const apiModules = import.meta.glob(${JSON.stringify(`${resolved.apiDir}/**/*.{ts,js}`)});`,
|
|
235
|
-
`export const dataModules = import.meta.glob(${JSON.stringify(`${resolved.serverDir}/**/*.{ts,js}`)});`,
|
|
236
|
+
`export const middlewareModules = import.meta.glob(${JSON.stringify(`${resolved.middlewareDir}/**/*.{ts,tsx,js,jsx}`)});`,
|
|
237
|
+
`export const apiModules = import.meta.glob(${JSON.stringify(`${resolved.apiDir}/**/*.{ts,js,tsx,jsx}`)});`,
|
|
238
|
+
`export const dataModules = import.meta.glob(${JSON.stringify(`${resolved.serverDir}/**/*.{ts,js,tsx,jsx}`)});`,
|
|
236
239
|
"",
|
|
237
240
|
"export const registry = {",
|
|
238
241
|
" routeModules,",
|
package/dist/pages-router.mjs
CHANGED
|
@@ -2,6 +2,14 @@ import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { basename, extname, join, relative } from "node:path";
|
|
3
3
|
//#region src/pages-router.ts
|
|
4
4
|
const PAGE_EXTENSIONS = new Set([
|
|
5
|
+
".tsx",
|
|
6
|
+
".ts",
|
|
7
|
+
".jsx",
|
|
8
|
+
".js",
|
|
9
|
+
".md",
|
|
10
|
+
".mdx"
|
|
11
|
+
]);
|
|
12
|
+
const SHELL_EXTENSIONS = new Set([
|
|
5
13
|
".tsx",
|
|
6
14
|
".ts",
|
|
7
15
|
".jsx",
|
|
@@ -72,7 +80,7 @@ function generatePagesManifestSource(pages, options) {
|
|
|
72
80
|
const defaultRender = options.pagesDefaultRender ?? "ssr";
|
|
73
81
|
const prefix = options.pagesDirPrefix;
|
|
74
82
|
const useImport = options.useImportSyntax ?? false;
|
|
75
|
-
const appFile = scanAllFiles(pagesDir).find((f) => basename(f, extname(f)) === "_app" &&
|
|
83
|
+
const appFile = scanAllFiles(pagesDir).find((f) => basename(f, extname(f)) === "_app" && SHELL_EXTENSIONS.has(extname(f)));
|
|
76
84
|
const lines = ["import { defineApp, group, route } from \"@pracht/core\";", ""];
|
|
77
85
|
const routeEntries = [];
|
|
78
86
|
for (const page of pages) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pracht/vite-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"homepage": "https://github.com/JoviDeCroock/pracht/tree/main/packages/vite-plugin",
|
|
5
6
|
"bugs": {
|
|
6
7
|
"url": "https://github.com/JoviDeCroock/pracht/issues"
|
|
@@ -30,8 +31,8 @@
|
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@preact/preset-vite": "^2.10.5",
|
|
32
33
|
"@prefresh/vite": "^2.0.0",
|
|
33
|
-
"@pracht/adapter-node": "0.1.
|
|
34
|
-
"@pracht/core": "0.2.
|
|
34
|
+
"@pracht/adapter-node": "0.1.7",
|
|
35
|
+
"@pracht/core": "0.2.6"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"vite": "^7.0.0 || ^8.0.0"
|