Skip to content

Commit

Permalink
fix: Seperate tsconfigs for tests and module
Browse files Browse the repository at this point in the history
  • Loading branch information
thebongy committed Apr 28, 2020
1 parent 6784b42 commit b38d8e0
Show file tree
Hide file tree
Showing 7 changed files with 476 additions and 448 deletions.
860 changes: 430 additions & 430 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"description": "",
"keywords": [],
"main": "dist/juno-node.umd.js",
"main": "dist/juno-node.cjs.js",
"module": "dist/juno-node.es5.js",
"typings": "dist/types/juno-node.d.ts",
"files": [
Expand All @@ -21,9 +21,9 @@
"scripts": {
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"prebuild": "rimraf dist",
"build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"build": "rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"start": "rollup -c rollup.config.ts -w",
"test": "ts-mocha -p ./tsconfig.json test/**/*.test.ts",
"test": "ts-mocha -p ./tsconfig/tsconfig.test.json test/**/*.test.ts",
"test:coverage": "nyc --reporter=html --reporter=text --reporter=text-summary npm test",
"test:prod": "npm run lint && npm run test",
"deploy-docs": "ts-node tools/gh-pages-publish",
Expand Down Expand Up @@ -61,7 +61,6 @@
"@types/chai-as-promised": "^7.1.2",
"@types/expect": "^24.3.0",
"@types/mocha": "^7.0.2",
"@types/node": "^13.13.4",
"@types/sinon": "^9.0.0",
"@types/sinon-chai": "^3.2.4",
"chai": "^4.2.0",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {
// Allow json resolution
json(),
// Compile TypeScript files
typescript({ useTsconfigDeclarationDir: true }),
typescript({ useTsconfigDeclarationDir: true, tsconfig:"tsconfig/tsconfig.module.json" }),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs(),
// Allow node_modules resolution, so you can use 'external' to control
Expand Down
18 changes: 5 additions & 13 deletions tsconfig.json → tsconfig/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es5",
"module": "es2015",
"lib": [
"es2015",
"es2016",
"es2017",
"dom"
],
"strict": true,
"sourceMap": true,
Expand All @@ -16,14 +13,9 @@
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declarationDir": "dist/types",
"outDir": "dist/lib",
"typeRoots": [
"node_modules/@types",
"types"
]
},
"include": [
"src"
]
"typeRoots": [
"./typings",
"../node_modules/@types"
]
}
}
11 changes: 11 additions & 0 deletions tsconfig/tsconfig.module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.base",
"compilerOptions": {
"module": "es2015",
"declarationDir": "../dist/types",
"outDir": "../dist/lib",
},
"include": [
"../src"
]
}
9 changes: 9 additions & 0 deletions tsconfig/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "commonjs"
},
"include": [
"../test"
]
}
17 changes: 17 additions & 0 deletions typings/mocha/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import BaseConnection from "../../src/connection/base-connection";
import { DummyJunoConnection } from "../../test/helpers";
import JunoModule from "../../src/juno-node";
import { SinonSpy } from "sinon";

interface JunoTest {
connection: BaseConnection;
}

declare module 'mocha' {
interface Runnable {
conn: DummyJunoConnection;
module: JunoModule;
sendFunc: SinonSpy;
getLatestSent: Function
}
}

0 comments on commit b38d8e0

Please sign in to comment.