Import IIFE Scripts #11145
-
How can I go about importing an IIFE script for use in a deno program? We have a library of JS that currently must target ES3 because a production product uses a tool with an older JS engine, and this is non-negotiable. But I need to be able to use this library in deno, and I can't convert it to ES modules. The library is currently using function-closure modules, ala Crockford, where every source is a single constructor function like this:
and then the module is consumed with Is there any way I can use these in deno? I don't care how, exactly -- I can load the script and eval it if necessary, but it would be nice to just use some form of import. Any suggestions would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The key was to wrap the source file with
|
Beta Was this translation helpful? Give feedback.
The key was to wrap the source file with
Function(return (+ ... +);)()
to get a reference to the module constructor function, which can then be constructed. I'm open to better ideas, but this works for my case.