update
This commit is contained in:
18
bun.config.ts
Normal file
18
bun.config.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import glob from 'fast-glob';
|
||||
import dts from 'bun-plugin-dts';
|
||||
|
||||
const services = await glob('src/services/*.ts');
|
||||
|
||||
await Bun.build({
|
||||
entrypoints: ['src/index.ts', ...services],
|
||||
outdir: './dist',
|
||||
target: 'node',
|
||||
format: 'esm',
|
||||
splitting: false,
|
||||
sourcemap: 'none',
|
||||
minify: false,
|
||||
external: ['minio'],
|
||||
plugins: [dts()],
|
||||
});
|
||||
|
||||
console.log('Build completed!');
|
||||
14
package.json
14
package.json
@@ -1,11 +1,9 @@
|
||||
{
|
||||
"name": "@kevisual/oss",
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.13",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"dev": "tsup --watch",
|
||||
"dev:lib": "tsup --watch"
|
||||
"build": "bun run bun.config.ts"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
@@ -15,6 +13,9 @@
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.3.3",
|
||||
"@types/node": "^24.10.1",
|
||||
"bun-plugin-dts": "^0.3.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"minio": "^8.0.5",
|
||||
"tsup": "^8.4.0"
|
||||
@@ -35,5 +36,10 @@
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.17.21",
|
||||
"fast-glob": "^3.3.3",
|
||||
"lodash": "^4.17.21"
|
||||
}
|
||||
}
|
||||
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
onlyBuiltDependencies:
|
||||
- esbuild
|
||||
14
src/index.ts
14
src/index.ts
@@ -84,18 +84,20 @@ export class OssBase implements OssBaseOperation {
|
||||
let size: number = opts?.size;
|
||||
const isStream = opts?.isStream;
|
||||
if (!isStream) {
|
||||
if (data instanceof Object) {
|
||||
putData = JSON.stringify(data);
|
||||
size = putData.length;
|
||||
} else if (typeof data === 'string') {
|
||||
if (typeof data === 'string') {
|
||||
putData = data;
|
||||
size = putData.length;
|
||||
} else {
|
||||
putData = data;
|
||||
putData = JSON.stringify(data);
|
||||
size = putData.length;
|
||||
}
|
||||
} else {
|
||||
putData = data as any;
|
||||
size = null;
|
||||
// 对于流式上传,如果没有提供 size,会导致多部分上传,ETag 会是 ****-1 格式
|
||||
// 必须提供准确的 size 才能得到标准的 MD5 格式 ETag
|
||||
if (!size) {
|
||||
throw new Error('Stream upload requires size parameter to avoid multipart upload and get standard MD5 ETag');
|
||||
}
|
||||
}
|
||||
if (opts?.check) {
|
||||
const obj = await this.statObject(objectName, true);
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
import glob from 'fast-glob';
|
||||
const services = glob.sync('src/services/*.ts');
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/index.ts', ...services],
|
||||
target: 'node22',
|
||||
splitting: false,
|
||||
sourcemap: false,
|
||||
clean: true,
|
||||
format: 'esm',
|
||||
external: ['minio'],
|
||||
dts: true,
|
||||
outDir: 'dist',
|
||||
tsconfig: 'tsconfig.json',
|
||||
});
|
||||
Reference in New Issue
Block a user