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
- chore(remix-dev): use fullImportPath to resolve package some packages like @heroicons/react use subdirectory package.json for things, like @heroicons/react/solid closes #2691 Signed-off-by: Logan M... — committed to remix-run/remix by mcansh 2 years ago
- fix(remix-dev): add try/catch to warnOnceIfEsmOnlyPackage for when a package isnt installed like `encoding` when using prisma and a custom output directory closes #2691 — committed to remix-run/remix by mcansh 2 years ago
Looks like
server-bare-modulesinv0.0.0-experimental-9aba8b51is failing to find@heroicons/react.Here’s a repo to reproduce the issue (it’s the Indie Stack with
@heroicons/reactadded).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
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 😃
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.
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:v0.0.0-experimental-a04f3d18is on the way https://github.com/remix-run/remix/runs/5998229731?check_suite_focus=truesorry all, forgot to do this, i just cut
v0.0.0-experimental-9aba8b51which has this in there 😃Thanks for the quick fix!