bottender
bottender copied to clipboard
hot reload and initial compilation in a custom server typescript project doesn't work (official example)
Describe the bug
when the custom-server-express-typescript example is downloaded from official examples, the command yarn dev
/ npm run dev
doesn't work. the dist
folder isn't found.
To Reproduce Steps to reproduce the behavior:
- Go to https://github.com/Yoctol/bottender/tree/master/examples/custom-server-express-typescript and download the example
- Call on 'yarn install / npm install'
- Call on 'yarn dev / npm run dev'
- See error:
> $ yarn dev
yarn run v1.22.4
warning package.json: No license field
$ nodemon --exec ts-node src/server.ts
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node src/server.ts`
(node:14189) UnhandledPromiseRejectionWarning: Error: Cannot find module './dist'
Require stack:
- /home/syta/Downloads/bottender/examples/custom-server-express-typescript/index.js
- /home/syta/Downloads/bottender/examples/custom-server-express-typescript/node_modules/bottender/dist/server/Server.js
- /home/syta/Downloads/bottender/examples/custom-server-express-typescript/node_modules/bottender/dist/bottender.js
- /home/syta/Downloads/bottender/examples/custom-server-express-typescript/node_modules/bottender/dist/index.js
- /home/syta/Downloads/bottender/examples/custom-server-express-typescript/src/server.ts
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/syta/Downloads/bottender/examples/custom-server-express-typescript/index.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
(node:14189) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:14189) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[nodemon] clean exit - waiting for changes before restart
Expected behavior The npm dev command transpiles the typescript code and executes the developer server normally, when a change in a file is made, the server reloads automatically, compiles/transpiles too, and listen in the default port.
Additional context
- A workaround exist: Bottender expects
npx bottender dev
to be executed at least one time to generatedist
folder but you lost all "hot reload" capabilities doing this, the dev server makes useless. - As noted in #847, in this moment Bottender doesn't allow to change the default entrypoint and route paths when startup.
- The actual configuration in Bottender using in a typescript project doesn't permit to avoid the "dual" workflow of use a
dist
transpiled folder configured as a import inindex.js
and a "core" typescript project usingts-node
.