Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module error #305

Closed
danielfdsilva opened this issue Nov 4, 2022 · 2 comments
Closed

Cannot find module error #305

danielfdsilva opened this issue Nov 4, 2022 · 2 comments

Comments

@danielfdsilva
Copy link
Collaborator

When accessing the analysis page at https://veda-ui.netlify.app/covid-19/analysis, A module not found error is presented:

image

I did some debugging around this issue and I have a general idea about what is happening, but couldn't figure out how to solve this.

The module in question refers to the file app/scripts/utils/format.ts which parcel is internally naming aV6JG. There's nothing special about this file as far as I can tell, it just happened to be this one.

There are several files using functions exported by this file, like:

  • app/scripts/components/home/index.tsx
  • app/scripts/components/common/mapbox/map.tsx
  • app/scripts/components/common/mapbox/layer-legend.tsx
  • app/scripts/components/common/chart/utils.ts
  • app/scripts/components/common/blocks/scrollytelling/chapter.tsx
  • app/scripts/components/common/blocks/block-map.tsx
  • app/scripts/components/common/aoi/utils.ts

To avoid duplicating the code multiple times, parcel will just package it once, name it something (aV6JG) and then reference it every time.

It seems that this behavior is clashing with code splitting. Each of our route components (Home, Analysis, About, etc) is being separated into a different file, and only loaded when needed. (Done automatically when using import('path') in app/scripts/main.js)

The problem here is that parcel is placing the code for our utils/format, inside Home (Home uses the zeroPad function from the file). When we load the analysis page, the file for Home is not loaded, hence the "module not found". This also explains why if you start at the site root, select a thematic area and then Analysis it works. The Home file was loaded and so the module is registered.

The next thing I'm going to try is to update parcel to the most recent version and see if it does anything.
cc @nerik @hanbyul-here (@olafveerman if you're curious)

@danielfdsilva
Copy link
Collaborator Author

Updating to the newest version (2.7.0) does not solve the issue, even though the mention updates to the bundler.

The bundler pr mentions missing module in large app -> Fix to come, which is not a promising sign. (this checkbox is not ticked because is not done, or because they forgot?)

@danielfdsilva
Copy link
Collaborator Author

I experimented switching the bundler with the experimental one and seems to be working. Will conduct more tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant