Skip to content

Imports/exports in function-body #2157

Answered by wooorm
hahnbeelee asked this question in Q&A
Discussion options

You must be logged in to vote

If you are going to run MDX code on the client in a browser, without a bundler, then you get actual imports. The browser will fetch those files. Your server will need to send those files back.

Sort of how it used to be 10 years ago: you had different JS files on a server, and you had script tags in an HTML page. The browser then got those files from the server for you.

The URL must also reflect that. An actual URL to a file on a website where the code runs from.

You can also run code inside Node.js. Then the files can exist on that server locally too. And they can be imported. Node.js can access file://.... But browsers can’t.

That’s why options.useDynamicImport and options.baseURL exist.…

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@hahnbeelee
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@wooorm
Comment options

@hahnbeelee
Comment options

@wooorm
Comment options

@hahnbeelee
Comment options

@hahnbeelee
Comment options

Answer selected by hahnbeelee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants