bpev
bpev12mo ago

How does Fresh run esbuild on Deploy without cache writes?

I'm trying to build some solidjs code during runtime, but I keep getting errors on Deploy because of writes to esbuild cache:
[uncaught application error]: PermissionDenied - Requires write access to '/src/.cache/esbuild/bin', but the file system on Deno Deploy is read-only.
[uncaught application error]: PermissionDenied - Requires write access to '/src/.cache/esbuild/bin', but the file system on Deno Deploy is read-only.
My config looks pretty similar I think?
const [denoResolver, denoLoader] = [...denoPlugins({
portable: true,
configPath: resolve('./deno.json'),
})]

const results = await esbuild.build({
plugins: [
denoResolver,
solidPlugin({ solid: { moduleName: 'npm:solid-js/web' } }),
denoLoader
],
entryPoints: ['./www/index.tsx'],
outfile: '.',
bundle: true,
platform: 'browser',
format: 'esm',
target: ['chrome99', 'safari15'],
treeShaking: true,
write: false,
})
const [denoResolver, denoLoader] = [...denoPlugins({
portable: true,
configPath: resolve('./deno.json'),
})]

const results = await esbuild.build({
plugins: [
denoResolver,
solidPlugin({ solid: { moduleName: 'npm:solid-js/web' } }),
denoLoader
],
entryPoints: ['./www/index.tsx'],
outfile: '.',
bundle: true,
platform: 'browser',
format: 'esm',
target: ['chrome99', 'safari15'],
treeShaking: true,
write: false,
})
fresh esbuild config: https://github.com/denoland/fresh/blob/2fc212cc045e4f71a787a5bc9ebdee1ef5770bf9/src/build/esbuild.ts#L96 edit: oh is it writes from installing via npm?? Maybe portable isn't as portable as I thought.
at Object.mkdir (ext:deno_fs/30_fs.js:140:14)
at installFromNPM (https://deno.land/x/esbuild@v0.19.4/mod.js:1782:14)
at eventLoopTick (ext:core/01_core.js:183:11)
at async install (https://deno.land/x/esbuild@v0.19.4/mod.js:1867:12)
at async https://deno.land/x/esbuild@v0.19.4/mod.js:1878:23
at async Module.initialize (https://deno.land/x/esbuild@v0.19.4/mod.js:1768:3)
at Object.mkdir (ext:deno_fs/30_fs.js:140:14)
at installFromNPM (https://deno.land/x/esbuild@v0.19.4/mod.js:1782:14)
at eventLoopTick (ext:core/01_core.js:183:11)
at async install (https://deno.land/x/esbuild@v0.19.4/mod.js:1867:12)
at async https://deno.land/x/esbuild@v0.19.4/mod.js:1878:23
at async Module.initialize (https://deno.land/x/esbuild@v0.19.4/mod.js:1768:3)
GitHub
fresh/src/build/esbuild.ts at 2fc212cc045e4f71a787a5bc9ebdee1ef5770...
The next-gen web framework. Contribute to denoland/fresh development by creating an account on GitHub.
3 Replies
Deno AI Helper
Deno AI Helper12mo ago
Based on the documentation, Deno Deploy's file system is read-only, which means it doesn't allow write operations. This is why you're seeing a PermissionDenied error when trying to write to the esbuild cache. The portable option in the denoPlugins function is likely meant to make the esbuild binary portable across different environments, but it doesn't change the fact that Deno Deploy's file system is read-only. The error you're seeing seems to be coming from the installFromNPM function, which is trying to create a directory in the esbuild cache. This operation is not allowed in Deno Deploy due to its read-only file system. Unfortunately, the documentation does not provide a clear solution for this issue. It might be worth reaching out to the Deno community or the maintainers of the esbuild and deno plugins for further assistance.
marvinh.
marvinh.12mo ago
We use the wasm build of esbuild on deploy. That's the main difference
bpev
bpev12mo ago
Ahh got it. I just added a build step to deploys for now, but maybe I'll play with that later. Thanks!