remix-run / blues-stack

The Remix Stack for deploying to Fly with PostgreSQL, authentication, testing, linting, formatting, etc.
https://remix.run/stacks
MIT License
959 stars 235 forks source link

feat: move to ESM #206

Open MichaelDeBoey opened 1 year ago

MichaelDeBoey commented 1 year ago

Just like I did in https://github.com/remix-run/indie-stack/pull/255


This will also need @mcansh's https://github.com/remix-run/remix/pull/7348

hs2323 commented 1 month ago

When applying these changes to an existing Blues Stack, and running npm run dev, I get the following error:

Error: Dynamic require of "path" is not supported

Edit: Found a similar issue when starting the project from scratch (template init) as well.

MichaelDeBoey commented 3 weeks ago

@hs2323 Any idea how to solve that? 🤔

hs2323 commented 3 weeks ago

@hs2323 Any idea how to solve that? 🤔

Not sure, it seems to be an issue with the server build. It doesn't like the require module:

🔶 Mock server running
file:///Users/hs2323/Documents/blues-stack/build/server.js:11
  throw Error('Dynamic require of "' + x + '" is not supported');
        ^

Error: Dynamic require of "path" is not supported
    at file:///Users/hs2323/Documents/blues-stack/build/server.js:11:9
    at node_modules/depd/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:44:20)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/body-parser/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:16909:21)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/express/lib/express.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:23591:22)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/express/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:23660:22)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/@isaacs/express-prometheus-middleware/src/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:28762:20)

When commenting out the exception catch, it produces the following error:

🔶 Mock server running
file:///Users/hs2323/Documents/blues-stack/build/server.js:44
    var relative = __require("path").relative;
                                    ^

TypeError: Cannot read properties of undefined (reading 'relative')
    at node_modules/depd/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:44:37)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/body-parser/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:16909:21)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/express/lib/express.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:23591:22)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/express/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:23660:22)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)
    at node_modules/@isaacs/express-prometheus-middleware/src/index.js (file:///Users/hs2323/Documents/blues-stack/build/server.js:28762:20)
    at __require2 (file:///Users/hs2323/Documents/blues-stack/build/server.js:17:50)

Line 44 of build/server.js

var relative = __require("path").relative;

It seems that it can't read the require from the build. Most likely will require a rewrite of server.ts.