-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/check-deps
- Loading branch information
Showing
54 changed files
with
649 additions
and
64 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
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
2 changes: 2 additions & 0 deletions
2
examples/react-component-bundle-false/src/components/CounterButton/index.tsx
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
2 changes: 2 additions & 0 deletions
2
examples/react-component-bundle/src/components/CounterButton/index.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @examples/react-component-umd | ||
|
||
This example demonstrates how to use Rslib to build a simple React component with umd format output. |
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 @@ | ||
{ | ||
"name": "@examples/react-component-umd", | ||
"private": true, | ||
"main": "./dist/umd/index.js", | ||
"unpkg": "./dist/umd/index.js", | ||
"scripts": { | ||
"build": "rslib build" | ||
}, | ||
"devDependencies": { | ||
"@rsbuild/plugin-react": "^1.0.4", | ||
"@rsbuild/plugin-sass": "^1.0.3", | ||
"@rslib/core": "workspace:*", | ||
"@types/react": "^18.3.11", | ||
"react": "^18.3.1" | ||
}, | ||
"peerDependencies": { | ||
"react": "*" | ||
} | ||
} |
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 { pluginReact } from '@rsbuild/plugin-react'; | ||
import { pluginSass } from '@rsbuild/plugin-sass'; | ||
import { defineConfig } from '@rslib/core'; | ||
|
||
export default defineConfig({ | ||
lib: [ | ||
{ | ||
format: 'umd', | ||
umdName: 'RslibUmdExample', | ||
output: { | ||
externals: { | ||
react: 'React', | ||
}, | ||
distPath: { | ||
root: './dist/umd', | ||
}, | ||
}, | ||
}, | ||
], | ||
plugins: [ | ||
pluginReact({ | ||
swcReactOptions: { | ||
runtime: 'classic', | ||
}, | ||
}), | ||
pluginSass(), | ||
], | ||
}); |
3 changes: 3 additions & 0 deletions
3
examples/react-component-umd/src/components/CounterButton/index.module.scss
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,3 @@ | ||
.button { | ||
background: yellow; | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/react-component-umd/src/components/CounterButton/index.tsx
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,16 @@ | ||
import React from 'react'; | ||
import styles from './index.module.scss'; | ||
|
||
interface CounterButtonProps { | ||
onClick: () => void; | ||
label: string; | ||
} | ||
|
||
export const CounterButton: React.FC<CounterButtonProps> = ({ | ||
onClick, | ||
label, | ||
}) => ( | ||
<button type="button" className={styles.button} onClick={onClick}> | ||
{label} | ||
</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,4 @@ | ||
declare module '*.module.scss' { | ||
const classes: { [key: string]: string }; | ||
export default classes; | ||
} |
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,3 @@ | ||
.counter-text { | ||
font-size: 50px; | ||
} |
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,16 @@ | ||
import React from 'react'; | ||
import { CounterButton } from './components/CounterButton/index'; | ||
import { useCounter } from './useCounter'; | ||
import './index.scss'; | ||
|
||
export const Counter: React.FC = () => { | ||
const { count, increment, decrement } = useCounter(); | ||
|
||
return ( | ||
<div> | ||
<h2 className="counter-text">Counter: {count}</h2> | ||
<CounterButton onClick={decrement} label="-" /> | ||
<CounterButton onClick={increment} label="+" /> | ||
</div> | ||
); | ||
}; |
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 { useState } from 'react'; | ||
|
||
export const useCounter = (initialValue = 0) => { | ||
const [count, setCount] = useState(initialValue); | ||
|
||
const increment = () => setCount((prev) => prev + 1); | ||
const decrement = () => setCount((prev) => prev - 1); | ||
|
||
return { count, increment, decrement }; | ||
}; |
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,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"baseUrl": ".", | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"isolatedModules": true, | ||
"jsx": "react", | ||
"lib": ["DOM", "ESNext"], | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"rootDir": "src", | ||
"skipLibCheck": true, | ||
"strict": true | ||
}, | ||
"exclude": ["**/node_modules"], | ||
"include": ["src"] | ||
} |
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
Oops, something went wrong.