Skip to content

Commit 2f0bf06

Browse files
committed
build(merkling): Add tsc support for consuming directly in node over npm
1 parent daa3f07 commit 2f0bf06

6 files changed

Lines changed: 17 additions & 19 deletions

File tree

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
- run:
1212
name: test
1313
command: npm test
14+
- run:
15+
name: build
16+
command: npm run build
1417
- run:
1518
name: release
1619
command: npm run semantic-release || true

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"type": "git",
1111
"url": "https://github.com/kanej/merkling.git"
1212
},
13-
"main": "src/index.js",
13+
"main": "dist/index.js",
14+
"types": "dist/index.d.ts",
1415
"scripts": {
1516
"test": "npm run test:unit",
1617
"test:unit": "jest --runInBand --coverage --config=jest.unit.json",

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Merkling } from './merkling'
2+
3+
module.exports = Merkling

src/internalGraph.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ export default class InternalGraph {
3232
topologicalSort(): number[] {
3333
const allVertexes = new Set<number>(
3434
Array.from(this._matrix.keys()).concat(
35-
Array.from(this._matrix.values()).flatMap(
36-
(s: Set<number>): number[] => Array.from(s)
35+
Array.from(this._matrix.values()).reduce(
36+
(acc: number[], s: Set<number>): number[] =>
37+
acc.concat(Array.from(s)),
38+
[]
3739
)
3840
)
3941
)

tsconfig.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
{
22
"compilerOptions": {
33
/* Basic Options */
4-
"target": "ESNEXT" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
4+
"target": "ES2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
55
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
66
"skipLibCheck": true,
7-
"lib": [
8-
"dom",
9-
"es6",
10-
"dom.iterable",
11-
"scripthost",
12-
"esnext"
13-
] /* Specify library files to be included in the compilation. */,
7+
"lib": [] /* Specify library files to be included in the compilation. */,
148
// "allowJs": true, /* Allow javascript files to be compiled. */
159
// "checkJs": true, /* Report errors in .js files. */
1610
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
17-
// "declaration": true, /* Generates corresponding '.d.ts' file. */
11+
"declaration": true /* Generates corresponding '.d.ts' file. */,
1812
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
1913
"sourceMap": true /* Generates corresponding '.map' file. */,
20-
// "outFile": "./dist/merkling.js", /* Concatenate and emit output to single file. */
14+
// "outFile": "./dist/merkling.js" /* Concatenate and emit output to single file. */,
2115
"outDir": "./dist" /* Redirect output structure to the directory. */,
2216
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
2317
// "composite": true, /* Enable project compilation */
@@ -46,7 +40,7 @@
4640
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
4741

4842
/* Module Resolution Options */
49-
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
43+
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
5044
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
5145
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
5246
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */

0 commit comments

Comments
 (0)