lucacasonato / esbuild_deno_loader

Deno module resolution for `esbuild`
https://jsr.io/@luca/esbuild-deno-loader
MIT License
176 stars 46 forks source link

Read permission is always required even with the portable loader #128

Closed reosablo closed 2 months ago

reosablo commented 6 months ago

The docs state that the portable loader requires --allow-read and/or --allow-net, but the former is always required in fact.

This seems to be because of the Deno.cwd() call.

https://github.com/lucacasonato/esbuild_deno_loader/blob/ccd8992c690deee821d6b7a7efeaf599722c394c/src/plugin_deno_loader.ts#L187-L190

The workaround for this issue is to specify a dummy absWorkingDir value in the esbuild configuration.

const result = await esbuild.build({
  // ...
  // required to avoid read permission of CWD by esbuild_deno_loader
  absWorkingDir: "/",
});

I encountered this problem when using this plugin in Val Town, which does not allow read permissions.

lucacasonato commented 2 months ago

The docs are correct. Read is not always reqiured, only when absWorkingDir is not set.