Recent versions of Node.js added a feature called “Customization Hooks”. This lets you change the way modules load. In other words, you can control how import works.

I wondered…could you import a JavaScript file from BitTorrent? Could you import a module from a .torrent file?

Introducing torrent-import

After a few days of work, I built torrent-import. It lets you import Node modules from .torrent files or magnet: URIs. Use it like this:

import { greet } from "./greet.js.torrent";
console.log(greet());

After installing the module and grabbing greet.js.torrent, you can run it like this:

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help