Skip to content

Commit

Permalink
feat: support cjs and esm both (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Sep 17, 2023
1 parent c9047b5 commit 49a0e8a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest'
version: '14, 16, 18, 20'
version: '16, 18, 20'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ dist

# TernJS port file
.tern-port

.tshy/
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
GetStreamResult,
CopyObjectOptions,
CopyAndPutMetaResult, SignatureUrlOptions,
} from '.';
} from './src/index.js';

const getObjectOptions = {} as GetObjectOptions;
expectType<string | undefined>(getObjectOptions.process);
Expand Down
43 changes: 35 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,38 @@
"name": "oss-interface",
"version": "1.1.3",
"description": "OSS Client interface",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts"
"dist",
"src"
],
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"scripts": {
"lint": "echo 'ignore'",
"test": "tsd",
"ci": "npm test"
"test": "npm run test:cjs && npm run test:esm",
"test:cjs": "tsd -f index.test-d.ts -t dist/commonjs/index.d.ts",
"test:esm": "tsd -f index.test-d.ts -t dist/esm/index.d.ts",
"ci": "npm run prepublishOnly && npm test",
"contributor": "git-contributor",
"prepublishOnly": "tshy && tshy-after"
},
"repository": {
"type": "git",
Expand All @@ -26,7 +49,11 @@
},
"homepage": "https://github.com/node-modules/oss-interface#readme",
"devDependencies": {
"@types/node": "^20.3.1",
"tsd": "^0.28.1"
}
"@eggjs/tsconfig": "^1.3.3",
"@types/node": "^20.6.2",
"tsd": "^0.29.0",
"tshy": "^1.0.0",
"tshy-after": "^1.0.0"
},
"types": "./dist/commonjs/index.d.ts"
}
2 changes: 1 addition & 1 deletion index.d.ts → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Readable, Writable } from 'stream';
import { Readable, Writable } from 'node:stream';

export type StorageType = 'Standard' | 'IA' | 'Archive';

Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "@eggjs/tsconfig",
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}

0 comments on commit 49a0e8a

Please sign in to comment.