Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hot reload and initial compilation in a custom server typescript project doesn't work (official example) #858

Open
sytabaresa opened this issue Aug 23, 2020 · 0 comments

Comments

@sytabaresa
Copy link

sytabaresa commented Aug 23, 2020

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:

  1. Go to https://github.com/Yoctol/bottender/tree/master/examples/custom-server-express-typescript and download the example
  2. Call on 'yarn install / npm install'
  3. Call on 'yarn dev / npm run dev'
  4. 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 generate dist folder but you lost all "hot reload" capabilities doing this, the dev server makes useless.
  • As noted in server/index.js requirement / typescript support #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 in index.js and a "core" typescript project using ts-node.
@sytabaresa sytabaresa changed the title custom-server-express-typescript example doesn't work hot reload and initial compilation in a typescript project doesn't work (official example) Aug 23, 2020
@sytabaresa sytabaresa changed the title hot reload and initial compilation in a typescript project doesn't work (official example) hot reload and initial compilation in a custom server typescript project doesn't work (official example) Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant