I’ve been trying to load some npm modules in Scriptable to make development easier and code shorter.
With importModule, I was able to load most of the modules I want so far.
Though, here is the challenge.
Some npm modules have require() statements to load its internal modules.
This would fail with RefferenceError as require variable is not found.
I tried adding this one liner at the top of my file before loading the module
require = importModule
let get = require(‘lib/lodash/get’)
thinking that might make require function global so that it would be available while evaluating the module’s source code; it failed.
I’m trying to understand why it doesn’t work the way I want.
Also, is it possible to make a variable global and be available in other Scriptable files while running other module source via importModule?
A help would be greatly appreciated!