Webpack can't recognize modules

Good day! I’ve got errors Uncaught TypeError: setting getter-only property "todo" and Uncaught TypeError: lib is undefined. My assumption is that those errors appear when I created a new module for local storage API.
I moved specific functions of local storage to that module.
When the whole code stored in the global scope, app functions fine without issues. The syntax for named export/import is correct.

You can check my repository here

The code from storage module:

export let todo = JSON.parse(localStorage.getItem("todo-list"));

export function setLocalStorage() {
    localStorage.setItem("todo-list", JSON.stringify(todo));
  }
  

How it’s imported:

import { todo, setLocalStorage } from "./modules/storageModule";

Looks to be caused by the "inline-source-map" option you have in webpack.dev.js.

If I remove the inline- it works (just as it does when I build, and it uses webpack.prod.js instead).

1 Like

I tried it, it still doesn’t work for me. But if I use build config without server, it works fine. I think, I will just build manually every time when I need to refresh the page :sweat_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.