Commit Graph
55 Commits
Author SHA1 Message Date
ayame113 b51f83b42d fix: actually preload all necessary files (#1242) 2023-06-03 22:07:01 +02:00
Asher Gomez 02dec2f483 chore: upgrade preact-render-to-string to 6.0.3 (#1236) 2023-06-02 16:24:14 +02:00
ayame113andLuca Casonato 7b35cb07d4 feat: preloading JavaScript files (#1189)
close #1187

## points

- use `<link rel="modulepreload">` tag and `Link: rel="modulepreload"`
header to preload dependencies
- No preloading at all for pages that don't use JavaScript at all.
- Information about preloading is delivered only when the JS file has
already been built. If the JS file hasn't finished building, it will
respond without preload information instead of waiting for the build and
then returning the HTML.

## performance comparison

I've deployed this branch to https://fresh-module-preload.deno.dev/ so
you can try it out and see how it behaves.

When I accessed [fresh.deno.dev](https://fresh.deno.dev/) and
[fresh-module-preload.deno.dev](https://fresh-module-preload.deno.dev/)
20 times each and measured the DOMContentLoaded time, it was 24% faster
(157.3ms -> 118.95ms) in my environment (Nagano City, Japan).

<details>
<summary>Actual measured data</summary>

(Don't forget to check `Disable Cache` in devtools)

 | afeter (ms) | before (ms)
-- | -- | --
0 | 180 | 152
1 | 82 | 144
2 | 78 | 186
3 | 156 | 196
4 | 88 | 211
5 | 85 | 123
6 | 162 | 209
7 | 154 | 110
8 | 86 | 175
9 | 135 | 109
10 | 183 | 117
11 | 115 | 159
12 | 99 | 173
13 | 83 | 131
14 | 82 | 142
15 | 135 | 160
16 | 120 | 125
17 | 148 | 152
18 | 118 | 229
19 | 90 | 143
average | 118.95 | 157.3

</details>

## screen shots


![image](https://github.com/denoland/fresh/assets/40050810/c8f6d46b-77da-4e20-b29c-3b0219907872)


![image](https://github.com/denoland/fresh/assets/40050810/3159904c-07f0-45ee-a9ca-7bed35a292ca)

---------

Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-06-01 11:18:28 +10:00
Luca Casonato a6852fa58f feat: more advanced prop serializer for islands (#1224)
This commit adds support for an advanced (de)serializer that is used
for page state (island props and plugin state). This new serializer
supports maintaining references (thus supporting circular objects,
and multi-referenced objects).

This is a pre-requisite for allowing to pass signals, JSX, Uint8Arrays,
Date, and many other "advanced" values.
2023-05-31 10:12:07 +02:00
Leo Kettmeir 060e2bb50d feat: add status and headers overwrite for HandlerContext.render (#725) 2023-05-31 10:09:53 +02:00
Luca Casonato 96ba036c12 fix: better HEAD handling with less special casing (#1206)
We now add a default HEAD handler to the server, rather than special
casing HEAD requests elsewhere. Static files now get their own optimized
HEAD handler that does not read the file contents.
2023-05-30 17:22:18 +10:00
Luca CasonatoandAsher Gomez 87b087e358 fix: __FRSH_BUILD_ID is not defined (#1207)
This could happen if the runtime/utils.ts coe was loaded
prior to server/constants.ts, because they had some shared state on
`globalThis`.

I have mitigated this by not relying on global state anymore.

Fixes #1191

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-30 10:46:44 +10:00
Luca CasonatoandAsher Gomez f95f7586f5 fix: don't change scheme on redirect (#1024)
Fixes #1015

This scenario can happen when a user has a proxy sitting in front of
Fresh, that does TLS termination, while Fresh is running on plain text
HTTP.

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-25 18:40:40 +10:00
Kamil OgórekandAsher Gomez e86a126c0a feat(server): Allow for custom HEAD method implementations (#1175)
Fixes https://github.com/denoland/fresh/issues/1115
Fixes https://github.com/denoland/fresh/issues/1165

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2023-05-25 08:55:09 +10:00
Luca CasonatoandJohn Pope 96b89d2a05 fix: cleanup pathname with multiple trailing slashes (#1167)
Co-authored-by: John Pope <88814278+innovatedev-john-pope@users.noreply.github.com>
2023-05-12 17:34:45 +02:00
Leo Kettmeir 9dd026e0f5 feat: add middleware destination (#1123)
Closes #521
2023-04-20 13:14:12 +02:00
Yoshiya Hinosawa eed9f0ef05 chore: fix ci (#1102) 2023-04-04 14:13:21 +09:00
Sylvain CauandLuca Casonato 7e72fa236c refactor: remove deno.run (#1036)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2023-03-10 04:57:16 +09:00
hashrock f04716df5c fix(context): handle HEAD requests (#1034) 2023-02-27 16:37:40 -04:00
Mark BennettandLuca Casonato ba7c78bcc2 feat: experimental support for Deno.serve (#681)
The experimental support can be enabled through the
`experimentalDenoServe` option for `start()`.

Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-09-07 23:04:45 +00:00
Sourav Singh Rawat 08d43803f7 feat: add support for custom static folder in FreshOptions (#626)
Support custom (user provided) static assets folder or fallback to default behavior.
2022-09-05 12:00:47 +00:00
Luca Casonato b12867a582 feat: support JSX automatic mode (#610)
This commit adds support for JSX automatic mode instead of the default
mode that requires the presence of the JSX pragma in each file.

This commit also adds the config file to the `fresh.gen.ts` manifest,
which is used to determine if the client emit should use automatic mode.

The minimum Deno version has also been bumped to 1.25.0.
2022-08-26 11:03:00 +02:00
ahuigo a00b97bac9 feat: support multiple middlewares with the same matcher (#553) 2022-08-23 23:50:57 +02:00
Luca Casonato fd4e2bbe17 feat: add initial plugin support (#512)
This commit adds initial support for fresh "plugins". These are bundles
of functionality that can be added to a fresh plugin through a simple
addition in the `main.ts` file.

Right now plugins are only able to hook into the render steps. This
means that they can inject styling and scripts. They can not yet hook
into routing.

Things that I think should be possible now:
- styling integrations for twind, unocss, and probably a few other tools

Things that are not possible yet:
- google analytics middleware
- database connectors
- CMS connectors

The routing additions to plugins can be added in a follow-up though.
2022-08-09 21:27:58 +02:00
Steven YungandLuca Casonato 49092ed83a feat: add ctx.renderNotFound() to explicitly render 404 template (#481)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-08-09 19:23:17 +00:00
AbdulazizandLuca Casonato 1dc1f87fc3 refactor: use named status codes from std internally (#417)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-07-30 15:35:31 +00:00
Luca Casonato aab8ceb78b fix: layered middleware not working for index page (#407)
This commit fixes layered middleware not being invoked for the the index
page of the layer.

For example: routes/api/_middleware.ts was not being invoked for /api,
only /api/foobar
2022-07-04 15:13:49 +00:00
Luca Casonato 70d1838cad BREAKING: make render fn an option on start (#260)
This commit removes the `_render.{tj}s{x}?` file in favor of a `render` option on the `start` call in `main.ts`.
2022-06-20 13:40:23 +02:00
Sylvain CauandLuca Casonato afafb7c938 fix: reviving multiple islands on one page (#197)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-06-07 15:02:48 +02:00
Sylvain Cau e8b1e229b3 feat: automatically apply asset caching to img src and srcset (#184) 2022-05-19 19:19:59 +02:00
Luca Casonato c1a9d53b18 fix: improved etag handling in static files (#198) 2022-05-19 19:05:07 +02:00
Luca Casonato cf438a7879 refactor: asset caching via query param (#192)
This updates the asset caching to use a cache busting query string,
rather than a totally separate path. This makes it safer to apply
caching automatically to things like `<img>` tags, as the path does not
change anymore.
2022-05-16 17:39:22 +00:00
Sylvain Cau 2f053816f4 test: Add revive test with puppeteer (#185) 2022-05-14 12:28:41 +02:00
Sylvain CauandLuca Casonato 8d4e77f4ac feat: layered and scoped middleware and context state (#139)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-04-23 22:07:40 +02:00
Sylvain Cau 6cbcc27646 feat: add support for static asset caching (#133) 2022-03-16 16:49:47 +01:00
Leo Kettmeir 67b3eb470e feat: pass ConnInfo to various handler contexts (#121) 2022-03-09 19:16:08 +01:00
Leo Kettmeir adfdec548a refactor: HandlerContext.match to HandlerContext.params (#118) 2022-03-06 20:27:02 +01:00
Luca Casonato fc25d2dfbf refactor: don't inline script if there are no islands (#101) 2022-03-05 01:44:35 +01:00
Luca Casonato 4970663721 refactor: improved reviving of islands (#100) 2022-03-05 01:20:54 +01:00
Luca Casonato 8daa280862 feat: a new "island" based architechture (#97) 2022-03-04 19:49:27 +01:00
Leo Kettmeir d441bf2489 feat: add etag to static files (#95) 2022-03-03 14:18:29 +01:00
Leo KettmeirandLuca Casonato 04a32f3498 feat: _app (#87)
Co-authored-by: Luca Casonato <hello@lcas.dev>
2022-02-18 19:30:24 +01:00
Leo Kettmeir 2ec980ca45 fix: PageProps.params never contains arrays, only strings (#91) 2022-02-15 13:24:18 +01:00
Leo Kettmeir d334b53320 feat: support custom error pages (#86) 2022-02-15 01:17:47 +01:00
Leo KettmeirandLuca Casonato 788a85c431 feat: allow passing additional args to HandlerContext.render (#82)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
2022-02-11 01:25:47 +01:00
Satya Rohith 489da1b49d feat: redirect trailing slash to non-trailing counterpart (#78) 2021-11-29 16:03:19 +01:00
Luca Casonato aa1e1bcdb4 feat: add support for middleware (#74) 2021-11-01 13:35:41 +01:00
Luca Casonato 95289380f3 feat: add auto reload on restart (#70)
This commit adds support for auto reloading open pages when fresh
restarts. This is particularly useful when `deno run` is used with
`--watch`.
2021-10-27 01:19:01 +02:00
Luca Casonato 75afa6daca feat: add static file support (#58)
This commit adds support for serving static files. Static can be placed
into the `/static` directory (as a sibling of the `/pages` directory).
2021-09-25 13:37:46 +02:00
Luca Casonato a25ec7109c feat: support overriding page routes (#57) 2021-09-25 11:27:16 +02:00
Luca Casonato f5b3faf0d8 BREAKING: merge API routes and pages concept (#53)
This commit merges API routes and pages into a single concept. The
pages/api folder is now not special anymore.
2021-09-25 10:49:53 +02:00
Luca Casonato 384daf0e06 feat: add lang to <html> (#47) 2021-08-06 18:36:04 +02:00
Luca Casonato 0777c1c7ba feat: add context information to render function (#46) 2021-08-06 18:08:48 +02:00
Luca Casonato 65d164d073 feat: add config option to disable runtime js (#36)
The config option can be toggled per page:

```js
export const config: PageConfig = { runtimeJS: false };
```
2021-06-13 00:01:59 +02:00
Luca Casonato 18feea9c45 feat: elide __FRSH_PROPS for no data or params (#33)
Minor size improvement.
2021-06-12 00:23:59 +02:00