-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle loading the Code package in the static build (#2337)
* Handle loading the Code package Fixes #2329 * Use Code the normal way * Adds a changeset * Only resolve browser path if there is no common ancestor * Update examples/fast-build/src/pages/index.astro Co-authored-by: Nate Moore <[email protected]> Co-authored-by: Nate Moore <[email protected]>
- Loading branch information
1 parent
c3c054c
commit 180dfcf
Showing
8 changed files
with
87 additions
and
4 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 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix using the Code component in static build |
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
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
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
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
10 changes: 10 additions & 0 deletions
10
packages/astro/test/fixtures/static-build-code-component/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,10 @@ | ||
--- | ||
import {Code} from 'astro/components'; | ||
--- | ||
<html> | ||
<head><title>Testing</title></head> | ||
<body> | ||
<h1>Test</h1> | ||
<Code lang="js" code={`const foo = 'bar';`} /> | ||
</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,25 @@ | ||
import { expect } from 'chai'; | ||
import cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Code component inside static build', () => { | ||
let fixture; | ||
|
||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
projectRoot: './fixtures/static-build-code-component/', | ||
renderers: [], | ||
buildOptions: { | ||
experimentalStaticBuild: true, | ||
} | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
it('Is able to build successfully', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('pre').length, 1, 'pre tag loaded'); | ||
}); | ||
}); |
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