Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mdx v2: import URL causes fail to compile error #1802

Closed
xHomu opened this issue Nov 8, 2021 · 6 comments
Closed

mdx v2: import URL causes fail to compile error #1802

xHomu opened this issue Nov 8, 2021 · 6 comments
Labels
🏗 area/tools This affects tooling 🙋 no/question This does not need any changes

Comments

@xHomu
Copy link
Contributor

xHomu commented Nov 8, 2021

Subject of the issue

The import {URL} from 'url' line in recma-document plugin creates a compile error.

I don't think it's necessary to import the URL class since it's a global object?

Your environment

  • OS: Window 10 64bit
  • Packages: v.2.0.0.rc
  • Env: yarn v1.22.15 Next 11.0.1

Steps to reproduce

yarn build a nextjs project.

Expected behaviour

Project compiles.

Actual behaviour

Failed to compile due to error.

./node_modules/@mdx-js/mdx/lib/plugin/recma-document.js
Attempted import error: 'URL' is not exported from 'url' (imported as 'URL').
@wooorm
Copy link
Member

wooorm commented Nov 9, 2021

I don't think it's necessary to import the URL class since it's a global object?

TypeScript can’t deal with it properly.

The import {URL} from 'url' line in recma-document plugin creates a compile error.

Where? Several people are using xdm and mdxjs/mdx@next without errors. And URL should be exported from 'url', so this leads me to think its a problem in your bundler?

@xHomu
Copy link
Contributor Author

xHomu commented Nov 9, 2021

I'm using webpack 5 for production bundling.

import {URL} from 'url' line is the only difference between the recma-document plugins on mdx-js/mdx@next and xdm:

https://github.com/mdx-js/mdx/blob/079c8c7bb953dda5e59cf4c93fb924ad07b15ad1/packages/mdx/lib/plugin/recma-document.js
https://github.com/wooorm/xdm/blob/f0fde3b5c1f6d2de8c0b40aba63f027b6d7edcfd/lib/plugin/recma-document.js

@wooorm
Copy link
Member

wooorm commented Nov 10, 2021

And how do you configure webpack? For example, I'm currently using all of this swimingly with webpack through next

@xHomu
Copy link
Contributor Author

xHomu commented Nov 10, 2021

I worked on the problem a bit more overnight and figured out the problem was caused by the version of nextjs I was using.

The compile error clears when I changed the next package from "next": "v11.0.1" to "next": "latest".

@xHomu xHomu closed this as completed Nov 10, 2021
@ChristianMurphy ChristianMurphy added 🙋 no/question This does not need any changes 🏗 area/tools This affects tooling and removed 🐛 type/bug This is a problem 🔍 status/open labels Nov 20, 2021
@cesutherland

This comment has been minimized.

@cesutherland

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏗 area/tools This affects tooling 🙋 no/question This does not need any changes
Development

No branches or pull requests

4 participants