Open pkerschbaum opened 1 year ago
In my case, this problem is fixed via installing esbuild
version 0.13.15
.
I'm facing the same issue here. Why the fix is not merged?
I had this same issue in a Remix application on mdx-bundler 10.0.1 and esbuild 0.20.1. I was able to fix it by adding this esbuildOptions
parameter to bundleMDX
:
esbuildOptions(options) {
options.define = {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
};
return options;
}
I had this same issue in a Remix application on mdx-bundler 10.0.1 and esbuild 0.20.1. I was able to fix it by adding this
esbuildOptions
parameter tobundleMDX
:esbuildOptions(options) { options.define = { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), }; return options; }
expected this to work, unfortunately it didn't in my case for whatever reason
was on esbuild 0.19.7
downgraded to 0.13.15
which fixed it for now 🫣
mdx-bundler
version: 9.2.1node
version: 16.14.2npm
version: 7.17.0Relevant code or config
The example code from https://github.com/kentcdodds/mdx-bundler#usage.
What you did:
Installed
mdx-bundler
andesbuild
and ran the example code.What happened:
Reproduction repository:
https://stackblitz.com/edit/node-syqie8
Problem description:
mdx-bundler
defines'process.env.NODE_ENV'
here, via JSON.stringify: https://github.com/kentcdodds/mdx-bundler/blob/f1f48285e870bdc21e5eb0db8c34dcc0dd0d1f75/src/index.js#L179.If the value
undefined
is passed toJSON.stringify
, it will return the valueundefined
(see mdn web docs).But
esbuild
expects a string instead. This was introduced in v0.16.0, see section "Add additional validation of API parameters" of https://github.com/evanw/esbuild/releases/tag/v0.16.0.Suggested solution:
Define
process.env.NODE_ENV
only if it is set.