Skip to content

What's the default behavior for default & namespace imports/exports? #2401

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

You must be logged in to vote

Hey @hahnbeelee! 👋

What's the default behavior for default & namespace imports/exports?

MDX exports translate into ESM exports, the behavior matches the standard https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

When you have a page with a default import or a namespace import, what is the expected behavior?

You can generate unlimited examples of the expected behavior with https://mdxjs.com/playground/

One that you may find particularly illustrative.

import { test } from 'node:test';

# page

export { test }

compiles to

import {jsx as _jsx} from "react/jsx-runtime";
import {test} from 'node:test';
export {test};
function _createMdxContent(props) {
  const

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hahnbeelee
Comment options

@ChristianMurphy
Comment options

@hahnbeelee
Comment options

@ChristianMurphy
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