codedread / bitjs

Binary Tools for JavaScript
MIT License
81 stars 7 forks source link

Angular 9 + "no loaders are configured" #24

Closed SamPool1 closed 9 months ago

SamPool1 commented 4 years ago

Hi there,

Was hoping you could help me out. I'm trying to use your bitjs in an angular 9 application and I am running into this problem:

./node_modules/@codedread/bitjs/image/webp-shim/webp-shim.js 9:18
Module parse failed: Unexpected token (9:18)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> const url = import.meta.url;
| if (!url.endsWith('/webp-shim.js')) {
|   throw 'webp-shim must be loaded as webp-shim.js';

I've made sure all of the JS files are imported properly, and followed your simple example but can't seem to figure out what i'm doing wrong.

Thanks for your help

EDIT: I double checked and I am receiving the file from the api as a type arraybuffer.

codedread commented 4 years ago

Hi there - this is a new issue to me.

Browser support for import.meta.url was added recently [1], but support for it in webpack was only added in version 5[2]. Can you manually update to webpack 5+ ?

On the other hand, support for WebP in Safari is coming along now [3], so maybe you don't even need this feature (loading WebP - is that something you need to worry about)?

[1] https://caniuse.com/#search=import.meta [2] https://github.com/webpack/webpack/issues/6719 [3] https://caniuse.com/#search=webp

SamPool1 commented 4 years ago

Hey! Apologies for the delayed response. I think the issue might have to do with Angular 10 not using Webpack (not sure what version they stopped using it, but its been a bit from what I understand). Angular is also throwing a fit on the importScript statements. I'm going to keep messing around with it, and i'll keep you updated if I'm able to get it integrated and how.

codedread commented 1 year ago

Hi there @SamPool1 - is this issue still valid? Any idea?

codedread commented 9 months ago

Closing as obsolete. Pls feel free to re-open if you have more info to share.