Skip to content

Commit

Permalink
feat: esm (#87)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ESM only

* feat: esm

* Update index.js

Co-authored-by: Diego Rodríguez Baquero <[email protected]>

Co-authored-by: Diego Rodríguez Baquero <[email protected]>
  • Loading branch information
ThaUnknown and DiegoRBaquero authored Dec 6, 2022
1 parent 84de071 commit 83873a9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/*! torrent-discovery. MIT License. WebTorrent LLC <https://webtorrent.io/opensource> */
const debug = require('debug')('torrent-discovery')
const DHT = require('bittorrent-dht/client') // empty object in browser
const EventEmitter = require('events').EventEmitter
const parallel = require('run-parallel')
const Tracker = require('bittorrent-tracker/client')
const LSD = require('bittorrent-lsd')
import Debug from 'debug'
import DHT from 'bittorrent-dht/client.js' // empty object in browser
import { EventEmitter } from 'events'
import parallel from 'run-parallel'
import Tracker from 'bittorrent-tracker/client.js'
import LSD from 'bittorrent-lsd'

const debug = Debug('torrent-discovery')

class Discovery extends EventEmitter {
constructor (opts) {
Expand Down Expand Up @@ -219,4 +221,4 @@ class Discovery extends EventEmitter {
}
}

module.exports = Discovery
export default Discovery
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"url": "https://webtorrent.io"
},
"browser": {
"bittorrent-dht/client": false,
"bittorrent-dht/client.js": false,
"bittorrent-lsd": false
},
"chromeapp": {},
"bugs": {
"url": "https://github.com/webtorrent/torrent-discovery/issues"
},
"type": "module",
"dependencies": {
"bittorrent-dht": "^10.0.7",
"bittorrent-tracker": "^9.19.0",
Expand Down Expand Up @@ -44,7 +45,12 @@
"peer discovery"
],
"license": "MIT",
"main": "index.js",
"engines": {
"node": ">=12.20.0"
},
"exports": {
"import": "./index.js"
},
"repository": {
"type": "git",
"url": "git://github.com/webtorrent/torrent-discovery.git"
Expand Down
8 changes: 4 additions & 4 deletions test/announce.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const DHT = require('bittorrent-dht')
const Discovery = require('../')
const randombytes = require('randombytes')
const test = require('tape')
import DHT from 'bittorrent-dht'
import Discovery from '../index.js'
import randombytes from 'randombytes'
import test from 'tape'

test('initialize with dht', t => {
t.plan(5)
Expand Down
8 changes: 4 additions & 4 deletions test/basic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discovery = require('../')
const DHT = require('bittorrent-dht')
const randombytes = require('randombytes')
const test = require('tape')
import Discovery from '../index.js'
import DHT from 'bittorrent-dht'
import randombytes from 'randombytes'
import test from 'tape'

test('initialize with dht', t => {
t.plan(1)
Expand Down
8 changes: 4 additions & 4 deletions test/reuse-dht.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Discovery = require('../')
const DHT = require('bittorrent-dht')
const randombytes = require('randombytes')
const test = require('tape')
import Discovery from '../index.js'
import DHT from 'bittorrent-dht'
import randombytes from 'randombytes'
import test from 'tape'

test('re-use dht, verify that peers are filtered', t => {
t.plan(5)
Expand Down

0 comments on commit 83873a9

Please sign in to comment.