closes https://github.com/denoland/fresh/issues/1338
This is more complex than first expected. It turns out the head of main
no longer has this error, because we started swallowing errors in
https://github.com/denoland/fresh/pull/1327. I'm not sure this is the
right implementation. It seems like we should explicitly check for the
`islands` folder instead of ignoring errors. But the obvious approach
(https://deno.land/std@0.192.0/fs/mod.ts?s=exists) is apparently
forbidden, due to some sort of nonsense with race conditions. Well, not
being able to find `islands` because it doesn't exist at all is
definitely different than it being buried in a source directory, so
we'll need to sort this out at some point.
I suppose that's now some technical debt to deal with, and not related
to this issue. The latest "error" when running `update` and using a
source directory is the following:
```
deno run -A -r file:///Users/reed/code/fresh/update.ts .
The manifest has been generated for 0 routes and 0 islands.
```
i.e. it just doesn't do anything. (To be fair, it does generate a
`fresh.gen.ts` in the incorrect location, so I suppose it does
_something_.)
But of course this isn't what we want. So we'll hunt for a source
directory, as defined by the precense of `main.ts`.
The fix for this is relatively straightforward. The test implements the
user's actions, i.e. init a project, move things, and then try to
update.
This can be useful when deploying to other providers.
Also more convenient for projects with multiple developers with port
preferences
---------
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
One can now inline the `imports` and `scopes` from the import map directly into deno.json.
For new projects, `import_map.json` is not generated anymore.
Co-authored-by: Luca Casonato <hello@lcas.dev>
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


---------
Co-authored-by: Luca Casonato <hello@lcas.dev>