-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(renderer): omitting internal symbol from mdx props (#10813)
- Loading branch information
Showing
10 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrojs/mdx": patch | ||
--- | ||
|
||
Omitting compiler-internal symbol from user components to fix breaking error messages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import mdx from '@astrojs/mdx'; | ||
import react from '@astrojs/react'; | ||
|
||
export default { | ||
integrations: [mdx(), react()], | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@test/mdx-plus-react-errors", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/mdx": "workspace:*", | ||
"@astrojs/react": "workspace:*", | ||
"astro": "workspace:*", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...s/integrations/mdx/test/fixtures/mdx-plus-react-errors/src/components/BrokenComponent.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useState } from "react"; | ||
|
||
export default function BrokenComponent() { | ||
useState(0); | ||
a; | ||
|
||
return <p>Whoops!</p>; | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/src/content/config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { z, defineCollection } from "astro:content"; | ||
|
||
const filesSchema = () => { | ||
return z.object({}); | ||
}; | ||
|
||
const filesCollection = defineCollection({ | ||
type: "content", | ||
schema: filesSchema(), | ||
}); | ||
|
||
export const collections = { files: filesCollection, }; |
4 changes: 4 additions & 0 deletions
4
...integrations/mdx/test/fixtures/mdx-plus-react-errors/src/content/files/file.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
import BrokenComponent from '../../components/BrokenComponent' | ||
|
||
<BrokenComponent {...props} /> |
9 changes: 9 additions & 0 deletions
9
packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/src/pages/broken.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
import { getCollection } from "astro:content"; | ||
const files = await getCollection("files"); | ||
const { Content } = await files[0].render(); | ||
--- | ||
|
||
<Content /> | ||
|
33 changes: 33 additions & 0 deletions
33
packages/integrations/mdx/test/mdx-plus-react-errors.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as assert from 'node:assert/strict'; | ||
import { describe, it } from 'node:test'; | ||
import { loadFixture } from '../../../astro/test/test-utils.js'; | ||
|
||
function hookError() { | ||
const error = console.error; | ||
const errors = []; | ||
console.error = function (...args) { | ||
errors.push(args); | ||
}; | ||
return () => { | ||
console.error = error; | ||
return errors; | ||
}; | ||
} | ||
|
||
describe('MDX and React with build errors', () => { | ||
let fixture; | ||
let unhook; | ||
|
||
it('shows correct error messages on build error', async () => { | ||
try { | ||
fixture = await loadFixture({ | ||
root: new URL('./fixtures/mdx-plus-react-errors/', import.meta.url), | ||
}); | ||
unhook = hookError(); | ||
await fixture.build(); | ||
} catch (err) { | ||
assert.equal(err.message, 'a is not defined'); | ||
} | ||
unhook(); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.