Is the code in ES6 modules executed every time we import a module? I'm using webpack and it seems that it does exactly that.
// FormStore.js
import sessionActions from "../../session/actions/session";
// session.spec.js
import sessionActions from "../../../src/session/actions/session";
This causes the code in the session module to be executed twice
I don't know exactly the answer, but I suspect it has to do with karma. I think it's due to having two different bundles.
In karma.config
preprocessors: {
"client/specs/index.ts": ["webpack"],
"client/specs/**/*spec.ts": ["webpack"]
},
webpack: {
entry: {
index: "./client/src/index.tsx",
vendor: []
}
},
Basically, I don't really need to add the index
entry point, as this will probably create an additional bundle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With