mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-10 23:02:56 +02:00
fix(mdx-loader): suppress image reading warning in Yarn PnP; log warning instead of error (#6779)
This commit is contained in:
parent
3e5da386ce
commit
9d7ed31661
2 changed files with 6 additions and 2 deletions
|
@ -59,7 +59,7 @@ describe('transformImage plugin', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('does not choke on invalid image', async () => {
|
test('does not choke on invalid image', async () => {
|
||||||
const errorMock = jest.spyOn(console, 'error').mockImplementation();
|
const errorMock = jest.spyOn(console, 'warn').mockImplementation();
|
||||||
const result = await processFixture('invalid-img', {staticDirs});
|
const result = await processFixture('invalid-img', {staticDirs});
|
||||||
expect(result).toMatchSnapshot();
|
expect(result).toMatchSnapshot();
|
||||||
expect(errorMock).toBeCalledTimes(1);
|
expect(errorMock).toBeCalledTimes(1);
|
||||||
|
|
|
@ -67,9 +67,13 @@ async function toImageRequireNode(
|
||||||
height = ` height="${size.height}"`;
|
height = ` height="${size.height}"`;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error`The image at path=${imagePath} can't be read correctly. Please ensure it's a valid image.
|
// Workaround for https://github.com/yarnpkg/berry/pull/3889#issuecomment-1034469784
|
||||||
|
// TODO remove this check once fixed in Yarn PnP
|
||||||
|
if (!process.versions.pnp) {
|
||||||
|
logger.warn`The image at path=${imagePath} can't be read correctly. Please ensure it's a valid image.
|
||||||
${(err as Error).message}`;
|
${(err as Error).message}`;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(jsxNode).forEach(
|
Object.keys(jsxNode).forEach(
|
||||||
(key) => delete jsxNode[key as keyof typeof jsxNode],
|
(key) => delete jsxNode[key as keyof typeof jsxNode],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue