Giter VIP home page Giter VIP logo

gulp-libsquoosh's People

Contributors

dependabot[bot] avatar pekeq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dmelearn

gulp-libsquoosh's Issues

Problems running more complex example

I'm trying to run the more complex example from the readme and I'm having the following issues:

The src object doesn't include a path component.

Because the src object doesn't have a path or an extension child, I get the following error

[16:19:28] gulp-squoosh: The "path" argument must be of type string. Received undefined /Users/carlos/code/gulp-starter-2021/src/original-images/Screen Shot 2021-08-08 at 17.51.02.png

Am I doing something wrong?

This is the code I'm using

gulp.task('squoosh', () => {
  return gulp.src(['src/original-images/**/*.{png,jpg,webp}'])
      .pipe(
          squoosh((src) => {
            console.log(src);
            const extname = path.extname(src.path);
            let options = {
              encodeOptions: squoosh.DefaultEncodeOptions[extname],
            };

            if (extname === '.jpg') {
              options = {
                encodeOptions: {
                  jxl: {},
                  mozjpeg: {},
                },
              };
            }

            if (extname === '.png') {
              options = {
                encodeOptions: {
                  avif: {},
                },
                preprocessOptions: {
                  quant: {
                    enabled: true,
                    numColors: 16,
                  },
                },
              };
            }

            return options;
          }),
      )
      .pipe(gulp.dest('dist/images'));
});

Memory issue (PluginError: WebAssembly.instantiate(): Out of memory: wasm memory)

Out of memory error occur like following:

(node:45565) UnhandledPromiseRejectionWarning: RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
(Use `node --trace-warnings ...` to show where the warning was created)
(node:45565) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:45565) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:45565) UnhandledPromiseRejectionWarning: RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
(Use `node --trace-warnings ...` to show where the warning was created)
(node:45565) UnhandledPromiseRejectionWarning: RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
(Use `node --trace-warnings ...` to show where the warning was created)
failed to asynchronously prepare wasm: RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
  • Error raised when running pipe(squoosh()) multiple times.
  • This is known issue. (GoogleChromeLabs/squoosh#1065)
  • Some workarounds exist.
    • Don't create multiple ImagePool instance. Create singleton instance.
    • Apply patch to ensure to free wasm memory. (vercel/next.js#23565)
    • Rollback libsquoosh to previous version.

Starting from version 1.1.0 error when starting a task

Hi!
When starting a task, it knocks out such an error:

Error: Cannot find module 'C:\C:\Users\vavsh\Desktop\temp\node_modules\@squoosh\lib\build\avif_node_enc_mt.worker-be931951.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at MessagePort.<anonymous> (node:internal/main/worker_thread:187:24)
    at MessagePort.[nodejs.internal.kHybridDispatch] (node:internal/event_target:562:20)
    at MessagePort.exports.emitMessage (node:internal/per_context/messageport:23:28)

My task code:

import { src, dest } from 'gulp';
import squoosh from 'gulp-libsquoosh';
import rename from 'gulp-rename';
import { config } from '../config';

const imageOptimizationJpg = () => {
  return src(config.source.convertjpg)
    .pipe(rename({
      extname: '.jpg',
    }))
    .pipe(squoosh({
      mozjpeg: {},
      webp: {},
      avif: {},
    }))
    .pipe(rename({
      dirname: 'pictures/',
    }))
    .pipe(dest(config.build.pictures));
};

The funny thing is that this problem does not exist on version โ€” 1.0.12
And all subsequent versions after this one go with an error

Gulp tasks don't exit when gulp-libsquoosh is included

Hi,

I've spent a few hours trying to figure out why my Gulp tasks don't exit after they've been finished and finally I pin-pointed the issue to the gulp-libsquoosh library.

So, the issue is that none of Gulp tasks exit after being finished if gulp-libsquoosh is included in the gulpfile.js. You don't have to use it in the task, just include, and that's enough to break all other tasks. It's easy to reproduce the issue with this minimal gulpfile.js:

const { src } = require('gulp');
const squoosh = require('gulp-libsquoosh');

function defaultTask() {
    return src('.')
}

exports.default = defaultTask;

Then just run the default task in a console: gulp.
After running the task you'll see that it never exits:

pavlo@DESKTOP-O2A9C8P:~$ gulp
[14:59:25] Using gulpfile ~/gulpfile.js
[14:59:25] Starting 'default'...
[14:59:25] Finished 'default' after 30 ms
|

The expected outcome is that the task finishes and exits back to the console.
As soon as I comment out the gulp-libsquoosh include, the task exits fine. The same will happen with all other tasks in the gulpfile.js.

Versions I'm using:
gulp: 4.0.2
gulp-libsquoosh: 1.0.10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.