-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Dan Jutan <[email protected]>
- Loading branch information
Showing
12 changed files
with
329 additions
and
5 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,6 @@ | ||
--- | ||
'@astrojs/vue': minor | ||
'astro': patch | ||
--- | ||
|
||
Support Vue 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
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,7 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import vue from '@astrojs/vue'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [vue({ jsx: true })], | ||
}); |
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 @@ | ||
{ | ||
"name": "@test/vue-jsx", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/vue": "workspace:*", | ||
"astro": "workspace:*", | ||
"vue": "^3.2.39" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/astro/test/fixtures/vue-jsx/src/components/Counter.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,28 @@ | ||
import { defineComponent, ref } from 'vue'; | ||
|
||
export default defineComponent({ | ||
props: { | ||
start: { | ||
type: String, | ||
required: true | ||
}, | ||
stepSize: { | ||
type: String, | ||
default: "1" | ||
} | ||
}, | ||
setup(props) { | ||
const count = ref(parseInt(props.start)) | ||
const stepSize = ref(parseInt(props.stepSize)) | ||
const add = () => (count.value = count.value + stepSize.value); | ||
const subtract = () => (count.value = count.value - stepSize.value); | ||
return () => ( | ||
<div class="counter"> | ||
<h1><slot /></h1> | ||
<button onClick={subtract}>-</button> | ||
<pre>{count.value}</pre> | ||
<button onClick={add}>+</button> | ||
</div> | ||
) | ||
}, | ||
}) |
15 changes: 15 additions & 0 deletions
15
packages/astro/test/fixtures/vue-jsx/src/components/Result.vue
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 @@ | ||
<template> | ||
<pre>{{ value }}</pre> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
value: { | ||
type: Number, | ||
required: true | ||
} | ||
} | ||
} | ||
</script> |
35 changes: 35 additions & 0 deletions
35
packages/astro/test/fixtures/vue-jsx/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,35 @@ | ||
--- | ||
import Counter from '../components/Counter.jsx' | ||
import Result from '../components/Result.vue' | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width" | ||
/> | ||
<title>Vue component</title> | ||
<style> | ||
:global(:root) { | ||
font-family: system-ui; | ||
padding: 1em; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<main> | ||
<Result value={2345}></Result> | ||
<Counter start="0">SSR Rendered, No Client</Counter> | ||
<Counter start="1" client:load>SSR Rendered, client:load</Counter> | ||
<!-- Test island deduplication, i.e. same UID as the component above. --> | ||
<Counter start="1" client:load>SSR Rendered, client:load</Counter> | ||
<!-- Test island deduplication account for non-render affecting props. --> | ||
<Counter start="1" step-size="2" client:load>SSR Rendered, client:load</Counter> | ||
<Counter start="10" client:idle>SSR Rendered, client:idle</Counter> | ||
<!-- Test that two client:visibles have unique uids --> | ||
<Counter start="100" client:visible>SSR Rendered, client:visible</Counter> | ||
<Counter start="1000" client:visible>SSR Rendered, client:visible</Counter> | ||
</main> | ||
</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,30 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Vue JSX', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/vue-jsx/', | ||
}); | ||
}); | ||
|
||
describe('build', () => { | ||
before(async () => { | ||
await fixture.build(); | ||
}); | ||
|
||
it('Can load Vue JSX', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
const allPreValues = $('pre') | ||
.toArray() | ||
.map((el) => $(el).text()); | ||
|
||
expect(allPreValues).to.deep.equal(['2345', '0', '1', '1', '1', '10', '100', '1000']); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.