Initial checklist
Affected package
@mdx-js/esbuild
Steps to reproduce
package.json:
{
"type": "module",
"dependencies": { "@mdx-js/esbuild": "^3.1.0", "esbuild": "^0.25.0" }
}
build.js:
import mdx from '@mdx-js/esbuild'
import esbuild from 'esbuild'
await esbuild.build({
entryPoints: ['test.mdx'],
format: 'esm',
outfile: 'output.js',
plugins: [mdx({jsx: true})]
})
test.mdx:
Test with
npm install
node build.js
Actual behavior
I get a build error like this:
✘ [ERROR] The JSX syntax extension is not currently enabled
index.mdx:8:9:
8 │ return <_components.h1>{"Hello World"}</_components.h1>;
╵ ^
The esbuild loader for this file is currently set to "js" but it must be set
to "jsx" to be able to parse JSX syntax. You can use "loader: { '.js': 'jsx'
}" to do that.
(Note that despite the message, setting loader in the esbuild options isn't helpful, since the plugin is responsible for setting the loader for its output.)
Expected behavior
Expected behavior (which I get with #2593): successful run of build.js, and then
output.js:
import { jsx } from "react/jsx-runtime";
function _createMdxContent(props) {
const _components = {
h1: "h1",
...props.components
};
return /* @__PURE__ */ jsx(_components.h1, { children: "Hello World" });
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
return MDXLayout ? /* @__PURE__ */ jsx(MDXLayout, { ...props, children: /* @__PURE__ */ jsx(_createMdxContent, { ...props }) }) : _createMdxContent(props);
}
export {
MDXContent as default
};
as translated by esbuild's JSX-to-JS logic (with default settings).
Runtime
[email protected]
Package manager
[email protected]
Operating system
Ubuntu 24.10
Build and bundle tools
No response
Initial checklist
Affected package
@mdx-js/esbuild
Steps to reproduce
package.json:{ "type": "module", "dependencies": { "@mdx-js/esbuild": "^3.1.0", "esbuild": "^0.25.0" } }build.js:test.mdx:# Hello World!Test with
Actual behavior
I get a build error like this:
(Note that despite the message, setting
loaderin the esbuild options isn't helpful, since the plugin is responsible for setting the loader for its output.)Expected behavior
Expected behavior (which I get with #2593): successful run of
build.js, and thenoutput.js:as translated by esbuild's JSX-to-JS logic (with default settings).
Runtime
[email protected]
Package manager
[email protected]
Operating system
Ubuntu 24.10
Build and bundle tools
No response