-
Notifications
You must be signed in to change notification settings - Fork 11
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
Make the package compatible Node.js and others runtimes #30
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8cad65a
fix: remove the only dep to use native Uint8Array as recommended here…
riderx c33ee9d
feat: add npm build
riderx 8cbad31
fix: add gitignore npm folder
riderx 162238a
fix: use the name of the author for the Pr
riderx 44908aa
fix: only shim tests
riderx b216061
fix: use better type
riderx 9449e0d
fix: rollback deps change
riderx fee6b0d
fix: make test integration pass in nodejs
riderx 81b931b
fix: lint and fmt
riderx c50b5ca
fix: npm build and test
riderx 8cbf075
fix: simplify the problem and fix the tests
riderx 1835840
fix: lint issue
riderx 811be45
fix: use optional shiming like oak
riderx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { build, emptyDir } from "https://deno.land/x/dnt@0.40.0/mod.ts"; | ||
|
||
const version = Deno.args[0]; | ||
|
||
if (!version) { | ||
throw new Error("Please specify a version."); | ||
} | ||
|
||
await emptyDir("./npm"); | ||
|
||
await build({ | ||
entryPoints: ["./mod.ts"], // Replace with your actual entry point | ||
outDir: "./npm", | ||
testPattern: "**/*(*.test|integration).{ts,tsx,js,mjs,jsx}", | ||
shims: { | ||
deno: { | ||
test: "dev", | ||
}, | ||
}, | ||
compilerOptions: { | ||
lib: ["ESNext", "DOM"], | ||
}, | ||
mappings: { | ||
"node:stream/web": { | ||
name: "node:stream/web", | ||
}, | ||
}, | ||
package: { | ||
name: "s3-lite-client", | ||
version: version, | ||
description: "This is a lightweight S3 client for Node.js and Deno.", | ||
license: "MIT", | ||
repository: { | ||
type: "git", | ||
url: "git+https://github.com/bradenmacdonald/deno-s3-lite-client.git", | ||
}, | ||
bugs: { | ||
url: "https://github.com/bradenmacdonald/deno-s3-lite-client/issues", | ||
}, | ||
engines: { | ||
"node": ">=20", | ||
}, | ||
author: { | ||
"name": "Braden MacDonald", | ||
"url": "https://github.com/bradenmacdonald", | ||
}, | ||
contributors: [ | ||
"Martin Donadieu <martindonadieu@gmail.com> (https://martin.solos.ventures/)", | ||
], | ||
devDependencies: { | ||
"@types/node": "^20.11.1", | ||
}, | ||
keywords: [ | ||
"api", | ||
"lite", | ||
"amazon", | ||
"minio", | ||
"cloud", | ||
"s3", | ||
"storage", | ||
], | ||
}, | ||
postBuild() { | ||
// Copy additional files to the npm directory if needed | ||
Deno.copyFileSync("LICENSE", "npm/LICENSE"); | ||
Deno.copyFileSync("README.md", "npm/README.md"); | ||
}, | ||
}); | ||
|
||
console.log("Build complete. Run `cd npm && npm publish && cd ..`."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
{ | ||
"fmt": { | ||
"lineWidth": 120 | ||
"lineWidth": 120, | ||
"exclude": ["npm/"] | ||
}, | ||
"lock": false | ||
"lint": { | ||
"exclude": ["npm/"] | ||
}, | ||
"lock": false, | ||
"tasks": { | ||
"test-integration": "deno test --allow-net integration.ts", | ||
"npm-build": "deno run -A --no-check build_npm.ts", | ||
"npm-publish": "cd npm && npm publish && cd .." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
import "./node_shims.ts"; | ||
|
||
export { Client as S3Client } from "./client.ts"; | ||
export * as S3Errors from "./errors.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
if (!("ReadableStream" in globalThis) || !("TransformStream" in globalThis) || !("WritableStream" in globalThis)) { | ||
(async () => { | ||
const { ReadableStream, TransformStream, WritableStream } = await import("node:stream/web"); | ||
Object.defineProperties(globalThis, { | ||
"ReadableStream": { | ||
value: ReadableStream, | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}, | ||
"TransformStream": { | ||
value: TransformStream, | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}, | ||
"WritableStream": { | ||
value: WritableStream, | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}, | ||
}); | ||
})(); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this ^ merging into globals will be done automatically by
dnt
if you specify it in the DNT configshims.custom
:See denoland/dnt#362 and this integration test which checks that this approach works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it here, and it does work on Node.js env but break in Workers env.
That why I implemented as oak project does (made by a Deno maintainer)