I am trying to read a file from ipfs/internet and then execute it in a meteor-environment. As one cannot place functions in a json-file, I thought I'd try this approach where the function code is separated in two string fields and then put togheter with new Function(arguments, body)
.
The problem I've encountered is that this...
new Function("message, signedMessage", 'import {elliptic} from "elliptic";')
creates this...
SyntaxError: Unexpected token import
That is, javascript doesn't seem to be able to read Meteor-specific (?) code such as import
. It works fine with the node-notation const elliptic = require("elliptic");
.
Is it possible to use new Function()
to accept code with import
-notation into the meteor framework?
Also, any suggestions on how to solve my main problem (getting code from the net into the meteor framework) is appreciated. :-)