RevillWeb / img-2

Replace <img /> elements with <img-2> to automatically pre-cache images and improve page performance.
MIT License
1.89k stars 63 forks source link

Why do I report an error? Are there examples? #12

Open 750973092 opened 6 years ago

750973092 commented 6 years ago

xi 1e supy 7 h1vb5n be02guh u8x5nwfl s 33

abraham commented 6 years ago

Try

import 'img-2/dist/img-2';
AlexGustafsson commented 6 years ago

@abraham Your solution works. However, shouldn't the expected behavior be to use either import img-2 as that's the package's name or import Img2 since that's what the documentation shows?

abraham commented 6 years ago

The package name is img-2 as defined by name in package.json. When you install with npm, this is the name you should use to import. I think import 'Img2' was just wrong.

When you do import 'img-2' the loader will typically look for the file defined by main in package.json. Before #10 this was incorrectly pointing at a file that didn't exist.

As a current workaround use import 'img-2/dist/img-2' to explicitly specify the file to load. Once a new version get's published to npm you can switch to import 'img-2'.

RevillWeb commented 6 years ago

Republished as 0.0.4 with the fix provided by @abraham 👍