-
-
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.
Only rethrow renderer error when no renderer found (#4131)
* Only rethrow renderer error when no renderer found * Adds a changeset
- Loading branch information
Showing
13 changed files
with
147 additions
and
1 deletion.
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 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fixes use of multiple renderers when one throws |
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/astro/test/fixtures/multiple-renderers/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 one from '@astrojs/renderer-one'; | ||
import two from '@astrojs/renderer-two'; | ||
|
||
export default { | ||
integrations: [one(), two()] | ||
}; |
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 @@ | ||
{ | ||
"name": "@test/multiple-renderers", | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/renderer-one": "file:./renderers/one", | ||
"@astrojs/renderer-two": "file:./renderers/two" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/astro/test/fixtures/multiple-renderers/renderers/one/index.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,15 @@ | ||
|
||
export default function() { | ||
return { | ||
name: 'renderer-one', | ||
hooks: { | ||
'astro:config:setup': ({ addRenderer }) => { | ||
addRenderer({ | ||
name: 'renderer-one', | ||
clientEntrypoint: null, | ||
serverEntrypoint: '@astrojs/renderer-one/server.mjs', | ||
}); | ||
} | ||
} | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/multiple-renderers/renderers/one/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,5 @@ | ||
{ | ||
"name": "@astrojs/renderer-one", | ||
"version": "1.0.0", | ||
"main": "index.mjs" | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/multiple-renderers/renderers/one/server.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,11 @@ | ||
|
||
export default { | ||
check() { | ||
throw new Error(`Oops this did not work`); | ||
}, | ||
renderToStaticMarkup(Component) { | ||
return { | ||
html: Component() | ||
}; | ||
}, | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/astro/test/fixtures/multiple-renderers/renderers/two/index.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,15 @@ | ||
|
||
export default function() { | ||
return { | ||
name: 'renderer-two', | ||
hooks: { | ||
'astro:config:setup': ({ addRenderer }) => { | ||
addRenderer({ | ||
name: 'renderer-two', | ||
clientEntrypoint: null, | ||
serverEntrypoint: '@astrojs/renderer-two/server.mjs', | ||
}); | ||
} | ||
} | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/astro/test/fixtures/multiple-renderers/renderers/two/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,5 @@ | ||
{ | ||
"name": "@astrojs/renderer-two", | ||
"version": "1.0.0", | ||
"main": "index.mjs" | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/astro/test/fixtures/multiple-renderers/renderers/two/server.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,11 @@ | ||
|
||
export default { | ||
check() { | ||
return true; | ||
}, | ||
renderToStaticMarkup(Component) { | ||
return { | ||
html: Component() | ||
}; | ||
}, | ||
}; |
14 changes: 14 additions & 0 deletions
14
packages/astro/test/fixtures/multiple-renderers/src/pages/index.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,14 @@ | ||
--- | ||
function Component() { | ||
return `<div id="component">works</div>`; | ||
} | ||
--- | ||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<h1>Testing</h1> | ||
<Component /> | ||
</body> | ||
</html> |
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,21 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Multiple renderers', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/multiple-renderers/', | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('when the first throws but the second does not, use the second renderer', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('#component')).to.have.a.lengthOf(1); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.