Currently, I am working on a vanilla JavaScript project using Vite and I have encountered an issue that I need help with:
In my app.js file, I am initializing a variable using the let command and exporting it as follows:
let activePoint = null;
export { activePoint };
Next, in another JS file called tool.js, I am importing this variable like so:
import { activePoint } from '../js/app.js'
The problem arises when I attempt to modify this variable (e.g. activePoint=4;
) within the tool.js file. I receive the error message
Uncaught TypeError: Assignment to constant variable.
I have experimented with both let and var, but the outcome remains the same. I also tried combining the initialization and export into one line versus two, yet the behavior does not change. Could there be a Vite-specific behavior that is causing my variables to act like constants?