I have three separate libraries -
- Lib A - Hosts shared code and uses babel to transpile the code into a /lib folder
- Lib B - which uses libA (imports the babel transpiled code) and it uses webpack to generate the bundle in a dist folder (dist/index.js). It also exports a global function "myGlobalFunction" by attaching it to a window.
- Lib C - Uses both A and the global "myGlobalFunction".
Issue is, the window.myGlobalFunction when accessed from lib C, prints undefined.
In Library B, if I import the contents of Lib A from src/ instead of the transpiled lib/, my issue gets resolved automatically.
Not sure why this is happening. Also, I have disabled the es modules transpilation in babel by setting
{modules: false}
in babelrc of the libA.
I have a problem similar to this one but the solution posted there didnt work either as I need to use the global in some another library by directly looking in the Window object.
All the libraries are separate npm packages.