Releases: Julien-R44/hot-hook
Throw if boundary file not dynamicaly imported
0.3.0
Minor Changes
-
64b51ed: Now Hot-Hook will throw an error when a file marked as "boundary" is not dynamically imported.
In AdonisJS, we had a few users complaining about having to restart the server to see the changes applied. Generally, the cause of this was a controller file not dynamically imported:
import PostsController from './app/controllers/posts_controller.js' router.get('/posts', [PostsController, 'index'])
Before this new version, this code did not throw an error, but it did not work either. You had to reload the server to see the changes. Now Hot-Hook will throw an error for this kind of case.
Suggesting to reread the readme if you want to understand why a dynamic import is necessary for Hot-Hook to work correctly.
Full Changelog: https://github.com/Julien-R44/hot-hook/compare/@hot-hook/[email protected]@0.3.0
Ignore vite.config.ts-timestamp* files
0.2.6
Patch Changes
- f81b32f: Vite has a bug that causes a
vite.config.js.timestamp-*
file to be created and persisted under certain conditions. When Hot-Hook is used with Vite, this bug can sometimes cause the server to restart indefinitely. Consequently, this commit adds these files by default to Hot-Hook'signore
config.
Support Node.js <= 20.9
Changes
89c2a60: Add support for Node.js 20. We removed the direct usage of importAttributes
that was only introduced in Node.js 20.9. Hot-hook should now works fine with Node.js 20.0.0 and above.
What's Changed
- refactor: support Node.js 20.x.x by @Julien-R44 in #8
Full Changelog: https://github.com/Julien-R44/hot-hook/compare/[email protected]@0.2.5
Restart files and bugfixes
0.2.4
Patch Changes
-
7d4a8bc: Fix: should use default values when configured through --import=hot-hook/register
-
07cadde: The HMR was a bit broken in some situations due to a change introduced by 117f9c1. This has been fixed and tests have been added to prevent it happening again.
-
0ade4eb: One of the problems we encountered was that Hot Hook didn't send a full reload message when a
.env
file was changed, for example. This is because.env
files are not javascript modules, and so are not processed by Hot Hook nor added to the dependency graph.As a result, this commit introduces a
restart
property in the config that allows you to specify which files should trigger a full reload. By default,restart
will be equal to['.env']
.// package.json { "hotHook": { "restart": [".env", "./config/foo.yaml"] } }
Bug fix
0.2.2
Patch Changes
-
117f9c1: Bugfix : We should not invalidate non-reloadable files when a reloadable file is changed. That means, we gonna keep fetching the same file from the cache and not increase the version query param. This was not the case until this commit and caused theses issues :
What's Changed
- Replace all references of reloading with replacement in hmr by @thetutlage in #7
New Contributors
- @thetutlage made their first contribution in #7
Full Changelog: https://github.com/Julien-R44/hot-hook/compare/[email protected]@0.2.2
[email protected]
What's Changed
- fix: windows paths handling by @Julien-R44 in #6
Full Changelog: https://github.com/Julien-R44/hot-hook/compare/[email protected]@0.2.1
Configuration Breaking Change
Breaking Changes
-
c0defa6: From this commit, if you are using
--import=hot-hook/register
for using hot-hook, thepackage.json
's directory will be used for resolving glob patterns in theboundaries
config.That means, if you had a
package.json
with the following content, and a root entrypoint in./src/start.ts
, glob patterns were resolved from./src/start.ts
file :{ "name": "my-package", "version": "1.0.0", "hot-hook": { "boundaries": ["./controllers/**/*"] } }
This configuration was matching all files in the
./src/controllers
directory.To achieve the same result, you should now use the following configuration:
{ "name": "my-package", "version": "1.0.0", "hot-hook": { "boundaries": ["./src/controllers/**/*"] } }
Full Changelog: https://github.com/Julien-R44/hot-hook/compare/[email protected]@0.2.0
Bugfix
0.1.10
Patch Changes
- c26292d: Don't throw when a dependent file node is missing. This can happen when a file has been deleted
Full Changelog: https://github.com/Julien-R44/hot-hook/compare/[email protected]@0.1.9
[email protected]
--import
usage
See fa6ed2e : add a new way of configuring hot-hook. This allows you to configure hot-hook without having to modify your codebase.
We introduce a new hot-hook/register
entrypoint that can be used with Node.JS's --import
flag. By using this method, the Hot Hook hook will be loaded at application startup without you needing to use hot.init
in your codebase. It can be used as follows:
node --import=hot-hook/register ./src/index.js
Be careful if you also use a loader to transpile to TS (ts-node
or tsx
), hot-hook must be placed in the second position, after the TS loader :
node --import=tsx --import=hot-hook/register ./src/index.ts
To configure boundaries and other files, you'll need to use your application's package.json
file, in the hot-hook
key. For example:
// package.json
{
"hot-hook": {
"boundaries": ["./src/controllers/**/*.tsx"],
},
}
@hot-hook/[email protected]
Dump Viewer
The dump viewer is a small frontend app built with Vis.js
that lets you view Hot Hook's dependency graph. This lets you quickly see which files are hot reloadable and which aren't, and why.
To use it, you can add it to your application as follows:
fastify.get('/dump-viewer', async (request, reply) => {
const { dumpViewer } = await import('@hot-hook/dump-viewer')
reply.header('Content-Type', 'text/html; charset=utf-8')
return dumpViewer()
})
then access your dev server at /dump-viewer
.