Skip to content

Commit 638b74a

Browse files
Merge pull request peterszombati#26 from Matb85/master
Support ESM
2 parents 78affc4 + b59cbf6 commit 638b74a

40 files changed

+2892
-856
lines changed

.eslintrc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
7+
"overrides": [],
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": "latest",
11+
"sourceType": "module"
12+
},
13+
"plugins": ["@typescript-eslint"],
14+
"rules": {
15+
"linebreak-style": ["error", "unix"],
16+
"quotes": ["error", "single"],
17+
"semi": ["error", "never"],
18+
"@typescript-eslint/no-explicit-any": "off",
19+
"@typescript-eslint/no-unused-vars": "off"
20+
},
21+
"ignorePatterns": ["**/*.js"]
22+
}

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "singleQuote": true, "semi": false, "printWidth": 120, "arrowParens": "avoid" }

esbuild.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const esbuild = require('esbuild')
2+
const package = require('./package.json')
3+
4+
console.log('external dependencies: ' + JSON.stringify(Object.keys(package.dependencies)))
5+
6+
const formats = [
7+
{ format: 'cjs', extension: '.cjs' },
8+
{ format: 'esm', extension: '.mjs' },
9+
]
10+
11+
for (const f of formats)
12+
esbuild
13+
.build({
14+
entryPoints: ['src/index.ts'],
15+
bundle: true,
16+
external: Object.keys(package.dependencies),
17+
format: f.format,
18+
outfile: 'build/index' + f.extension,
19+
target: 'node16',
20+
define: {
21+
'process.env.ES_TARGET': '"' + f.format + '"',
22+
},
23+
})
24+
.catch(e => {
25+
console.log(e)
26+
})
27+
.then(() => console.log('Successfully bundled the package in the ' + f.format + ' format'))

package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,64 @@
11
{
2+
"name": "xapi-node",
3+
"version": "2.5.6",
4+
"description": "This project makes it possible to get data from Forex market, execute market or limit order with NodeJS/JS through WebSocket connection",
5+
"exports": {
6+
".": {
7+
"require": "./build/index.cjs",
8+
"import": "./build/index.mjs"
9+
}
10+
},
11+
"types": "build/index.d.ts",
12+
"files": [
13+
"build/*"
14+
],
15+
"dependencies": {
16+
"logger4": "^2.1.5",
17+
"ws": "^8.9.0"
18+
},
19+
"devDependencies": {
20+
"@types/chai": "^4.3.3",
21+
"@types/mocha": "^10.0.0",
22+
"@types/node": "^18.7.23",
23+
"@types/ws": "^8.5.3",
24+
"@typescript-eslint/eslint-plugin": "^5.38.1",
25+
"@typescript-eslint/parser": "^5.38.1",
26+
"chai": "^4.3.6",
27+
"esbuild": "^0.15.10",
28+
"eslint": "^8.24.0",
29+
"mocha": "^10.0.0",
30+
"prettier": "^2.7.1",
31+
"ts-mocha": "^10.0.0",
32+
"ts-node": "^10.9.1",
33+
"typescript": "^4.8.4"
34+
},
35+
"scripts": {
36+
"build": "rm -rf ./build && tsc --declaration --emitDeclarationOnly & node ./esbuild.config.js",
37+
"test": "ts-mocha -p ./tsconfig.json ./sandbox/tests.ts ./sandbox/sandbox.ts --exit",
38+
"prettier": "prettier --check \"src/**/*.ts\" \"sandbox/**/*.ts\"",
39+
"eslint": "eslint --fix \"src/**/*.ts\" \"sandbox/**/*.ts\"",
40+
"lint": "tsc --noEmit && pnpm run prettier && pnpm run eslint"
41+
},
42+
"repository": {
43+
"type": "git",
44+
"url": "git+https://github.com/peterszombati/xapi-node.git"
45+
},
46+
"keywords": [
47+
"xstation5",
48+
"trading",
49+
"xtb",
50+
"bfbcapital",
51+
"forex",
52+
"trading-api",
53+
"xopenhub"
54+
],
55+
"author": "Peter Szombati",
56+
"license": "BSD 4-Clause",
57+
"bugs": {
58+
"url": "https://github.com/peterszombati/xapi-node/issues"
59+
},
60+
"homepage": "https://github.com/peterszombati/xapi-node#readme"
61+
=======
262
"name": "xapi-node",
363
"version": "2.5.6",
464
"description": "This project is made possible to get data from Forex market, execute market or limit order with NodeJS/JS through WebSocket connection",

0 commit comments

Comments
 (0)