remix: ESM? Build errors after updating to v1.3.5

What version of Remix are you using?

1.3.5 and 1.4.0

Steps to Reproduce

update from 1.3.4 to 1.3.5 or 1.4.0

run remix build

Expected Behavior

App should compile

Actual Behavior

Lots of errors starting with the following:

Building Remix app in production mode...
y-indexeddb is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
The path "encoding" is imported in generated/prisma/client/runtime/index.js but encoding is not listed in your package.json dependencies. Did you forget to install it?
✘ [ERROR] [plugin server-bare-modules] Cannot find module 'encoding/package.json'
Require stack:
- /node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js
- /node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler.js
- /node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/commands.js
- /node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/run.js
- /node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/index.js
- /node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/index.js
- /node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli.js
    generated/prisma/client/runtime/index.js:15389:26:
      15389 │         convert = require("encoding").convert;
            ╵                           ~~~~~~~~~~
  This error came from the "onResolve" callback registered here:
    node_modules/.pnpm/@remix-run+dev@1.3.5_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js:46:12:
      46 │       build.onResolve({
         ╵             ~~~~~~~~~

There are many more errors, but all seem realeted.

Reverting back to v1.3.4 and everything is ok again.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 33 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Looks like server-bare-modules in v0.0.0-experimental-9aba8b51 is failing to find @heroicons/react.

✘ [ERROR] [plugin server-bare-modules] Cannot find module ‘@heroicons/react

  This error came from the "onResolve" callback registered here:

    node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js:47:12:
      47 │       build.onResolve({
         ╵             ~~~~~~~~~

    at setup (removed/node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js:47:13)
    at handlePlugins (removed/node_modules/esbuild/lib/main.js:842:23)

Here’s a repo to reproduce the issue (it’s the Indie Stack with @heroicons/react added).

good news, i think #2694 should cover these bases

our nightly releases aren’t quite set up yet unfortunately, but i will cut an experimental soon

Looks like server-bare-modules in v0.0.0-experimental-9aba8b51 is failing to find @heroicons/react

this appears to be a slightly different issue, each sub import (solid/outline) have their own package.json with no information in them https://github.com/tailwindlabs/heroicons/blob/master/scripts/build.js#L112-L113 I’ll see if we can make something work 🥴

@ivosabev ok cool, resolved in the linked PR on this issue, they dont explicitly list their package.json as an “export”, but we use it for a few things (like bundling modules into your build if you opt in to that)

here’s both fortawesome and headless ui running in a “playground” based on that PR 😃 Screen Shot 2022-04-08 at 9 45 11 AM

Reverting back to v1.3.4 and everything is ok again.

Can confirm that downgrading worked for me as well as several others in the discord. From what I can tell by a quick glance through the commit merging 1.3.5 it seems like it makes some significant changes to the compiler in the remix-dev package, can’t pinpoint what the problem is specifically yet.

Spent a bit more time on this today. I think the last remaining warnings are related to pnpm not hoisting packages.

Adding lib0 (which is required by yjs) with a regex /lib0/ instead of 'lib0' in serverDependenciesToBundle and adding a top level dependency on 'encoding' (which is required by prisma) seems to have fixed the remaining issues.

Whilst I’m happy to have this working again, I’m not entirely convinced about the DX around the changes that came in with v1.3.4. Why would everything have worked just fine before not after?

Thanks for you help in investigating this @machour and @mcansh. I went back and checked if v1.4.0 would work after my latest config updates, but it seems that the changes you made for v0.0.0-experimental-aaac29de are still required, so I will stick with this version until they get merged.

Yes, it seems to originate from prisma, but when I revert remix back to v1.3.4 there are no build errors.

I can confirm that v0.0.0-experimental-a04f3d18 fixes all my issues 🎉

@ianduvall would you mind giving this a try?

Working for me as well. Thanks for the quick turn around!

I’ve just tested with v0.0.0-experimental-a04f3d18, though there are a lot less than before, I still have build errors:

Building Remix app in production mode...
@hocuspocus/server is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
@hocuspocus/extension-logger is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
@hocuspocus/extension-monitor is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
@hocuspocus/extension-rocksdb is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
@hocuspocus/provider is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
y-indexeddb is possibly an ESM only package and should be bundled with "serverDependenciesToBundle in remix.config.js.
The path "encoding" is imported in generated/prisma/client/runtime/index.js but encoding is not listed in your package.json dependencies. Did you forget to install it?
▲ [WARNING] Comparison with -0 using the "===" operator will also match 0
    generated/prisma/client/runtime/index.js:13474:29:
      13474 │             } else if (x === -0) {
            ╵                              ~~
  Floating-point equality is defined such that 0 and -0 are equal, so "x === -0" returns true for both 0 and -0. You need to use "Object.is(x, -0)" instead to test for -0.
✘ [ERROR] [plugin server-bare-modules] Cannot find module 'encoding'
Require stack:
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/commands.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/run.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/index.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/index.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli.js
    generated/prisma/client/runtime/index.js:15389:26:
      15389 │         convert = require("encoding").convert;
            ╵                           ~~~~~~~~~~
  This error came from the "onResolve" callback registered here:
    node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js:47:12:
      47 │       build.onResolve({
         ╵             ~~~~~~~~~
    at setup (/node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js:47:13)
    at handlePlugins (/node_modules/.pnpm/esbuild@0.14.22/node_modules/esbuild/lib/main.js:842:23)
Build failed with 1 error:
generated/prisma/client/runtime/index.js:15389:26: ERROR: [plugin: server-bare-modules] Cannot find module 'encoding'
Require stack:
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler/plugins/serverBareModulesPlugin.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/commands.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/run.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/index.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/index.js
- /node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli.js
Error
    at Object.onBuildFailure (/node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/commands.js:150:13)
    at buildEverything (/node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler.js:280:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.build (/node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/compiler.js:105:3)
    at async Object.build (/node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/commands.js:145:3)
    at async Object.run (/node_modules/.pnpm/@remix-run+dev@0.0.0-experimental-a04f3d18_25e4b5bc5190ce64f1c1869d744ce914/node_modules/@remix-run/dev/cli/run.js:467:7)

@mcansh please cut us a new experimental release when you have time so that we can validate the fix and ship it in 1.3.6 🙏

v0.0.0-experimental-a04f3d18 is on the way https://github.com/remix-run/remix/runs/5998229731?check_suite_focus=true

i will cut an experimental soon

sorry all, forgot to do this, i just cut v0.0.0-experimental-9aba8b51 which has this in there 😃

Thanks for the quick fix!