pekeq / gulp-libsquoosh Goto Github PK
View Code? Open in Web Editor NEWMinify images with libSquoosh, the Squoosh API for Node.
License: MIT License
Minify images with libSquoosh, the Squoosh API for Node.
License: MIT License
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'));
});
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
pipe(squoosh())
multiple times.ImagePool
instance. Create singleton instance.When running with the current Node.js LTS 18, the following error is encountered.
[email protected]: The engine "node" is incompatible with this module. Expected version " ^14.0.0 || ^16.0.0 ". Got "18.12.1"
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
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.