I have a problem with importing modules and created a small testapp to demonstrate.
The (client-only) app has 4 files, structured like this:
client
imports
x1.jsx
x2.js
x3.jsx
main.js
x1.jsx:
export let x1 = 1;
x2.js:
import {x1} from './x1.jsx'
export let x2 = x1 + 1;
x3.jsx:
import {x1} from './x1.jsx'
export let x3 = x1 + 2;
main.js:
// import {x2} from './imports/x2'
import {x3} from './imports/x3.jsx'
console.log('x3: ' + x3);
When running like this it produces:
Uncaught Error: Cannot find module './x1.jsx'
If I uncomment the first line in main.js (the x2-import), everything is ok:
x3: 3
I don’t see why the x1 module cannot be found and how importing un unused variable {x2}
can make the problem disappear…?
You can find the testapp here if you want to check it out.