Skip to content

Commit

Permalink
tree-shake node bundle (nodejs#1187)
Browse files Browse the repository at this point in the history
* tree-shake node bundle

* Update index-fetch.js

Co-authored-by: Robert Nagy <ronagy@icloud.com>
  • Loading branch information
2 people authored and metcoder95 committed Dec 26, 2022
1 parent 80a1dab commit d785342
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -75,3 +75,6 @@ yarn.lock
corpus/
crash-*
fuzz-results-*.json

# Bundle output
undici-fetch.js
15 changes: 15 additions & 0 deletions index-fetch.js
@@ -0,0 +1,15 @@
'use strict'

const Agent = require('./lib/agent')

const globalDispatcher = new Agent()

const fetchImpl = require('./lib/fetch')
module.exports.fetch = async function fetch (resource, init) {
return fetchImpl.call(globalDispatcher, resource, init)
}
module.exports.FormData = require('./lib/fetch/formdata').FormData
module.exports.Headers = require('./lib/fetch/headers').Headers
module.exports.Response = require('./lib/fetch/response').Response
module.exports.Request = require('./lib/fetch/request').Request

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -40,7 +40,7 @@
"docs"
],
"scripts": {
"build:node": "npx esbuild@0.14.25 index.js --bundle --platform=node --outfile=undici.js",
"build:node": "npx esbuild@0.14.25 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js",
"prebuild:wasm": "docker build -t llhttp_wasm_builder -f build/Dockerfile .",
"build:wasm": "node build/wasm.js --docker",
"lint": "standard | snazzy",
Expand Down

0 comments on commit d785342

Please sign in to comment.