create-aziz-app 3.0.8 → 3.0.9
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/package.json
CHANGED
|
@@ -118,15 +118,19 @@ function matchRoute(pattern, pathname) {
|
|
|
118
118
|
|
|
119
119
|
// Find the best matching route for a pathname
|
|
120
120
|
function resolveRoute(pathname) {
|
|
121
|
+
// Normalize: treat '' and '/' the same
|
|
122
|
+
const normalized = pathname === '' ? '/' : pathname;
|
|
123
|
+
|
|
121
124
|
// Exact match first
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
const exact = routes[normalized];
|
|
126
|
+
if (exact !== undefined) {
|
|
127
|
+
return { route: exact, params: {} };
|
|
124
128
|
}
|
|
125
129
|
|
|
126
|
-
// Pattern match
|
|
130
|
+
// Pattern match (dynamic segments like /blog/[slug])
|
|
127
131
|
for (const pattern in routes) {
|
|
128
132
|
if (pattern.includes('[')) {
|
|
129
|
-
const params = matchRoute(pattern,
|
|
133
|
+
const params = matchRoute(pattern, normalized);
|
|
130
134
|
if (params !== null) {
|
|
131
135
|
return { route: routes[pattern], params };
|
|
132
136
|
}
|
|
@@ -213,6 +217,7 @@ export const router = {
|
|
|
213
217
|
// Find matching route
|
|
214
218
|
const match = resolveRoute(pathname);
|
|
215
219
|
console.log(`🔍 resolveRoute('${pathname}'):`, match);
|
|
220
|
+
console.log('📦 All registered routes:', Object.keys(routes));
|
|
216
221
|
|
|
217
222
|
if (!match) {
|
|
218
223
|
root.innerHTML = '';
|
|
@@ -86,25 +86,34 @@ function buildRouteManifest() {
|
|
|
86
86
|
// Transforms: import X from '@/lib/db' → import X from '/lib/db.js'
|
|
87
87
|
|
|
88
88
|
function rewriteImports(code, filePath) {
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(match, specifier) => `from '/_modules/${specifier}'`
|
|
99
|
-
);
|
|
89
|
+
// Process line by line — only rewrite actual import/export statements
|
|
90
|
+
// This avoids corrupting string literals that contain import-like syntax
|
|
91
|
+
return code.split('\n').map(line => {
|
|
92
|
+
const trimmed = line.trimStart();
|
|
93
|
+
|
|
94
|
+
// Only process lines that are import or export statements
|
|
95
|
+
if (!trimmed.startsWith('import ') && !trimmed.startsWith('export ')) {
|
|
96
|
+
return line;
|
|
97
|
+
}
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
// Rewrite @/ alias → absolute path
|
|
100
|
+
line = line.replace(
|
|
101
|
+
/from\s+['"]@\/([^'"]+)['"]/g,
|
|
102
|
+
(_, p) => `from '/${p}'`
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// Rewrite bare specifiers (not starting with /, ./, ../)
|
|
106
|
+
line = line.replace(
|
|
107
|
+
/from\s+['"]([^'"./][^'"]*)['"]/g,
|
|
108
|
+
(_, specifier) => `from '/_modules/${specifier}'`
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
return line;
|
|
112
|
+
}).join('\n').replace(
|
|
113
|
+
// Dynamic imports can appear anywhere — but only rewrite bare specifiers
|
|
114
|
+
/\bimport\s*\(\s*['"]([^'"./][^'"]*)['"]\s*\)/g,
|
|
104
115
|
(_, specifier) => `import('/_modules/${specifier}')`
|
|
105
116
|
);
|
|
106
|
-
|
|
107
|
-
return code;
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
// ─── Module Resolver ─────────────────────────────────────────
|