Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree-shake node bundle #1187

Merged
merged 3 commits into from Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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