-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Milestone
Description
I'm just trying to create a simple route to test sqip which looks really really cool. I had issue with sharp that I fixed updating nextjs webpack config but now I'm facing another error:
sqip Loading sqip-plugin-primitive +0ms
sqip Loading sqip-plugin-data-uri +0ms
Error: Unable to load plugin "sqip-plugin-primitive". Try installing it via:
npm install sqip-plugin-primitive
at eval (webpack-internal:///(rsc)/./node_modules/.pnpm/sqip@1.0.0-alpha.41_@vibrant+color@3.2.0-alpha.1_sqip-plugin-blur@1.0.0-alpha.22_sqip-plugin-_l2j7ib26irsjvtky3rkbdcveiu/node_modules/sqip/dist/sqip.js:144:31)
at Generator.throw (<anonymous>)
at rejected (webpack-internal:///(rsc)/./node_modules/.pnpm/sqip@1.0.0-alpha.41_@vibrant+color@3.2.0-alpha.1_sqip-plugin-blur@1.0.0-alpha.22_sqip-plugin-_l2j7ib26irsjvtky3rkbdcveiu/node_modules/sqip/dist/sqip.js:50:40)
I'm using node v20.9.0v18.18.2
Here is the app/sqip/route.ts file:
import { sqip } from 'sqip';
import axios from 'axios';
import { NextResponse } from 'next/server';
export async function GET() {
try {
const { data } = await axios({
method: 'get',
url: 'https://cdn.vox-cdn.com/thumbor/WR9hE8wvdM4hfHysXitls9_bCZI=/0x0:1192x795/1400x1400/filters:focal(596x398:597x399)/cdn.vox-cdn.com/uploads/chorus_asset/file/22312759/rickroll_4k.jpg,
responseType: 'arraybuffer',
});
const result = await sqip({
input: data,
// Fix required "outputFileName" when using buffer
outputFileName: 'whatever',
plugins: [
{
name: 'sqip-plugin-primitive',
options: {
numberOfPrimitives: 8,
mode: 0,
},
},
'sqip-plugin-data-uri',
],
});
console.log(result);
return Response.json({ ok: true });
} catch (err) {
console.error(err);
}
}package.json
{
"sharp": "^0.32.6",
"sqip": "1.0.0-alpha.41",
"sqip-plugin-data-uri": "1.0.0-alpha.42",
"sqip-plugin-primitive": "1.0.0-alpha.43",
"sqip-plugin-svgo": "1.0.0-alpha.43"
}and my next.config.js
module.exports = {
webpack: (config) => {
return {
...config,
externals: {
sharp: 'commonjs sharp',
},
};
},
};