cayo 0.9.1 → 0.9.2
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/cayo.js
CHANGED
|
@@ -135,8 +135,8 @@ async function getTemplate(config) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
async function getPages(config) {
|
|
138
|
-
const { pages, cayoPath } = config;
|
|
139
|
-
return createPageManifest(pages, cayoPath)
|
|
138
|
+
const { src, pages, cayoPath } = config;
|
|
139
|
+
return createPageManifest(pages, cayoPath, src)
|
|
140
140
|
.then(async () => await import(path.resolve(cayoPath, `./__cayo/pages.js?v=${hash()}`)))
|
|
141
141
|
.then(({ pages }) => {
|
|
142
142
|
data.pages = getPageModules(pages, config);
|
|
@@ -201,6 +201,13 @@ function watch(config) {
|
|
|
201
201
|
let componentModule = Object.entries(components).find(([, { modulePath }]) => modulePath === filePath);
|
|
202
202
|
handleCayoComponent(componentModule[0], componentModule[1].modulePath, config);
|
|
203
203
|
})
|
|
204
|
+
} else if (filePath.includes('/components')) {
|
|
205
|
+
logChange('component');
|
|
206
|
+
getPages(config)
|
|
207
|
+
.then(() => {
|
|
208
|
+
prerenderPages(config);
|
|
209
|
+
})
|
|
210
|
+
|
|
204
211
|
// TODO: watch component changes
|
|
205
212
|
// } else if (componentFileChanged) {
|
|
206
213
|
// find out which pages are affected
|
package/lib/utils.js
CHANGED
|
@@ -59,8 +59,9 @@ export async function getComponentModulePaths(srcPath) {
|
|
|
59
59
|
return await fg([path.resolve(srcPath, './components/**/*.cayo.svelte')]);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export async function createPageManifest(pagesPath, outDir) {
|
|
62
|
+
export async function createPageManifest(pagesPath, outDir, srcPath) {
|
|
63
63
|
const pagePaths = await getPageModulePaths(pagesPath);
|
|
64
|
+
const nonCayoComponentPaths = await fg([path.resolve(srcPath, './components/**/*[!(.cayo)].svelte')]);
|
|
64
65
|
let importPages = `import { createRequire } from 'module';\n`
|
|
65
66
|
importPages += `const require = createRequire(import.meta.url);\n`
|
|
66
67
|
importPages += `require('svelte/register');\n`;
|
|
@@ -73,6 +74,11 @@ export async function createPageManifest(pagesPath, outDir) {
|
|
|
73
74
|
importPages += ` '${path}': page_${i},\n`;
|
|
74
75
|
})
|
|
75
76
|
importPages += '}\n';
|
|
77
|
+
|
|
78
|
+
nonCayoComponentPaths.forEach((path) => {
|
|
79
|
+
importPages += `delete require.cache['${path}'];\n`;
|
|
80
|
+
});
|
|
81
|
+
|
|
76
82
|
return await fs.outputFile(path.resolve(outDir, './__cayo/pages.js'), importPages);
|
|
77
83
|
}
|
|
78
84
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
HUH?
|