how to require from string ?

Hi all,

I am developing an npm package, but have not published it yet.
So to use it in a notebook, I require it from a file I input each time.
For more convenience, I would like to require it from a file a I attached.
I could not found any example doing that, is there ?

See notebook @oscar6echo/require-from-string

How should I do that ? Any other suggestion ?
By advance, thx for any advice.

This way:

ganj3 = require(await FileAttachment('ganja.js').url())

Super ! :+1:
Thx @severo for the fast and accurate answer.

notebook @oscar6echo/require-from-string updated.

1 Like