Skip to content

Latest commit

 

History

History
93 lines (69 loc) · 2.02 KB

NOTES.md

File metadata and controls

93 lines (69 loc) · 2.02 KB

NOTES

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

TLDR

# 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

Required to be a node package

dynamic-module/package.json

  "main": "dist/index.js",
  "files": [
    "dist/**/*",
    "*.md"
  ],

Change src to lib

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

Debug ConsumerApp Config

{
  "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

Test breakpoint in

consumer-app/src/main.ts dynamic-module/src/config/config.service.ts

Fix: Cannot read file tsconfig.json, when it's in subfolders and not in root