ElMassimo / ElMassimo/iles

Should display an error when useDocuments is used with a variable

Open
#146 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
1.2k
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Hi!

I stumbled upon an issue I couldn't explain. When I run `npm run dev` in a dummy app with:
```js

const foobar = '~/pages'
console.log(useDocuments(foobar).value.length) // it always logs 0
console.log(useDocuments('~/pages').value.length) // it logs 3 (in my case)

```

When looking at the transpiled code in my browser, I saw:

```js
import _documents_0 from '/@islands/documents?pattern=ooba';
import _documents_1 from '/@islands/documents?pattern=~/pages'
```

I could find why this has this behaviour: https://github.com/ElMassimo/iles/blob/80eb10366ddefea217f32d138b8b79e1aea5366e/packages/iles/src/node/plugin/documents.ts#L134

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)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.