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

chore(cjs/esm): Bundle module and use package exports #1227

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -38,3 +38,5 @@ jobs:
- run: npm install

- run: npm test -- --colors

- run: npm run build
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -37,6 +37,9 @@ node_modules
# Babel-compiled files
lib

# esbuild-compiled files
dist

# Ignore package manager lock files
package-lock.json
yarn.lock
Expand Down
25 changes: 17 additions & 8 deletions package.json
Expand Up @@ -2,22 +2,32 @@
"name": "node-fetch",
"version": "3.0.0-beta.10",
"description": "A light-weight module that brings Fetch API to node.js",
"main": "./src/index.js",
"main": "./dist/index.mjs",
"sideEffects": false,
"type": "module",
"files": [
"src",
"dist",
"@types/index.d.ts"
],
"types": "./@types/index.d.ts",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
"build:esm": "esbuild src/index.js --bundle --platform=node --format=esm --outfile=dist/index.mjs",
"build:cjs": "esbuild src/index.js --bundle --platform=node --format=cjs --outfile=dist/index.cjs",
"test": "mocha",
"coverage": "c8 report --reporter=text-lcov | coveralls",
"test-types": "tsd",
"lint": "xo"
"lint": "xo",
"prepublishOnly": "npm run build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -53,18 +63,17 @@
"chai-iterator": "^3.0.2",
"chai-string": "^1.5.0",
"coveralls": "^3.1.0",
"data-uri-to-buffer": "^3.0.1",
"delay": "^5.0.0",
"esbuild": "^0.12.16",
"fetch-blob": "^3.1.2",
"form-data": "^4.0.0",
"formdata-node": "^3.5.4",
"mocha": "^8.3.2",
"p-timeout": "^5.0.0",
"tsd": "^0.14.0",
"xo": "^0.39.1"
},
"dependencies": {
"data-uri-to-buffer": "^3.0.1",
"fetch-blob": "^3.1.2"
},
"tsd": {
"cwd": "@types",
"compilerOptions": {
Expand Down Expand Up @@ -115,4 +124,4 @@
]
},
"runkitExampleFilename": "example.js"
}
}