Skip to content

Commit

Permalink
refactor: replace node-fetch's FormData and Blob with `formdata…
Browse files Browse the repository at this point in the history
…-node` (#3)
  • Loading branch information
angeloashmore committed Dec 15, 2022
1 parent b3ea7b9 commit 32b1a63
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 12 deletions.
55 changes: 51 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Expand Up @@ -21,9 +21,9 @@
"types": "./dist/index.d.ts"
},
"./client": {
"require": "./dist/client.cjs",
"import": "./dist/client.js",
"types": "./dist/client.d.ts"
"require": "./dist/client/index.cjs",
"import": "./dist/client/index.js",
"types": "./dist/client/index.d.ts"
},
"./package.json": "./package.json"
},
Expand Down Expand Up @@ -53,8 +53,8 @@
"dependencies": {
"busboy": "^1.6.0",
"devalue": "^4.2.0",
"h3": "^1.0.2",
"node-fetch": "^3.3.0"
"formdata-node": "^5.0.0",
"h3": "^1.0.2"
},
"devDependencies": {
"@size-limit/preset-small-lib": "^8.1.0",
Expand All @@ -66,6 +66,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-tsdoc": "^0.2.17",
"node-fetch": "^3.3.0",
"prettier": "^2.8.1",
"prettier-plugin-jsdoc": "^0.4.2",
"size-limit": "^8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/objectToFormData.server.ts
@@ -1,5 +1,5 @@
import { Buffer } from "node:buffer";
import { FormData, Blob } from "node-fetch";
import { FormData, Blob } from "formdata-node";

import { flattenObject } from "./flattenObject";
import { serialize } from "./serialize";
Expand Down
1 change: 1 addition & 0 deletions src/lib/sendFormData.ts
Expand Up @@ -57,6 +57,7 @@

import { Readable } from "node:stream";
import { H3Event, sendStream, setHeaders } from "h3";
import { FormData } from "formdata-node";

/**
* Reads from a given ReadableStream.
Expand Down
2 changes: 1 addition & 1 deletion test/__setup__.ts
@@ -1,5 +1,5 @@
import { vi } from "vitest";
import { FormData, Blob } from "node-fetch";
import { FormData, Blob } from "formdata-node";

vi.stubGlobal("FormData", FormData);
vi.stubGlobal("Blob", Blob);
11 changes: 10 additions & 1 deletion vite.config.ts
Expand Up @@ -2,7 +2,16 @@ import { defineConfig } from "vite";
import sdk from "vite-plugin-sdk";

export default defineConfig({
plugins: [sdk()],
plugins: [
sdk({
internalDependencies: ["formdata-node"],
}),
],
build: {
lib: {
entry: ["./src/index.ts", "./src/client/index.ts"],
},
},
test: {
coverage: {
reporter: ["lcovonly", "text"],
Expand Down

0 comments on commit 32b1a63

Please sign in to comment.