javascriptreactjsnode.jsremix.runturborepo

Remix throwing strange errors when used in turborepo


I am trying to add remix example for one of my libraries - react18-themes. I have a working example here. However, when I try to setup the example in the monorepo, it throws strange errors

TypeError: Unknown file extension ".ts" for ...react18-themes\packages\react18-themes\index.ts
at new NodeError (node:internal/errors:399:5)
remix-example:dev:     at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
remix-example:dev:     at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
remix-example:dev:     at defaultLoad (node:internal/modules/esm/load:81:20)
remix-example:dev:     at nextLoad (node:internal/modules/esm/loader:163:28)
remix-example:dev:     at ESMLoader.load (node:internal/modules/esm/loader:605:26)
remix-example:dev:     at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
remix-example:dev:     at new ModuleJob (node:internal/modules/esm/module_job:64:26)
remix-example:dev:     at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:480:17)
remix-example:dev:     at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)

It can be reproduced from this branch. OS - Windows 11.

I am not able to figure out what is going wrong here and why is remix trying to get to the packages\react18-themes\index.ts file, even when I replace workspace:* with ^1.0.8.


Solution

  • Thanks to @jrestall. I needed to add the following config and also add all the dependencies that were used by the workspace that remix example depended on.

    /** @type {import('@remix-run/dev').AppConfig} */
    export default {
        ignoredRouteFiles: ["**/.*"],
        watchPaths: ["../../packages/react18-themes", "../../packages/shared-ui"],
        serverDependenciesToBundle: ["react18-themes", "shared-ui"], // <- note this line
    };
    

    Note this: serverDependenciesToBundle: ["react18-themes", "shared-ui"]