sebastienros / jint

Javascript Interpreter for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module resolution does not work for absolute path

croban opened this issue · comments

I'm trying to update from 3.0.0-beta-2053 to 3.0.1, but I get exception when an module importing module which have absolute paths
Jint.Runtime.JavaScriptException : Could not load module /generated/dictionary.js

What i have is following unit test

var engine = new Engine(options =>  {
        options.EnableModules("C:\\SomeFolder\\", false);
});

// on the server this is exported as below - for the client - real js will be generated on the fly 
engine.Modules.Add("/generated/dictionary.js", builder => builder
    .ExportFunction("findTranslationByKey", values => $"hier comes translation {values[0]}"));

// this module rexports function from generated dictionary and it is imported by other modules 
var trans = engine.Modules.Import("./Dictionary-2cf62bb1.js")
    .Get("T");<- this line throws Could not load module /generated/dictionary.js

var data = engine.Invoke(trans, JsValue.FromObject(engine, "tanskey")); 

This is content of ./Dictionary-2cf62bb1.js is:

import{findTranslationByKey as r}from"/generated/dictionary.js";function e(e){return r(e,"de")}export{e as T};

A working repro or a pull request to fix things would be appreciated.

Closing due to inactivity.

Are you referring to something along the lines of Fork of JINT, @lahma?
I found that prefixing the generated name with file:///C:... allows the test to pass, which works for me.