About importing external functions to the app page #443
-
Hi! Could you help me with the following problem? I have an app the main page of which imports a number of functions from an external js file, and everything goes just fine until I jump to the settings page by push() and then return by means of back() function. After returning back to the main page I get all my imported functions undefined as if they weren't imported. Is there any way to fix this? As I got it right, I can't import external functions at any other place but at the top of the main_page.js, which means I can't use import statement within my function (which in its turn uses those imported function) to reimport them one more time when I get back to the main_page.js |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Yes, dynamic imports are not supported. You will have to import all the necessary things on each page that requires them. |
Beta Was this translation helpful? Give feedback.
-
We have further investigated this, and it's indeed the issue with the library not being supported by our build tools.
Besides removing the AMD wrapper, which this conversion defaults to // export as Node module / AMD module / browser variable
if (typeof exports === 'object' && typeof module !== 'undefined') module.exports = SunCalc;
else if (typeof define === 'function' && define.amd) define(SunCalc);
else window.SunCalc = SunCalc; you have to re-export the module with ecmascript support. Considering it's mostly built with prototypes, here's the straightforward approach const SunCalc = {};
...
// stuff in between remains the same
...
export default SunCalc; Additionally, it's better to replace all |
Beta Was this translation helpful? Give feedback.
We have further investigated this, and it's indeed the issue with the library not being supported by our build tools.
As suggested
Besides removing the AMD wrapper, which this conversion defaults to
you have to re-export the module with ecmascript support. Considering it's mostly built with prototypes, here's the straightfo…