gfx / universal-zopfli-js

JavaScript binding to Zopfli with WebAssembly.
https://www.npmjs.com/package/@gfx/zopfli
Other
81 stars 3 forks source link

Error: Module not found: Error: Can't resolve './libzopfli-wasm' #15

Open aaltotsky opened 4 years ago

aaltotsky commented 4 years ago

I'm trying to integrate @gfx/zopfli into my Angular9 app. When I run build I got an error:

ERROR in ./node_modules/@gfx/zopfli/dist/libzopfli.js
Module not found: Error: Can't resolve './libzopfli-wasm' in 'C:\Dev\MyApp\ClientApp\node_modules\@gfx\zopfli\dist'

I'm using it as it described in the readme:

import { gzip  } from "@gfx/zopfli";

// All regular routes use the Universal engine
    server.get('*', async (req, res) => {
        res.render(indexHtml, { req }, (_err, html) => {
            if (req.header('Accept-Encoding').includes('gzip')) {
                gzip(html, { numiterations: 15 }, (_err, output) => {
                    // output is compressed in gzip
                    res.set('Content-Encoding', 'gzip');
                    res.send(output);
                });
            }
            else {
                res.send(html);
            }
        });
    });

In the package.json I have: @gfx/zopfli": "^1.0.14" Any suggestions?

jimmykane commented 4 years ago

Same here

jimmykane commented 4 years ago

Did you manage to solve this ?

gfx commented 4 years ago

Hmm. Can you explain more? For example, minimum reproducable code should help me.

I never use this module with Angular, but I use this module long time with NodeJS v10 and v12.

jimmykane commented 4 years ago

Well if you try to use it it fails :-)

aaltotsky commented 4 years ago

I moved away and end up using compression "compression": "^1.7.4" import * as compression from 'compression';

aaltotsky commented 4 years ago

@gfx I think you just need to include the libzopfli-wasm into the distribution package.

jimmykane commented 4 years ago

@aaltotsky I am using Pako. Was looking which also uses gzip and deflate and works superb.

Jeremias-Nater commented 1 year ago

Same Problem. Im looking for brotli compression and 'pako' and 'compression' don't support it. It would be amazing if you could fix this problem