generated from rspack-contrib/rsbuild-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1a9b88
commit c6526e9
Showing
16 changed files
with
1,431 additions
and
115 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
import { dirname } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { expect, test } from '@playwright/test'; | ||
import { createRsbuild, loadConfig } from '@rsbuild/core'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
test('should build basic Vue jsx correctly', async ({ page }) => { | ||
const rsbuild = await createRsbuild({ | ||
cwd: __dirname, | ||
rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, | ||
}); | ||
|
||
await rsbuild.build(); | ||
const { server, urls } = await rsbuild.preview(); | ||
|
||
await page.goto(urls[0]); | ||
const button1 = page.locator('#button1'); | ||
await expect(button1).toHaveText('A: 0'); | ||
|
||
await server.close(); | ||
}); |
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,18 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginBabel } from '@rsbuild/plugin-babel'; | ||
import { pluginVue2 } from '@rsbuild/plugin-vue2'; | ||
import { pluginVue2Jsx } from '../../dist'; | ||
import { getRandomPort } from '../helper'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
pluginVue2(), | ||
pluginVue2Jsx(), | ||
pluginBabel({ | ||
include: /\.(?:jsx|tsx)$/, | ||
}), | ||
], | ||
server: { | ||
port: getRandomPort(), | ||
}, | ||
}); |
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,19 @@ | ||
import { defineComponent } from 'vue'; | ||
|
||
export default defineComponent({ | ||
name: 'Test', | ||
|
||
data() { | ||
return { | ||
count: 0, | ||
}; | ||
}, | ||
|
||
render() { | ||
return ( | ||
<button id="button1" type="button" onClick={() => this.count++}> | ||
A: {this.count} | ||
</button> | ||
); | ||
}, | ||
}); |
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 Vue from 'vue'; | ||
import A from './A'; | ||
|
||
new Vue({ | ||
el: '#root', | ||
render: (h) => h(A), | ||
}); |
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 { dirname } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { expect, test } from '@playwright/test'; | ||
import { createRsbuild, loadConfig } from '@rsbuild/core'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
test('should build Vue sfc with lang="jsx" correctly', async ({ page }) => { | ||
const rsbuild = await createRsbuild({ | ||
cwd: __dirname, | ||
rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, | ||
}); | ||
|
||
await rsbuild.build(); | ||
const { server, urls } = await rsbuild.preview(); | ||
|
||
await page.goto(urls[0]); | ||
const button = page.locator('#button'); | ||
await expect(button).toHaveText('0'); | ||
|
||
const foo = page.locator('#foo'); | ||
await expect(foo).toHaveText('Foo'); | ||
|
||
await server.close(); | ||
}); |
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,18 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginBabel } from '@rsbuild/plugin-babel'; | ||
import { pluginVue2 } from '@rsbuild/plugin-vue2'; | ||
import { pluginVue2Jsx } from '@rsbuild/plugin-vue2-jsx'; | ||
import { getRandomPort } from '../helper'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
pluginVue2(), | ||
pluginVue2Jsx(), | ||
pluginBabel({ | ||
include: /\.(?:jsx|tsx)$/, | ||
}), | ||
], | ||
server: { | ||
port: getRandomPort(), | ||
}, | ||
}); |
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,27 @@ | ||
<template> | ||
<div> | ||
<button id="button" type="button" @click="count++">{{ count }}</button> | ||
<Foo /> | ||
</div> | ||
</template> | ||
|
||
<script lang="jsx"> | ||
import { ref } from 'vue'; | ||
const Foo = { | ||
render() { | ||
return <div id="foo">Foo</div>; | ||
}, | ||
}; | ||
export default { | ||
components: { | ||
Foo, | ||
}, | ||
setup() { | ||
const count = ref(0); | ||
return { count }; | ||
}, | ||
}; | ||
</script> |
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 Vue from 'vue'; | ||
import App from './App.vue'; | ||
|
||
new Vue({ | ||
el: '#root', | ||
render: (h) => h(App), | ||
}); |
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 { dirname } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { expect, test } from '@playwright/test'; | ||
import { createRsbuild, loadConfig } from '@rsbuild/core'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
test('should build Vue sfc with lang="tsx" correctly', async ({ page }) => { | ||
const rsbuild = await createRsbuild({ | ||
cwd: __dirname, | ||
rsbuildConfig: (await loadConfig({ cwd: __dirname })).content, | ||
}); | ||
|
||
await rsbuild.build(); | ||
const { server, urls } = await rsbuild.preview(); | ||
|
||
await page.goto(urls[0]); | ||
const button = page.locator('#button'); | ||
await expect(button).toHaveText('0'); | ||
|
||
const foo = page.locator('#foo'); | ||
await expect(foo).toHaveText('Foo'); | ||
|
||
await server.close(); | ||
}); |
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,18 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginBabel } from '@rsbuild/plugin-babel'; | ||
import { pluginVue2 } from '@rsbuild/plugin-vue2'; | ||
import { pluginVue2Jsx } from '@rsbuild/plugin-vue2-jsx'; | ||
import { getRandomPort } from '../helper'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
pluginVue2(), | ||
pluginVue2Jsx(), | ||
pluginBabel({ | ||
include: /\.(?:jsx|tsx)$/, | ||
}), | ||
], | ||
server: { | ||
port: getRandomPort(), | ||
}, | ||
}); |
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,27 @@ | ||
<template> | ||
<div> | ||
<button id="button" type="button" @click="count++">{{ count }}</button> | ||
<Foo /> | ||
</div> | ||
</template> | ||
|
||
<script lang="tsx"> | ||
import { ref } from 'vue'; | ||
const Foo = { | ||
render() { | ||
return <div id="foo">Foo</div>; | ||
}, | ||
}; | ||
export default { | ||
components: { | ||
Foo, | ||
}, | ||
setup() { | ||
const count = ref<number>(0); | ||
return { count }; | ||
}, | ||
}; | ||
</script> |
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 Vue from 'vue'; | ||
import App from './App.vue'; | ||
|
||
new Vue({ | ||
el: '#root', | ||
render: (h) => h(App), | ||
}); |