cityjson / cityjson-threejs-loader

Apache License 2.0
19 stars 10 forks source link

got error "Uncaught Error: Cannot find module './geometry/GeometryData'" #5

Open hopezh opened 2 years ago

hopezh commented 2 years ago

I got the following error after using import { CityJSONLoader, CityJSONWorkerParser } from "cityjson-threejs-loader"; in script.js.

The module was installed via npm i cityjson-threejs-loader.

May I ask what the error means, and how to fix it?

Thanks.

Uncaught Error: Cannot find module './geometry/GeometryData'
    webpackMissingModule bundle.9478a3eba0cd7458.js:56419
    js bundle.9478a3eba0cd7458.js:56419
    Webpack 6
        __webpack_require__
        js
        __webpack_require__
        <anonymous>
        <anonymous>
        <anonymous>
[bundle.9478a3eba0cd7458.js:56419:50](http://192.168.50.92:8080/bundle.9478a3eba0cd7458.js)
    webpackMissingModule bundle.9478a3eba0cd7458.js:56419
    js bundle.9478a3eba0cd7458.js:56419
    Webpack 6
        __webpack_require__
        js
        __webpack_require__
        <anonymous>
        <anonymous>
        <anonymous>
liberostelios commented 2 years ago

Hi @hopezh,

I am not entirely sure what's wrong here. I am assuming webpack is doing things differently than parcel.js and something is broken regarding imports.

Would you mind sharing your webpack config? Or even the whole project?

hopezh commented 2 years ago

Thank you, @liberostelios

Unfortunately, the project files (web dev files and CityJSON data files) are confidential, and I'm unable to post it here.

The three webpack related config files in the "bundler" folder are attached here for your reference.

webpack_config_files.zip

liberostelios commented 2 years ago

I think this is because your webpack configuration doesn't play well with the hybrid (and, I have to admit, a bit sloppy 😊) import of TypeScript and JavaScript files used.

Since I am not able to reproduce the issue, I'd like ask your help. Here is an hacky way to figure out if this is the case:

  1. Open file node_modules/cityjson-threejs-loader/src/parsers/CityJSONWorkerParser.js.
  2. Replace line 3 to: import { POINTS, LINES, TRIANGLES } from './geometry/GeometryData';

It might fail again, but the error message should complain about other modules not included (my assumption is that it will complain about TriangleParser).

If that's the case, there are two ways to resolve this:

  1. You can try to fix it on your end by making the webpack work with TypeScript modules (I am no webpack expert, so I can't help with that).
  2. I can try to fix on my end by including only the JavaScript files and release a fix for it. It might take a bit longer and since I can't reproduce the problem, you might still find more issues.

If you are on a hurry, you can keep doing this for all import lines in the code for which the code complains, until I fix it on my end. But this isn't a proper solution.

Let me know what you get and we see.