Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hot-esm

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hot-esm - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

.github/dependabot.yml

12

hot.test.js

@@ -78,4 +78,3 @@ import process from 'process'

`Changed ${directory.path}/app.js`,
`Invalidating ${directory.path}/app.js`,
`Invalidating ${directory.path}/server.js`,
`Invalidating ${directory.path}/app.js, ${directory.path}/server.js`,
])

@@ -87,3 +86,3 @@

t.deepEqual(readLogs(server).slice(7), [`Importing ${directory.path}/app.js`])
t.deepEqual(readLogs(server).slice(6), [`Importing ${directory.path}/app.js`])

@@ -108,6 +107,5 @@ await directory.writeFile(

t.deepEqual(readLogs(server).slice(8), [
t.deepEqual(readLogs(server).slice(7), [
`Changed ${directory.path}/app.js`,
`Invalidating ${directory.path}/app.js`,
`Invalidating ${directory.path}/server.js`,
`Invalidating ${directory.path}/app.js, ${directory.path}/server.js`,
])

@@ -119,3 +117,3 @@

t.deepEqual(readLogs(server).slice(11), [
t.deepEqual(readLogs(server).slice(9), [
`Importing ${directory.path}/app.js`,

@@ -122,0 +120,0 @@ `Watching ${directory.path}/text.js`,

@@ -7,4 +7,6 @@ import process from 'process'

import makeLogger from 'debug'
import DependencyTree from './dependency-tree.js'
const log = makeLogger('hot-esm')
const dependencyTree = new DependencyTree()

@@ -29,47 +31,2 @@ const includedPackages = process.env.HOT_INCLUDE_PACKAGES

const versions = new Map()
function trackVersion(filePath) {
if (!versions.has(filePath)) {
log('Watching %s', filePath)
watcher.add(filePath)
versions.set(filePath, 1)
}
}
function untrackVersion(filePath) {
versions.delete(filePath)
}
function getVersion(filePath) {
return versions.get(filePath)
}
function incrementVersion(filePath) {
if (versions.has(filePath)) {
log('Invalidating %s', filePath)
versions.set(filePath, versions.get(filePath) + 1)
}
}
const dependents = new Map()
function getDependents(filePath) {
if (dependents.has(filePath)) {
return dependents.get(filePath)
}
return new Set()
}
function addDependent(filePath, dependentFilePath) {
if (dependents.has(filePath)) {
dependents.get(filePath).add(dependentFilePath)
} else {
dependents.set(filePath, new Set([dependentFilePath]))
}
}
function untrackDependents(filePath) {
dependents.delete(filePath)
}
const watcher = chokidar

@@ -83,13 +40,10 @@ .watch([])

const queue = [realFilePath]
while (queue.length > 0) {
const filePath = queue.pop()
incrementVersion(filePath)
queue.push(...getDependents(filePath))
}
const invalidatedFiles =
dependencyTree.invalidateFileAndDependents(realFilePath)
log('Invalidating %s', Array.from(invalidatedFiles).join(', '))
})
.on('unlink', (relativeFilePath) => {
const filePath = path.resolve(relativeFilePath)
untrackVersion(filePath)
untrackDependents(filePath)
log('Deleted %s', filePath)
dependencyTree.remove(filePath)
})

@@ -111,5 +65,11 @@

trackVersion(child.pathname)
const childFilePath = child.pathname
if (!dependencyTree.has(childFilePath)) {
log('Watching %s', childFilePath)
dependencyTree.add(childFilePath)
watcher.add(childFilePath)
}
if (parent) {
addDependent(child.pathname, parent.pathname)
dependencyTree.addDependent(childFilePath, parent.pathname)
}

@@ -119,3 +79,3 @@

...result,
url: `${child.href}?version=${getVersion(child.pathname)}`,
url: `${child.href}?version=${dependencyTree.getVersion(childFilePath)}`,
}

@@ -122,0 +82,0 @@ }

{
"name": "hot-esm",
"version": "1.4.0",
"version": "1.4.1",
"description": "ESM hot-reloading for Node.js",

@@ -33,3 +33,3 @@ "keywords": [

"semantic-release": "^19.0.2",
"xo": "^0.47.0"
"xo": "^0.48.0"
},

@@ -36,0 +36,0 @@ "resolutions": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc