cayo 0.9.1 → 0.9.5

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
@@ -19,6 +19,6 @@
19
19
  const json = JSON.stringify($$restProps);
20
20
  </script>
21
21
 
22
- <div data-cayo-id={name ? `${name}-${hash()}` : ''} data-cayo-props={json}>Cayo loading...<slot/></div>
22
+ <div data-cayo-id={name ? `${name}-${hash()}` : ''} data-cayo-props={json}><slot/></div>
23
23
  <slot/>
24
24
 
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,6 +1,6 @@
1
1
  {
2
2
  "name": "cayo",
3
- "version": "0.9.1",
3
+ "version": "0.9.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "start": "node cayo dev --projectRoot test"
@@ -1,4 +1,5 @@
1
1
  <script>
2
2
  export let beans = '';
3
3
  </script>
4
- <div>{beans}</div>
4
+ <div>{beans}</div>
5
+ <p>I prob change don't i</p>
@@ -1 +1 @@
1
- a
1
+ HUH?
@@ -5,15 +5,18 @@
5
5
  </script>
6
6
  <script>
7
7
  import Cayo from '../../../lib/components/Cayo.svelte';
8
+
9
+ import Some from '../components/Some.svelte';
8
10
  </script>
9
11
 
12
+ <Some />
10
13
 
11
14
  I'm index howdy ok<br>
12
15
  <a href="/howdy/">Howdy</a><br>
13
16
  <a href="/hey/" class="red">Hey</a>
14
17
  <a href="/some/page/" class="red">Some</a>
15
18
 
16
- <Cayo name="Cool" beans='ayo'></Cayo>
19
+ <Cayo name="Cool" beans='ayo'>Whaaat</Cayo>
17
20
  <Cayo name="Cool" beans='beeeeaaaaasnnss' />
18
21
  <Cayo name="Cool" beans='NOT BEANS' />
19
22