Skip to content

Commit ee36eb0

Browse files
authored
Merge pull request #74 from dopecodez/fix-ts-exports
Changed imports and added roll up to create a cjs file to allow users to keep using commonjs require.
2 parents 6604e65 + 98fd840 commit ee36eb0

File tree

4 files changed

+2420
-2454
lines changed

4 files changed

+2420
-2454
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
node-version:
24-
- 16
2524
- 18
2625
- 20
26+
- 22
2727
steps:
2828
- uses: actions/checkout@v5
2929
- uses: actions/setup-node@v6
@@ -39,7 +39,7 @@ jobs:
3939
- uses: actions/checkout@v5
4040
- uses: actions/setup-node@v6
4141
with:
42-
node-version: '18'
42+
node-version: '20'
4343
- run: yarn
4444
- run: yarn test
4545
- uses: codecov/codecov-action@v5

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"name": "wikipedia",
33
"version": "2.3.0",
44
"description": "A JavaScript wrapper for the wikipedia apis",
5-
"main": "dist",
5+
"main": "dist/index.js",
66
"engines": {
77
"node": ">=10"
88
},
9+
"exports": {
10+
"import": "./dist/index.js",
11+
"require": "./dist/index.cjs"
12+
},
913
"scripts": {
10-
"prepublishOnly": "tsc --build --clean && tsc",
14+
"prepublishOnly": "tsc --build --clean && tsc && npx rollup ./dist/index.js --file ./dist/index.cjs --format cjs",
1115
"test": "jest --coverage",
12-
"build": "yarn lint && tsc --build --clean && tsc",
16+
"build": "yarn lint && tsc --build --clean && tsc && npx rollup ./dist/index.js --file ./dist/index.cjs --format cjs",
1317
"prepare": "yarn build",
1418
"lint": "eslint source/*.ts",
1519
"release": "np"
@@ -30,6 +34,7 @@
3034
"eslint": "^8.30.0",
3135
"eslint-plugin-tsdoc": "^0.2.17",
3236
"jest": "^29.3.1",
37+
"rollup": "^4.52.5",
3338
"ts-jest": "^29.0.3",
3439
"typescript": "^4.9.4"
3540
},

source/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,9 @@ wiki.setUserAgent = (userAgent: string) => {
663663
setUserAgent(userAgent);
664664
}
665665

666-
export default wiki;
667-
// For CommonJS default export support
668-
module.exports = wiki;
669-
module.exports.default = wiki;
670-
671666
export * from './errors';
672667
export * from './resultTypes';
673668
export * from './optionTypes';
674-
export * from './page';
669+
export * from './page';
670+
671+
export default wiki;

0 commit comments

Comments
 (0)