diff options
author | 2023-03-23 12:01:27 -0400 | |
---|---|---|
committer | 2023-03-23 12:01:27 -0400 | |
commit | 4685f55549da418137ecf1a99e9cd36b3ad08c8c (patch) | |
tree | aaa97d97fb55d6e8079edcc4d76afd902a6c7cad /packages/integrations/image/wasmize.mjs | |
parent | 9caf2a9ccc2fd59af5cb2bb7ede9399fc491d38b (diff) | |
download | astro-4685f55549da418137ecf1a99e9cd36b3ad08c8c.tar.gz astro-4685f55549da418137ecf1a99e9cd36b3ad08c8c.tar.zst astro-4685f55549da418137ecf1a99e9cd36b3ad08c8c.zip |
Change how squoosh is loaded in the image integration (#6548)
* WIP fix image integration in Netlify
* Add a changeset
* Try another way
* Get the chunks folder
* try inlining
* deep sigh
* fix some things
* more
* Remove some stuff
* remove unused imports
* Add changeset
* remove unused --copy-wasm
* Remove unused post:build
Diffstat (limited to '')
-rw-r--r-- | packages/integrations/image/wasmize.mjs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/integrations/image/wasmize.mjs b/packages/integrations/image/wasmize.mjs new file mode 100644 index 000000000..fc570538d --- /dev/null +++ b/packages/integrations/image/wasmize.mjs @@ -0,0 +1,13 @@ +import fastglob from 'fast-glob'; +import { fileURLToPath } from 'node:url'; +import * as fs from 'node:fs'; + +const result = await fastglob(fileURLToPath(new URL('./src/**/*.wasm', import.meta.url))); + +for(const filepath of result) { + const buffer = await fs.promises.readFile(filepath); + const base64 = buffer.toString('base64'); + const source = `export default Buffer.from(${JSON.stringify(base64)}, 'base64');`; + const outpath = filepath + '.ts'; + await fs.promises.writeFile(outpath, source, 'utf-8'); +} |