itowns icon indicating copy to clipboard operation
itowns copied to clipboard

Error running tests

Open Diaaz opened this issue 1 year ago • 1 comments

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

Diaaz avatar Feb 15 '24 05:02 Diaaz

@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 avatar Mar 06 '24 09:03 Desplandis

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

Desplandis avatar Mar 22 '24 16:03 Desplandis

Thanks for that! I see it was merged :)

Diaaz avatar Mar 25 '24 05:03 Diaaz

Thanks, everything works in version 2.43.0.

Diaaz avatar Apr 04 '24 08:04 Diaaz