kentcdodds / mdx-bundler

🦤 Give me MDX/TSX strings and I'll give you back a component you can render. Supports imports!
MIT License
1.79k stars 75 forks source link

Error: Could not resolve './dirname-messed-up.cjs' from ./dirname-messed-up.cjs?commonjs-external #22

Closed rbusquet closed 3 years ago

rbusquet commented 3 years ago

What you did: Upgraded mdx-bundler on a remix.run project

What happened:

Building Remix app for production...
Error: Could not resolve './dirname-messed-up.cjs' from ./dirname-messed-up.cjs?commonjs-external
    at error (<redacted-repo dir>/node_modules/rollup/dist/shared/rollup.js:5305:30)
    at ModuleLoader.handleResolveId (<redacted-repo dir>/node_modules/rollup/dist/shared/rollup.js:18531:24)
    at <redacted-repo dir>/node_modules/rollup/dist/shared/rollup.js:18487:22
    at async Promise.all (index 0)
    at async ModuleLoader.fetchStaticDependencies (<redacted-repo dir>/node_modules/rollup/dist/shared/rollup.js:18485:34)
    at async Promise.all (index 0)
    at async ModuleLoader.fetchModule (<redacted-repo dir>/node_modules/rollup/dist/shared/rollup.js:18461:9)
    at async Promise.all (index 10)
    at async ModuleLoader.fetchStaticDependencies (<redacted-repo dir>/node_modules/rollup/dist/shared/rollup.js:18485:34)
    at async Promise.all (index 0)

Problem description: Something might be wrong in the implementation of #21

Suggested solution: Unfortunately I don't have a lot of background to suggest a solution. Thought about reporting given that the error seems related to #21 which was just released.

kentcdodds commented 3 years ago

Whoops! Looks like when babel compiles it, it removes the .cjs and renames it to .js: https://unpkg.com/browse/mdx-bundler@3.2.0/dist/

Bummer. I think this is such a one-off thing that we can just hack this to make it work. We're doing some wonky things in this repo thanks to the native ESM mix of our deps and current lack of support from tools.

Luckily, I see this project as mostly "done" so I'm not worried about the long-term maintainability of these workarounds 😅

kentcdodds commented 3 years ago

Here we go: #23 That should fix it.

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 3.2.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: