-
Notifications
You must be signed in to change notification settings - Fork 1
feat(create-rstack): add Vue library templates #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chenjiahan
merged 1 commit into
main
from
chenjiahan/feat-create-rstack-vue-library-templates
Aug 8, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| # AGENTS.md | ||
|
|
||
| ## Commands | ||
|
|
||
| - `{{ packageManager }} run build` - Build the library for production | ||
| - `{{ packageManager }} run dev` - Rebuild the library when source files change | ||
| - `{{ packageManager }} run test` - Run tests | ||
| - `{{ packageManager }} run test:watch` - Run tests in watch mode | ||
|
|
||
| ## Docs | ||
|
|
||
| - Rslib: https://rslib.rs/llms.txt | ||
| - Rspack: https://rspack.rs/llms.txt | ||
| - Rstest: https://rstest.rs/llms.txt |
This file contains hidden or 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,40 @@ | ||
| # Rstack library | ||
|
|
||
| ## Setup | ||
|
|
||
| Install the dependencies: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} install | ||
| ``` | ||
|
|
||
| ## Get started | ||
|
|
||
| Build the library: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run build | ||
| ``` | ||
|
|
||
| Build the library in watch mode: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run dev | ||
| ``` | ||
|
|
||
| Run tests: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run test | ||
| ``` | ||
|
|
||
| Run tests in watch mode: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run test:watch | ||
| ``` | ||
|
|
||
| ## Learn more | ||
|
|
||
| - [Rstack documentation](https://rstack.rs) | ||
| - [Rslib documentation](https://rslib.rs) |
This file contains hidden or 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,37 @@ | ||
| { | ||
| "name": "rstack-lib-vue-js", | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "default": "./dist/index.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "README.md" | ||
| ], | ||
| "scripts": { | ||
| "build": "rs lib", | ||
| "dev": "rs lib --watch", | ||
| "format": "rs fmt", | ||
| "lint": "rs lint", | ||
| "test": "rs test", | ||
| "test:watch": "rs test --watch" | ||
| }, | ||
| "devDependencies": { | ||
| "@rsbuild/plugin-vue": "^2.0.1", | ||
| "@testing-library/jest-dom": "^7.0.0", | ||
| "@testing-library/vue": "^8.1.0", | ||
| "@vue/test-utils": "^2.4.11", | ||
| "happy-dom": "^20.11.1", | ||
| "rstack": "^0.3.5", | ||
| "vue": "^3.5.40" | ||
| }, | ||
| "peerDependencies": { | ||
| "vue": ">=3.2.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
packages/create-rstack/template-lib-vue-js/rstack.config.js
This file contains hidden or 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 @@ | ||
| // @ts-check | ||
| // Rstack configuration guide: https://rstack.rs/config | ||
| import { define } from 'rstack'; | ||
|
|
||
| define.lib(async () => { | ||
| const { pluginVue } = await import('@rsbuild/plugin-vue'); | ||
|
|
||
| return { | ||
| bundle: false, | ||
| source: { | ||
| entry: { | ||
| index: ['./src/**'], | ||
| }, | ||
| }, | ||
| output: { | ||
| target: 'web', | ||
| }, | ||
| plugins: [pluginVue()], | ||
| }; | ||
| }); | ||
|
|
||
| define.test({ | ||
| setupFiles: ['./tests/rstest.setup.js'], | ||
| }); | ||
|
|
||
| define.lint(async () => { | ||
| const { js } = await import('rstack/lint'); | ||
|
|
||
| return [js.configs.recommended]; | ||
| }); |
This file contains hidden or 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,41 @@ | ||
| <script setup> | ||
| import { computed } from 'vue'; | ||
| import './button.css'; | ||
|
|
||
| const { | ||
| primary = false, | ||
| backgroundColor, | ||
| size = 'medium', | ||
| label, | ||
| onClick, | ||
| } = defineProps({ | ||
| primary: { | ||
| type: Boolean, | ||
| }, | ||
| backgroundColor: { | ||
| type: String, | ||
| }, | ||
| size: { | ||
| type: String, | ||
| }, | ||
| label: { | ||
| type: String, | ||
| }, | ||
| onClick: { | ||
| type: Function, | ||
| }, | ||
| }); | ||
|
|
||
| const mode = computed(() => (primary ? 'demo-button--primary' : 'demo-button--secondary')); | ||
| </script> | ||
|
|
||
| <template> | ||
| <button | ||
| type="button" | ||
| :class="['demo-button', `demo-button--${size}`, mode]" | ||
| :style="{ backgroundColor }" | ||
| @click="onClick" | ||
| > | ||
| {{ label }} | ||
| </button> | ||
| </template> |
This file contains hidden or 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,34 @@ | ||
| .demo-button { | ||
| font-weight: 700; | ||
| border: 0; | ||
| border-radius: 3em; | ||
| cursor: pointer; | ||
| display: inline-block; | ||
| line-height: 1; | ||
| } | ||
|
|
||
| .demo-button--primary { | ||
| color: white; | ||
| background-color: #1ea7fd; | ||
| } | ||
|
|
||
| .demo-button--secondary { | ||
| color: #333; | ||
| background-color: transparent; | ||
| box-shadow: rgba(0, 0, 0, 0.15) 0 0 0 1px inset; | ||
| } | ||
|
|
||
| .demo-button--small { | ||
| font-size: 12px; | ||
| padding: 10px 16px; | ||
| } | ||
|
|
||
| .demo-button--medium { | ||
| font-size: 14px; | ||
| padding: 11px 20px; | ||
| } | ||
|
|
||
| .demo-button--large { | ||
| font-size: 16px; | ||
| padding: 12px 24px; | ||
| } |
This file contains hidden or 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 @@ | ||
| export { default as Button } from './Button.vue'; |
16 changes: 16 additions & 0 deletions
16
packages/create-rstack/template-lib-vue-js/tests/index.test.js
This file contains hidden or 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,16 @@ | ||
| import { expect, test } from 'rstack/test'; | ||
| import { render, screen } from '@testing-library/vue'; | ||
| import Button from '../src/Button.vue'; | ||
|
|
||
| test('The button should have correct background color', async () => { | ||
| render(Button, { | ||
| props: { | ||
| backgroundColor: '#ccc', | ||
| label: 'Demo Button', | ||
| }, | ||
| }); | ||
| const button = screen.getByText('Demo Button'); | ||
| expect(button).toHaveStyle({ | ||
| backgroundColor: '#ccc', | ||
| }); | ||
| }); |
4 changes: 4 additions & 0 deletions
4
packages/create-rstack/template-lib-vue-js/tests/rstest.setup.js
This file contains hidden or 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 { expect } from 'rstack/test'; | ||
| import * as jestDomMatchers from '@testing-library/jest-dom/matchers'; | ||
|
|
||
| expect.extend(jestDomMatchers); |
This file contains hidden or 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 @@ | ||
| # AGENTS.md | ||
|
|
||
| ## Commands | ||
|
|
||
| - `{{ packageManager }} run build` - Build the library for production | ||
| - `{{ packageManager }} run dev` - Rebuild the library when source files change | ||
| - `{{ packageManager }} run test` - Run tests | ||
| - `{{ packageManager }} run test:watch` - Run tests in watch mode | ||
|
|
||
| ## Docs | ||
|
|
||
| - Rslib: https://rslib.rs/llms.txt | ||
| - Rspack: https://rspack.rs/llms.txt | ||
| - Rstest: https://rstest.rs/llms.txt |
This file contains hidden or 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,40 @@ | ||
| # Rstack library | ||
|
|
||
| ## Setup | ||
|
|
||
| Install the dependencies: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} install | ||
| ``` | ||
|
|
||
| ## Get started | ||
|
|
||
| Build the library: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run build | ||
| ``` | ||
|
|
||
| Build the library in watch mode: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run dev | ||
| ``` | ||
|
|
||
| Run tests: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run test | ||
| ``` | ||
|
|
||
| Run tests in watch mode: | ||
|
|
||
| ```bash | ||
| {{ packageManager }} run test:watch | ||
| ``` | ||
|
|
||
| ## Learn more | ||
|
|
||
| - [Rstack documentation](https://rstack.rs) | ||
| - [Rslib documentation](https://rslib.rs) |
This file contains hidden or 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,42 @@ | ||
| { | ||
| "name": "rstack-lib-vue-ts", | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| } | ||
| }, | ||
| "types": "./dist/index.d.ts", | ||
| "files": [ | ||
| "dist", | ||
| "README.md" | ||
| ], | ||
| "scripts": { | ||
| "build": "rs lib && vue-tsc", | ||
| "dev": "rs lib --watch", | ||
| "format": "rs fmt", | ||
| "lint": "rs lint", | ||
| "test": "rs test", | ||
| "test:watch": "rs test --watch" | ||
| }, | ||
| "devDependencies": { | ||
| "@rsbuild/plugin-vue": "^2.0.1", | ||
| "@testing-library/jest-dom": "^7.0.0", | ||
| "@testing-library/vue": "^8.1.0", | ||
| "@types/node": "^24.13.3", | ||
| "@vue/test-utils": "^2.4.11", | ||
| "happy-dom": "^20.11.1", | ||
| "rstack": "^0.3.5", | ||
| "typescript": "^6.0.3", | ||
| "vue": "^3.5.40", | ||
| "vue-tsc": "^3.3.9" | ||
| }, | ||
| "peerDependencies": { | ||
| "vue": ">=3.2.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
packages/create-rstack/template-lib-vue-ts/rstack.config.ts
This file contains hidden or 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,29 @@ | ||
| // Rstack configuration guide: https://rstack.rs/config | ||
| import { define } from 'rstack'; | ||
|
|
||
| define.lib(async () => { | ||
| const { pluginVue } = await import('@rsbuild/plugin-vue'); | ||
|
|
||
| return { | ||
| bundle: false, | ||
| source: { | ||
| entry: { | ||
| index: ['./src/**'], | ||
| }, | ||
| }, | ||
| output: { | ||
| target: 'web', | ||
| }, | ||
| plugins: [pluginVue()], | ||
| }; | ||
| }); | ||
|
|
||
| define.test({ | ||
| setupFiles: ['./tests/rstest.setup.ts'], | ||
| }); | ||
|
|
||
| define.lint(async () => { | ||
| const { js, ts } = await import('rstack/lint'); | ||
|
|
||
| return [js.configs.recommended, ts.configs.recommended]; | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.