project started from nestjs sample 25-dynamic-modules
UPDATE: above make me lost 2 nights now step back and use the old school ways with https://github.com/koakh/NestJsPlayWithDynamicModulesWithAppAndAppLib.git repo
# dynamic-module
$ cd dynamic-module
$ npm run start:dev
or
$ npm run build
# consumer-app
$ cd consumer-app
$ npm run start:debug
# or launch debug
dynamic-module/package.json
"main": "dist/index.js",
"files": [
"dist/**/*",
"*.md"
],
dynamic-module/tsconfig.json
change "include": ["src/**/*"]
to "include": ["lib/**/*"]
dynamic-module/tsconfig.build.json
add "include": ["lib/**/*"],
{
"extends": "./tsconfig.json",
"include": ["lib/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
build to assert everything is working
$ npm run build
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/consumer-app/src/main.ts",
"preLaunchTask": "tsc: build - consumer-app/tsconfig.json",
"outFiles": [
"${workspaceFolder}/**/dist/**/*.js"
],
"cwd": "${workspaceFolder}/consumer-app"
}
]
}
notes for cwd to read config, and consumer-app on program, preLaunchTask and outFiles
to debug dynamic-modules must change
"${workspaceFolder}/consumer-app/dist/**/*.js"
to"${workspaceFolder}/**/dist/**/*.js"
, else breakpoints will be grey
consumer-app/src/main.ts
dynamic-module/src/config/config.service.ts