![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ESM hot-reloading for Node.js
hot ./server.js
Install hot-esm by running
yarn add hot-esm
hot-esm provides a loader that clears the module cache for files that are edited and the files that import them. This allows you to re-import your application and get updated code.
node --experimental-loader hot-esm ./server.js
# Or use this shorthand:
hot ./server.js
import * as http from 'http'
const server = http.createServer(async (request, response) => {
const app = await import('./app.js')
app.default(request, response)
})
server.listen(8080)
You'll have to find an appropriate place in your application to place an
import()
expression. This expression needs to run often enough to not miss
updates.
State that is local to a file will be lost when that file is re-imported. To
share state between the old and new copies of a file, put that state in
global
.
Also, any ongoing side-effects will need to be cleaned up when a new version of
a file is imported. Otherwise, for example, multiple of the same event listener
will be running. Again, this can be managed using global
state.
Note that this only works with ECMAScript Modules and not with CommonJS modules.
Also, edits to files in node_modules
, even if they are ECMAScript Modules are
ignored as attaching filesystem watchers to so many directories is too
expensive.
FAQs
ESM hot-reloading for Node.js
The npm package hot-esm receives a total of 55 weekly downloads. As such, hot-esm popularity was classified as not popular.
We found that hot-esm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.