paulbartrum / jurassic

A .NET library to parse and execute JavaScript code.
MIT License
873 stars 122 forks source link

How to execute loading module by require? #187

Open lhf552004 opened 4 years ago

lhf552004 commented 4 years ago

Hi, I'm going to load a module below: var lunrMutable = require('lunr-mutable-indexes'); But I don't know how to load this module correctly. My steps is load a single file /lunr-mutable-indexes/lunr-mutable.js But it is failed. The problem is this module is not a single file, besides it would load another module inside it. For example it would load lunr module.

engine = new Jurassic.ScriptEngine();
engine.ExecuteFile("lib/require.js/require.min.js");
engine.ExecuteFile("lib/lunr.js/lunr.js");
//engine.Execute("var lunrMutable = require('lunr-mutable-indexes');");
engine.ExecuteFile("lib/lunr-mutable-indexes/lunr-mutable.js");

image image

paulbartrum commented 4 years ago

require() is a node.js-specific thing I think. There's a standard (ECMAScript) replacement called "import" but Jurassic doesn't support that either :-(