iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.07k stars 291 forks source link

Error running tests #2273

Closed Diaaz closed 3 months ago

Diaaz commented 4 months ago

In version 2.42.0, when running tests in our project (npm run t) an error occurs:

./node_modules/copc/lib/utils/getter.js:78:65-78 - Error: Module not found: Error: Can't resolve 'fs' in 'Angular\node_modules\copc\lib\utils'

copc is a package reference in itowns package.json. Copc has a file getter.ts (https://github.com/connormanning/copc.js/blob/master/src/utils/getter.ts) which references 'fs'. This package was removed by npm because it contained malicious code: https://www.npmjs.com/package/fs?activeTab=versions

Desplandis commented 4 months ago

@Diaaz fs is a module of the node.js standard library and thus not available in a browser context. It is lazy-loaded by the copc.js if we are in a node.js environnement which is not the case for iTowns. However it seems that webpack is not smart enough to eliminate this unused code leading to this error... A temporary fix for this issue is available in our webpack.config.js: https://github.com/iTowns/itowns/blob/4f361c34a38be0dbad754ac2ce2940f894502f7c/webpack.config.js#L85

I will try to push a fix upstream to resolve this issue.

Desplandis commented 3 months ago

I pushed a fix upstream (see connormanning/copc.js#7), waiting for review. =)

Diaaz commented 3 months ago

Thanks for that! I see it was merged :)

Diaaz commented 3 months ago

Thanks, everything works in version 2.43.0.