#express template's server.js dependencies

1 messages · Page 1 of 1 (latest)

sinful quail
#

https://github.com/remix-run/remix/blob/main/templates/express/server.js#L5

chokidar is a devDependency, and it's only used when NODE_ENV is development.
However, the way the template's server.js is written, I think chokidar will always be required? and making production rely on devDependencies.
I changed it to use dynamic import on my own project, but I wonder if I'm missing something?

GitHub

Build Better Websites. Create modern, resilient user experiences with web fundamentals. - remix-run/remix

wanton sage
#

I’ve also stumbled upon this problem. How did you solve it? And should this really be the default behavior?

somber lagoon
nocturne fiber
#

You could also do what Kent does in the epic stack:

if (MODE === 'development') {
    async function reloadBuild() {
        devBuild = await import(`${BUILD_PATH}?update=${Date.now()}`)
        broadcastDevReady(devBuild)
    }

    const dirname = path.dirname(fileURLToPath(import.meta.url))
    const watchPath = path.join(dirname, BUILD_PATH).replace(/\\/g, '/')
    const watcher = chokidar.watch(watchPath, { ignoreInitial: true })
    watcher.on('all', reloadBuild)
}
#

basically have the chokidar code always be inside a process.env check

somber lagoon
#

I think the difference here is that Epic Stack has a seperate dev-server file that isn't used in production.

nocturne fiber
#

oh, oopsy

#

scratch my comment then :S

somber lagoon
#

mmm, actually it still uses server/index.ts if i read this correctly, which has chokidar dependency.

#

Let me run it locally and see what the esbuild metadata says.