Skip to content

Commit

Permalink
COM-498 Add CommonJS support (#42)
Browse files Browse the repository at this point in the history
* COM-498 Add CommonJS support

* update package-lock.json
  • Loading branch information
eric-moov authored Apr 4, 2022
1 parent fb7c0bc commit abd2980
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 81 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.18] - 2022-04-04

### Added

- Added CommonJS support

## [0.1.17] - 2022-03-25

### Updated
Expand Down
15 changes: 7 additions & 8 deletions examples/package-lock.json

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

11 changes: 11 additions & 0 deletions fixup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
2 changes: 1 addition & 1 deletion lib/moov.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import got from "got";
import got from "got-cjs";

import {
check,
Expand Down
2 changes: 1 addition & 1 deletion lib/types/moov.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class Moov {
domain: string;
};
tokenCache: {};
got: import("got").Got;
got: import("got-cjs").Got;
_accounts: Accounts;
_capabilities: Capabilities;
_transfers: Transfers;
Expand Down
2 changes: 1 addition & 1 deletion lib/types/moov.d.ts.map

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

131 changes: 65 additions & 66 deletions package-lock.json

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

15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"name": "@moovio/node",
"version": "0.1.17",
"version": "0.1.18",
"description": "Node SDK for the Moov API and Dashboard",
"main": "lib/index.js",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
}
},
"types": "lib/types/index.d.ts",
"type": "module",
"engines": {
"node": ">=14"
},
Expand All @@ -29,6 +35,7 @@
"lib/**/*"
],
"scripts": {
"build": "chmod +x fixup.sh && rm -fr dist/* && tsc -p tsconfig-esm.json && tsc -p tsconfig-cjs.json && ./fixup.sh",
"docs": "node ./scripts/generateDocs.cjs",
"docs-watch": "watch \"npm run docs\" ./docs/templates",
"docs-clean": "rm ./docs/output/*.*",
Expand All @@ -47,6 +54,6 @@
"watch": "^0.13.0"
},
"dependencies": {
"got": "^12.0.0"
"got-cjs": "^12.0.0"
}
}
25 changes: 25 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "lib",
"declaration": true,
"esModuleInterop": true,
"inlineSourceMap": false,
"lib": ["esnext"],
"listEmittedFiles": false,
"listFiles": false,
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"pretty": true,
"resolveJsonModule": true,
"rootDir": "lib",
"skipLibCheck": true,
"strict": true,
"traceResolution": false,
"types": ["node"]
},
"compileOnSave": false,
"exclude": ["node_modules", "dist"],
"include": ["lib/**/*"],
}
8 changes: 8 additions & 0 deletions tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2015"
}
}
8 changes: 8 additions & 0 deletions tsconfig-esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs",
"target": "esnext"
}
}

0 comments on commit abd2980

Please sign in to comment.