Clearscript: Import V8 Module Cache? Refresh?

Created on 21 May 2020  路  3Comments  路  Source: microsoft/ClearScript

I have been looking at the V8 Import capabilities and managed to get it working as below
Top Level File level1.js

import HelloWorld  from 'modules/level2.js'
HelloWorld()

Module file level2.js

export default function HelloWorld() {
    console.log("Hello World How Are you today!!")
}

My program is an automation tool that uses ClearScript at the backend. Therefore the scripts get executed multiple times at user discretion. During coding of the scripts if I make changes to the Module level2.js whilst the parent program is still running (but the scripts have finished) the original level2.js is executed instead of the updated code. If I stop and restart the parent program then the correct level2.js is executed.

This sounds like some sort of engine cache? Is this the case? Can I flush this somehow or tell engine not to cache the imported modules?

question

All 3 comments

I just found this in some of your Test Code which seems to have resolved this.

                DocumentLoader.Default.DiscardCachedDocuments();
                GC.Collect();
                GC.WaitForPendingFinalizers();

Hi @egooner,

The DiscardCachedDocuments call should be sufficient.

Please reopen this issue if you have additional questions or concerns.

Thanks!

Thanks - been working through this and found the same. :)

Was this page helpful?
0 / 5 - 0 ratings