Closed as not planned
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
1.6.22
Link to runnable example
No response
Steps to reproduce
- Use this project.
- Run one of the following commands
pnpm install && pnpm build
yarn set version stable && yarn install && yarn build
yarn install --pnp && yarn build
The problem seems to be that
Lines 4 to 7 in c91b00c
assumes that
@mdx-js/react
will have been hoisted into the project's node_modules directory so webpack can find it when processing the transformed file later. Changing that to
const DEFAULT_RENDERER = `
import React from ${ JSON.stringify( require.resolve( 'react' ) ) }
import { mdx } from ${ JSON.stringify( require.resolve( '@mdx-js/react' ) ) }
`
makes it work (at least in pnpm).
I note this problem doesn't seem to occur with version 2.0.0 or later. However, I'm not using @mdx-js/loader
directly, I'm using it via @storybook/addon-docs
which still depends on @mdx-js/loader
^1.6.22
, so updating to v2 is not currently an option.
Expected behavior
Project should build without error.
Actual behavior
Build fails with this error
ERROR in ./test.mdx 4:0-36
Module not found: Error: Can't resolve '@mdx-js/react' in '/tmp/test'
resolve '@mdx-js/react' in '/tmp/test'
Parsed request is a module
using description file: /tmp/test/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in /tmp/test/node_modules
single file module
using description file: /tmp/test/package.json (relative path: ./node_modules/@mdx-js/react)
no extension
Field 'browser' doesn't contain a valid alias configuration
/tmp/test/node_modules/@mdx-js/react doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/tmp/test/node_modules/@mdx-js/react.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/tmp/test/node_modules/@mdx-js/react.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
/tmp/test/node_modules/@mdx-js/react.wasm doesn't exist
/tmp/test/node_modules/@mdx-js/react doesn't exist
/tmp/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
Runtime
Node v16
Package manager
yarn v3, yarn v1, pnpm
OS
Linux
Build and bundle tools
webpack