@flarelabs-net/wrangler-build-time-fs-assets-polyfilling
v0.0.1
Published
The package in a nutshell generates files at built time that define what static assets a Cloudflare worker has access to alongside fs polyfills that make sure to such files to provide support for some `fs` functions.
Downloads
2,137
Keywords
Readme
wrangler-build-time-fs-assets-polyfilling
The package in a nutshell generates files at built time that define what static assets
a Cloudflare worker has access to alongside fs polyfills that make sure to such files
to provide support for some fs functions.
A more proper documentation will be added later here if beneficial 🙂
How to use the package
Install the package as a dev dependency:
npm i -D @flarelabs-net/wrangler-build-time-fs-assets-polyfillingThe package can be run via npx and similar tools:
npx wrangler-build-time-fs-assets-polyfilling --assets ./publicThe command currently accepts two types of options:
--assets|-a
What path of a directory containing the assets the command needs to generate the build-time files from (multiple paths can be provided here).--assets-output-dir|-o
Path were to copy all the assets. This is mandatory only when multiple assets paths are provided.
Besides the above you need to update your wrangler config file to:
include an
assetsbinding, its binding name needs to beASSETSand it's directory needs to be either:- the assets output directory specified when running the command
- or the single assets path specified when running the command
include
aliases set to the following:node:fs:./.wrangler/fs-assets-polyfilling/polyfills/node/fs.tsfs:./.wrangler/fs-assets-polyfilling/polyfills/node/fs.tsnode:fs/promises:./.wrangler/fs-assets-polyfilling/polyfills/node/fs/promises.tsfs/promises:./.wrangler/fs-assets-polyfilling/polyfills/node/fs/promises.ts
optionally a
buildcommand that runs thewrangler-build-time-fs-assets-polyfillingcommand (for convenience)
