Skip to content

Commit

Permalink
Add named export for CommonJS consumers (#423)
Browse files Browse the repository at this point in the history
* Clean up build

* Update distribution files

* Add named `WorkOS` export

* Remove `dist` from .gitignore

* Disable `no-shadowed-variable`
  • Loading branch information
maxdeviant authored Jul 9, 2021
1 parent c2a4515 commit 62144ef
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.npmrc
node_modules
yarn-error.log
dist
lib/
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/*.spec.js
**/*.spec.d.ts
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"node": "14.17.3",
"yarn": "1.22.10"
},
"main": "dist/src/index.js",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
"dist/**/*"
"lib/"
],
"repository": {
"type": "git",
Expand All @@ -24,7 +25,7 @@
"url": "https://github.com/workos-inc/workos-node/issues"
},
"scripts": {
"build": "tsc -p tsconfig.json",
"build": "tsc -p .",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ export * from './passwordless/interfaces';
export * from './portal/interfaces';
export * from './sso/interfaces';

export { WorkOS };

// tslint:disable-next-line:no-default-export
export default WorkOS;
5 changes: 3 additions & 2 deletions src/workos.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios, { AxiosError, AxiosInstance, AxiosResponse } from 'axios';
import { version } from '../package.json';
import { AuditTrail } from './audit-trail/audit-trail';
import {
GenericServerException,
Expand All @@ -21,6 +20,8 @@ import { Passwordless } from './passwordless/passwordless';
import { Portal } from './portal/portal';
import { SSO } from './sso/sso';

const VERSION = '1.1.0';

const DEFAULT_HOSTNAME = 'api.workos.com';

export class WorkOS {
Expand Down Expand Up @@ -60,7 +61,7 @@ export class WorkOS {
baseURL: this.baseURL,
headers: {
Authorization: `Bearer ${this.key}`,
'User-Agent': `workos-node/${version}`,
'User-Agent': `workos-node/${VERSION}`,
},
});
}
Expand Down
9 changes: 2 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "preserve",
"lib": ["dom", "es2017"],
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"typeRoots": ["./node_modules/@types"],
"target": "es6",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"outDir": "lib",
"strict": true
},
"include": ["src/**/*"],
"exclude": ["src/**/*.spec.ts", "dist"]
"include": ["src"]
}
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"quotemark": [true, "single", "jsx-double"],
"variable-name": [true, "allow-leading-underscore"],
"semicolon": [true, "always", "ignore-bound-class-methods"],
"no-default-export": true
"no-default-export": true,
"no-shadowed-variable": false
},
"rulesDirectory": []
}

0 comments on commit 62144ef

Please sign in to comment.