Skip to content

Commit

Permalink
doc: update entryPoint documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerioageno committed Mar 9, 2024
1 parent 2503359 commit df94a17
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,34 @@ fn main() {

## What is the "entryPoint"?

The `entryPoint` is the function that returns an object with one or more properties that are functions that when called return the rendered result.
The `entryPoint` could be either:
- the function that returns an object with one or more properties that are functions that when called return the rendered result
- the object itself with one or more properties that are functions that when called return the rendered result

In case the bundled JS is an IIFE the `entryPoint` is an empty string.
In case the bundled JS is an IIFE or the plain object the `entryPoint` is an empty string.

```javascript
// IIFE example | bundle.js -> See vite-react example
(() => ({ renderToStringFn: (props) => "<html></html>" }))() // The entryPoint is an empty string
```

```javascript
// Plain object example | bundle.js
({renderToStringFn: (props) => "<html></html>"}); // The entryPoint is an empty string
```

```javascript
// IIFE varible example | bundle.js -> See webpack-react example
var SSR = (() => ({renderToStringFn: (props) => "<html></html>"}))() // SSR is the entry point
```

```javascript
// Varible example | bundle.js -> See webpack-react example
var SSR = () => ({renderToStringFn: (props) => "<html></html>"}) // SSR is the entry point
var SSR = {renderToStringFn: (props) => "<html></html>"}; // SSR is the entry point
```

> The exports results are managed by the bundler directly.
## Example with initial props

```rust
Expand Down
24 changes: 20 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,35 @@
//! }
//! ```
//! ## What is the "entryPoint"?
//! The `entryPoint` is the function that returns an object with one or more properties that are functions that when called return the rendered result.
//! In case the bundled JS is an IIFE the `entryPoint` is an empty string.
//!
//! The `entryPoint` could be either:
//! - the function that returns an object with one or more properties that are functions that when called return the rendered result
//! - the object itself with one or more properties that are functions that when called return the rendered result
//!
//! In case the bundled JS is an IIFE or the plain object the `entryPoint` is an empty string.
//!
//! ```javascript
//! // IIFE example | bundle.js -> See vite-react example
//! (() => ({ renderToStringFn: (props) => "<html></html>" }))() // The entryPoint is an empty string
//! ```
//! ```javascript
//! // Plain object example | bundle.js
//! ({renderToStringFn: (props) => "<html></html>"}); // The entryPoint is an empty string
//! ```
//! ```javascript
//! // IIFE varible example | bundle.js -> See webpack-react example
//! var SSR = (() => ({renderToStringFn: (props) => "<html></html>"}))() // SSR is the entry point
//! ```
//! ```javascript
//! // Varible example | bundle.js -> See webpack-react example
//! var SSR = () => ({renderToStringFn: (props) => "<html></html>"}) // SSR is the entry point
//! var SSR = {renderToStringFn: (props) => "<html></html>"}; // SSR is the entry point
//! ```
//!
//! > The exports results are managed by the bundler directly.
//!
//! # Example with initial props
//!
//! ```no_run
Expand Down

0 comments on commit df94a17

Please sign in to comment.