Skip to content

Commit

Permalink
refactor: configure TypeScript paths
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagozf committed Apr 12, 2020
1 parent 2814f43 commit a1f4e7c
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 26 deletions.
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
"tsx",
"js"
],
"moduleNameMapper": {
"^@rimo/(.*)": [
"<rootDir>/src/$1"
]
},
"coveragePathIgnorePatterns": [
"rimo.ts",
"/node_modules/",
Expand All @@ -73,7 +78,7 @@
}
},
"collectCoverageFrom": [
"src/*.{js,ts}"
"src/**/*.{js,ts}"
]
},
"prettier": {
Expand Down Expand Up @@ -102,6 +107,7 @@
"jest": "^25.3.0",
"jest-config": "^25.3.0",
"lint-staged": "^10.1.3",
"lodash": "^4.17.15",
"lodash.camelcase": "^4.3.0",
"prettier": "^2.0.4",
"prompt": "^1.0.0",
Expand All @@ -112,9 +118,11 @@
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.5.0",
"rollup-plugin-ts-paths": "^1.0.5",
"rollup-plugin-typescript2": "^0.27.0",
"semantic-release": "^17.0.4",
"shelljs": "^0.8.3",
"shortid": "^2.2.15",
"travis-deploy-once": "^5.0.11",
"ts-jest": "^25.3.1",
"ts-node": "^8.8.2",
Expand All @@ -124,8 +132,5 @@
"typedoc": "^0.17.4",
"typescript": "^3.8.3"
},
"dependencies": {
"lodash": "^4.17.15",
"shortid": "^2.2.15"
}
"dependencies": {}
}
2 changes: 2 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import commonjs from 'rollup-plugin-commonjs'
import sourceMaps from 'rollup-plugin-sourcemaps'
import camelCase from 'lodash.camelcase'
import typescript from 'rollup-plugin-typescript2'
import tsConfigPaths from 'rollup-plugin-ts-paths'
import json from 'rollup-plugin-json'

const pkg = require('./package.json')
Expand All @@ -24,6 +25,7 @@ export default {
// Allow json resolution
json(),
// Compile TypeScript files
tsConfigPaths(),
typescript({ useTsconfigDeclarationDir: true }),
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
commonjs({
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from './AggregateRoot'
export * from './DomainEvent'
export * from './DomainEventHandler'
export * from './DomainEvents'
export * from './Entity'
export * from './EntityId'
export * from './Identifier'
export * from './Object'
export * from './ValueObject'
10 changes: 1 addition & 9 deletions src/rimo.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
export * from './AggregateRoot'
export * from './DomainEvent'
export * from './DomainEventHandler'
export * from './DomainEvents'
export * from './Entity'
export * from './EntityId'
export * from './Identifier'
export * from './Object'
export * from './ValueObject'
export * from './core'
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { AggregateRoot } from '../src/AggregateRoot'
import { DomainEvent } from '../src/DomainEvent'
import { EntityId } from '../src/EntityId'
import { DomainEventHandler } from '../src/DomainEventHandler'
import { DomainEvents } from '../src/DomainEvents'
import { AggregateRoot, DomainEvent, EntityId, DomainEventHandler, DomainEvents } from '@rimo/core'

class PostFollowed implements DomainEvent {
public static type: string = 'PostFollowed'
Expand Down
3 changes: 1 addition & 2 deletions test/Entity.test.ts → test/core/Entity.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity } from '../src/Entity'
import { EntityId } from '../src/EntityId'
import { Entity, EntityId } from '@rimo/core'

/**
* Entity test
Expand Down
2 changes: 1 addition & 1 deletion test/EntityId.test.ts → test/core/EntityId.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntityId } from '../src/EntityId'
import { EntityId } from '@rimo/core'

/**
* EntityId test
Expand Down
2 changes: 1 addition & 1 deletion test/Identifier.test.ts → test/core/Identifier.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Identifier } from '../src/Identifier'
import { Identifier } from '@rimo/core'

/**
* Identifier test
Expand Down
2 changes: 1 addition & 1 deletion test/ValueObject.test.ts → test/core/ValueObject.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ValueObject } from '../src/ValueObject'
import { ValueObject } from '@rimo/core'

/**
* ValueObject test
Expand Down
9 changes: 7 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
"emitDecoratorMetadata": true,
"declarationDir": "dist/types",
"outDir": "dist/lib",
"typeRoots": ["node_modules/@types"]
"typeRoots": ["node_modules/@types"],
"baseUrl": ".",
"paths": {
"@rimo/*": ["src/*"]
}
},
"include": ["src"]
"include": ["src", "test"],
"exclude": ["node_modules"]
}
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7682,6 +7682,14 @@ rollup-plugin-sourcemaps@^0.5.0:
"@rollup/pluginutils" "^3.0.1"
source-map-resolve "^0.5.3"

rollup-plugin-ts-paths@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/rollup-plugin-ts-paths/-/rollup-plugin-ts-paths-1.0.5.tgz#bc43245b400d5a87df90191ac74ef184a45ae9be"
integrity sha512-Ca2FK0SEb6SicXQAAyI6Lfibyd7BNuTUERnMS8Dl28sYDS2vu/i8L012FMRjNcuHFzQTlU3QUpb+t4wP/Qb7Kw==
dependencies:
strip-bom "^4.0.0"
strip-json-comments "^3.0.1"

rollup-plugin-typescript2@^0.27.0:
version "0.27.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.27.0.tgz#95ff96f9e07d5000a9d2df4d76b548f9a1f83511"
Expand Down Expand Up @@ -8390,6 +8398,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.0.1.tgz#85713975a91fb87bf1b305cca77395e40d2a64a7"
integrity sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==

strip-json-comments@^3.0.1:
version "3.1.0"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.0.tgz#7638d31422129ecf4457440009fba03f9f9ac180"
integrity sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==

strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
Expand Down

0 comments on commit a1f4e7c

Please sign in to comment.