Skip to content

Commit

Permalink
docs: node:fs.stat() workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
hansSchall committed Aug 5, 2024
1 parent ed838c9 commit 022becb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,26 @@ setups Babel isn't really needed, see Usage wit Preact).
`tailwindcss` currently needs to be installed via NPM/Yarn, otherwise the PostCSS plugin loader is unable to find it.
You could also use the Tailwind Play CDN during development.

### `Deno.stat` workaround needed

Until https://github.com/denoland/deno/issues/24899 has been resolved, you need to include the following snippet in
order to achieve the correct behavior when `node:fs.stat()` is called with an invalid file path. Otherwise you get
errors like `[vite] Pre-transform error: EINVAL: invalid argument, stat`.

```typescript
const deno_stat = Deno.stat;

Deno.stat = (...args) => {
const path = args[0].toString().replaceAll("\\", "/");

if (path.includes("/jsr:@")) {
return deno_stat("./not-existing");
} else {
return deno_stat(...args);
}
};
```

## License (LGPL-2.1-or-later)

Copyright (C) 2024 Hans Schallmoser
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deno-plc/vite-plugin-deno",
"version": "0.1.1",
"version": "0.1.2",
"exports": "./mod.ts",
"fmt": {
"indentWidth": 4,
Expand Down

0 comments on commit 022becb

Please sign in to comment.