You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/T03-templates.md
+48-1Lines changed: 48 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Registry selection:
33
33
34
34
A custom template is just an npm package that fulfills the following requirements:
35
35
36
-
1. Expose a CommonJS module (`main` in the *package.json*)
36
+
1. Expose a **CommonJS module** (`main` in the *package.json*)
37
37
2. Have a `default` export being a function specified below
38
38
3. Have `template` and either `pilet` (for pilets) or `piral` (for Piral instances) as keyword
39
39
@@ -84,3 +84,50 @@ interface ExecutionDetails {
84
84
```
85
85
86
86
This way, the template packages are essentially factories to create virtual files which are then written out by the `piral-cli`.
87
+
88
+
The easiest way to have a convenient codebase and adhere to the CommonJS output is to use a bundler such as `esbuild`. For instance, the following code (stored in *src/index.js*) would not work directly:
Importantly, you can run `npm run build` to convert the original ES module codebase to a single file stored in *lib/index.js*. This way, you do not need to declare runtime dependencies such as `@smapiot/template-utils` (they can remain a development-only dependency) and you obtain a legit CommonJS module.
Copy file name to clipboardExpand all lines: docs/static/schemas/piral-v0.json
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,10 @@
92
92
],
93
93
"description": "Defines how the styles for the web components are transported. 'inline' puts them on the web components when rendering, 'sheet' includes a stylesheet when bundling, 'none' requires you to include them somewhere. By default, 'inline' is used."
94
94
},
95
+
"remoteTypesSource": {
96
+
"type": "string",
97
+
"description": "The URL of the generated d.ts combining extra type information from all pilets."
Copy file name to clipboardExpand all lines: docs/tutorials/11-server-side-rendering.md
-47Lines changed: 0 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -168,53 +168,6 @@ The diagram below shows this sequence.
168
168
169
169
**Remark**: The replacement for the embedded data needs to be placed *before* the root module (in the example above `<script src="index.tsx"></script>`) is referenced.
170
170
171
-
The embedded data is either the data from the pilet feed (this section) or the data from the feed including the pilets (see next section).
172
-
173
-
## Embedding the Pilets
174
-
175
-
Embedding the pilet feed may already be enough to provide improved startup performance. Nevertheless, especially for "cold starts", i.e., where no pilets have yet been seen or loaded, it can make sense to also deliver the pilets with the initial response.
176
-
177
-
Following the approach described beforehand, we can extend the `sendIndex` function to also include the pilets.
178
-
179
-
The only thing to add is the `getPilet` function in the provided options. This way, we can tell the SSR utility how to retrieve a pilet from its link.
Generally, this approach gives us quite some flexibility. It allows us to use caching in addition to HTTP requests. It also allows us to embed a pilet feed directly on the server-side, potentially not requiring any feed seen outside.
217
-
218
171
## Conclusion
219
172
220
173
SSR can be helpful to improve startup performance and user experience. The cost of optimizing the backend is, however, not negligible and should be considered, too. Providing the fastest response possible to pilet feed and general page requests could be already sufficient to ensure a great user experience.
0 commit comments