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

[with-typescript] Server HMR fails when entry file is .ts #420

Closed
markyfyi opened this issue Dec 6, 2017 · 7 comments
Closed

[with-typescript] Server HMR fails when entry file is .ts #420

markyfyi opened this issue Dec 6, 2017 · 7 comments

Comments

@markyfyi
Copy link

markyfyi commented Dec 6, 2017

Hey, great work on razzle! I've developing on top of latest with-typescript, and noticed HMR on the server is broken.

Steps to repro:

  1. create-razzle-app --example with-typescript <name>
  2. cd <name>
  3. npm start
  4. Edit and save src/server.tsx
  5. Dev server output:
[HMR] Cannot apply update.
[HMR] Error: Aborted because ./src/index.ts is not accepted
Update propagation: ./src/index.ts -> 0
    at hotApply (<...>/razzle-ts-hmr-demo/build/server.js:400:30)
    at <...>/razzle-ts-hmr-demo/build/server.js:249:21
    at <anonymous>
[HMR] You need to restart the application!

If you convert src/index.ts to .js, HMR works again. 🤔 (demo: https://github.com/markshlick/razzle-ts-hmr-demo/commit/dc476fdc3ba03a1b018b1f783dd3a0aea556fe1a).

@eronalves
Copy link

+1

@jariz jariz added the bug label Dec 22, 2017
@Thomas-X
Copy link

Thomas-X commented Mar 9, 2018

+1

@rayandrew
Copy link

have you tried the new razzle typescript plugin?

@pavelprokes
Copy link

+1

@SheikhG1900
Copy link

SheikhG1900 commented Jul 12, 2018

Problem is in index.ts file. I changed its code with following. (Razzle default index.js code). Now server HMR working.

import http from 'http'
import app from './server'

const server = http.createServer(app)

let currentApp = app

server.listen(process.env.PORT || 3000, (error) => {
  if (error) {
    console.log(error)
  }

  console.log('🚀 started')
})

if (module.hot) {
  console.log('✅  Server-side HMR Enabled!')

  module.hot.accept('./server', () => {
    console.log('🔁  HMR Reloading `./server`...')
    server.removeListener('request', currentApp)
    const newApp = require('./server').default
    server.on('request', newApp)
    currentApp = newApp
  })
}

@stale
Copy link

stale bot commented Sep 10, 2018

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

@stale stale bot added the stale label Sep 10, 2018
@stale
Copy link

stale bot commented Sep 17, 2018

ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants