Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@astrojs/image] Unnecessary .wasm output #5689

Closed
1 task
kagankan opened this issue Dec 28, 2022 · 4 comments · Fixed by #6701
Closed
1 task

[@astrojs/image] Unnecessary .wasm output #5689

kagankan opened this issue Dec 28, 2022 · 4 comments · Fixed by #6701
Assignees
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: assets Related to the Assets feature (scope) pkg: image Related to the `@astrojs/image` package (scope)

Comments

@kagankan
Copy link
Contributor

What version of astro are you using?

1.8.0

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows 10

Describe the Bug

Thank you for always developing Astro!
@astrojs/image integration is very useful to get image width and height. 😍

Problem

  1. Clone reproduction repo.
  2. Run npm install and npx astro build
  3. There are .wasm files in dist/chunks folder after build.

To my understanding, wasm files are needed for image optimization, and not needed for getting image sizes.
I would like to disable this output, since I'm not using image optimization.

Want

Disable this output automatically when image optimization is not used,
or allow to turn off this manually.

Thank you.

Link to Minimal Reproducible Example

https://github.com/kagankan/astro-sample/tree/sample/image-integration

Participation

  • I am willing to submit a pull request for this issue.
@Princesseuh Princesseuh self-assigned this Jan 25, 2023
@Princesseuh Princesseuh added the pkg: image Related to the `@astrojs/image` package (scope) label Feb 2, 2023
@matthewp matthewp added the - P2: nice to have Not breaking anything but nice to have (priority) label Feb 8, 2023
@danielberndt
Copy link

fyi this issue is also present when activating

  experimental: {
    assets: true,
  }

for astro 2.1.2.

Adding this to the config results in 5.3MB of .wasm files in dist/chunks

Note that this also happens when

  image: {
    service: "astro/assets/services/sharp",
  }

is set.

@danielberndt
Copy link

Is it maybe enough to extend this expression to also include .wasm files?

const files = await glob('**/*.mjs', {

@sujaykumarh
Copy link
Contributor

Hello, Here's what i found,

this is the line of code that copies .wasm files which was added in PR#4738

await copyWasmFiles(new URL('./chunks', dir));

the .wasm vendor files are present at https://github.com/withastro/astro/tree/main/packages/astro/src/assets/services/vendor/squoosh


i do not understand the need for wasm files to be present for a SSG site, having tested on astro v2.1.3 and with experimental feature astro:assets this seems unnecessary as images are optimized on build and no wasm file is loaded on any request on a SSG site after build



Possible solution

an option to disable export of .wasm files in astro.config.mjs would be helpful if wasm files are required to be present for some reason by default

// example config of astro.config.mjs
export default defineConfig({
  ....
  vite: {
    build: {
      assets: {
         export_wasm: false, // or export_vendor: false,
      },
    },
  },
});

@Princesseuh
Copy link
Member

The WASM files are required during the build, they just aren't cleaned up properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: assets Related to the Assets feature (scope) pkg: image Related to the `@astrojs/image` package (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants