Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/solid-component-bundle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @examples/solid-component

This example demonstrates how to use Rslib to build a simple SolidJS component.
22 changes: 22 additions & 0 deletions examples/solid-component-bundle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@examples/solid-component-bundle",
"version": "1.0.0",
"private": true,
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "rslib build"
},
"devDependencies": {
"@rsbuild/plugin-sass": "^1.3.1",
"@rsbuild/plugin-solid": "^1.0.5",
"@rslib/core": "workspace:*",
"solid-js": "^1.6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renovate will bump it to 1.9.0, is 1.6.0 being added purposely?

"typescript": "^5.8.3"
},
"peerDependencies": {
"solid-js": "^1.0.0"
}
}
16 changes: 16 additions & 0 deletions examples/solid-component-bundle/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { pluginSass } from '@rsbuild/plugin-sass';
import { pluginSolid } from '@rsbuild/plugin-solid';
import { defineConfig } from '@rslib/core';

export default defineConfig({
lib: [
{
format: 'esm',
dts: true,
},
],
output: {
target: 'web',
},
plugins: [pluginSolid(), pluginSass()],
});
1 change: 1 addition & 0 deletions examples/solid-component-bundle/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button {
background: yellow;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Component } from 'solid-js';
import styles from './index.module.scss';

interface CounterButtonProps {
onClick: () => void;
label: string;
}

export const CounterButton: Component<CounterButtonProps> = (props) => (
<button
type="button"
onClick={props.onClick}
classList={{ 'counter-button': true, [styles.button]: true }}
>
{props.label}
</button>
);
1 change: 1 addition & 0 deletions examples/solid-component-bundle/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@rslib/core/types" />
10 changes: 10 additions & 0 deletions examples/solid-component-bundle/src/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.counter-title {
width: 100px;
height: 100px;
background: no-repeat url('./assets/logo.svg');
background-size: cover;
}

.counter-text {
font-size: 50px;
}
17 changes: 17 additions & 0 deletions examples/solid-component-bundle/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Component } from 'solid-js';
import { CounterButton } from './components/CounterButton';
import { useCounter } from './useCounter';
import './index.scss';

export const Counter: Component = () => {
const { count, increment, decrement } = useCounter();

return (
<div>
<h1 class="counter-title">Solid</h1>
<h2 class="counter-text">Counter: {count()}</h2>
<CounterButton onClick={decrement} label="-" />
<CounterButton onClick={increment} label="+" />
</div>
);
};
10 changes: 10 additions & 0 deletions examples/solid-component-bundle/src/useCounter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createSignal } from 'solid-js';

export const useCounter = (initialValue = 0) => {
const [count, setCount] = createSignal(initialValue);

const increment = () => setCount((prev) => prev + 1);
const decrement = () => setCount((prev) => prev - 1);

return { count, increment, decrement };
};
19 changes: 19 additions & 0 deletions examples/solid-component-bundle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"jsxImportSource": "solid-js",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"baseUrl": "./src",
"paths": {
"@/*": ["*"]
}
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
135 changes: 135 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading