New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should display an error when useDocuments is used with a variable #146
Comments
The reason why I stumbled upon this is because I want to build a wrapper to order the Documents that looks like: import { ref, computed } from 'vue'
import { useDocuments } from 'iles/dist/client'
export const defaultCompareFn = (x: any, y: any) => x.order - y.order // this is a convention I use to sort my pages in the menu
export const dateCompareFn = (x: any, y: any) => x.date - y.date
export default (globPattern: string, compareFn = defaultCompareFn) => computed(() => useDocuments(
globPattern).value.sort(compareFn)) I would have liked to re-use this composable for my navbar and my blog posts. |
Thanks for reporting! Generating imports requires static analysis, there's no way to support a dynamic value, as Rollup needs to know which files to process at compile time. It's very similar to glob imports in Vite:
This would be a nice addition to the docs, pull requests are welcome. At the moment it seems that quotes in the Ideally, îles should throw an error on analysis, just like Vite would if you used That way users that weren't aware of this limitation in build systems will see an explicit error instead of unexpected behavior. Pull requests for this are also welcome 😃 |
All right, thanks for the swift reply. This is my first project with Vite! |
Hi!
I stumbled upon an issue I couldn't explain. When I run
npm run dev
in a dummy app with:When looking at the transpiled code in my browser, I saw:
I could find why this has this behaviour:
iles/packages/iles/src/node/plugin/documents.ts
Line 134 in 80eb103
I am deeply troubled by this static analysis of the code, which fails when using
useDocuments
with a variable. Is it a usual pattern, or a design choice from your end? This seems really flaky to me, and needs at the very least to be documented.(otherwise, iles is nice :) thanks for the great work)
The text was updated successfully, but these errors were encountered: