@11ty/eleventy
Advanced tools
| import module from "node:module"; | ||
| import { resolve, addToModifiedPaths } from "./EsmResolver.js"; | ||
| // module.register (old, deprecated) | ||
| import { MessageChannel } from "node:worker_threads"; | ||
| const { port1, port2 } = new MessageChannel(); | ||
| // ESM Cache Buster | ||
| // - register requires Node 18.19+ https://nodejs.org/docs/latest/api/module.html#moduleregisterspecifier-parenturl-options | ||
| // - registerHooks requires Node 22.15+ | ||
| // Fixes https://github.com/11ty/eleventy/issues/3270 | ||
| // ENV variable for https://github.com/11ty/eleventy/issues/3371 | ||
| if (!process?.env?.ELEVENTY_SKIP_ESM_RESOLVER) { | ||
| if ("registerHooks" in module) { | ||
| module.registerHooks({ | ||
| // sync-only | ||
| resolve, | ||
| }); | ||
| } else if ("register" in module) { | ||
| module.register("./EsmResolver.js", import.meta.url, { | ||
| parentURL: import.meta.url, | ||
| data: { | ||
| port: port2, | ||
| }, | ||
| transferList: [port2], | ||
| }); | ||
| } | ||
| } | ||
| export function addModifiedPath(path, date) { | ||
| if (process?.env?.ELEVENTY_SKIP_ESM_RESOLVER) { | ||
| return; | ||
| } | ||
| if ("registerHooks" in module) { | ||
| addToModifiedPaths(path, date); | ||
| } else if ("register" in module) { | ||
| port1.postMessage({ path: path, newDate: date }); | ||
| } | ||
| } |
+10
-10
| { | ||
| "name": "@11ty/eleventy", | ||
| "version": "3.1.5", | ||
| "version": "3.1.6", | ||
| "description": "A simpler static site generator.", | ||
@@ -116,4 +116,4 @@ "publishConfig": { | ||
| "pretty": "^2.0.0", | ||
| "react": "^19.2.4", | ||
| "react-dom": "^19.2.4", | ||
| "react": "^19.2.7", | ||
| "react-dom": "^19.2.7", | ||
| "sass": "^1.98.0", | ||
@@ -134,3 +134,3 @@ "simple-git-hooks": "^2.13.1", | ||
| "@11ty/lodash-custom": "^4.17.21", | ||
| "@11ty/posthtml-urls": "^1.0.2", | ||
| "@11ty/posthtml-urls": "^1.0.3", | ||
| "@11ty/recursive-copy": "^4.0.4", | ||
@@ -148,5 +148,5 @@ "@sindresorhus/slugify": "^2.2.1", | ||
| "kleur": "^4.1.5", | ||
| "liquidjs": "^10.25.0", | ||
| "liquidjs": "^10.27.0", | ||
| "luxon": "^3.7.2", | ||
| "markdown-it": "^14.1.1", | ||
| "markdown-it": "^14.2.0", | ||
| "minimist": "^1.2.8", | ||
@@ -156,9 +156,9 @@ "moo": "0.5.2", | ||
| "nunjucks": "^3.2.4", | ||
| "picomatch": "^4.0.3", | ||
| "picomatch": "^4.0.4", | ||
| "please-upgrade-node": "^3.2.0", | ||
| "posthtml": "^0.16.7", | ||
| "posthtml-match-helper": "^2.0.3", | ||
| "semver": "^7.7.4", | ||
| "slugify": "^1.6.8", | ||
| "tinyglobby": "^0.2.15" | ||
| "semver": "^7.8.1", | ||
| "slugify": "^1.6.9", | ||
| "tinyglobby": "^0.2.16" | ||
| }, | ||
@@ -165,0 +165,0 @@ "overrides": { |
@@ -8,12 +8,17 @@ import debugUtil from "debug"; | ||
| let lastModifiedPaths = new Map(); | ||
| export async function initialize({ port }) { | ||
| // From `eleventy.importCacheReset` event in Require.js | ||
| port.on("message", ({ path, newDate }) => { | ||
| lastModifiedPaths.set(path, newDate); | ||
| addToModifiedPaths(path, newDate); | ||
| }); | ||
| } | ||
| export function addToModifiedPaths(path, date) { | ||
| lastModifiedPaths.set(path, date); | ||
| } | ||
| // Fixes issue https://github.com/11ty/eleventy/issues/3270 | ||
| // Docs: https://nodejs.org/docs/latest/api/module.html#resolvespecifier-context-nextresolve | ||
| export async function resolve(specifier, context, nextResolve) { | ||
| export function resolve(specifier, context, nextResolve) { | ||
| try { | ||
@@ -28,3 +33,3 @@ // Not a relative import and not a file import | ||
| ) { | ||
| return nextResolve(specifier); | ||
| return nextResolve(specifier, context); | ||
| } | ||
@@ -35,3 +40,3 @@ | ||
| // already is cache busted outside resolver (wider compat, url was changed prior to import, probably in Require.js) | ||
| return nextResolve(specifier); | ||
| return nextResolve(specifier, context); | ||
| } | ||
@@ -46,3 +51,3 @@ | ||
| return nextResolve(fileUrl.toString()); | ||
| return nextResolve(fileUrl.toString(), context); | ||
| } | ||
@@ -53,3 +58,3 @@ } catch (e) { | ||
| return nextResolve(specifier); | ||
| return nextResolve(specifier, context); | ||
| } | ||
@@ -56,0 +61,0 @@ |
+3
-22
@@ -5,4 +5,5 @@ import fs from "node:fs"; | ||
| import module from "node:module"; | ||
| import { MessageChannel } from "node:worker_threads"; | ||
| import { addModifiedPath } from "./EsmResolverPortAdapter.js"; | ||
| import { TemplatePath } from "@11ty/eleventy-utils"; | ||
@@ -15,18 +16,2 @@ | ||
| const { port1, port2 } = new MessageChannel(); | ||
| // ESM Cache Buster is an enhancement that works in Node 18.19+ | ||
| // https://nodejs.org/docs/latest/api/module.html#moduleregisterspecifier-parenturl-options | ||
| // Fixes https://github.com/11ty/eleventy/issues/3270 | ||
| // ENV variable for https://github.com/11ty/eleventy/issues/3371 | ||
| if ("register" in module && !process?.env?.ELEVENTY_SKIP_ESM_RESOLVER) { | ||
| module.register("./EsmResolver.js", import.meta.url, { | ||
| parentURL: import.meta.url, | ||
| data: { | ||
| port: port2, | ||
| }, | ||
| transferList: [port2], | ||
| }); | ||
| } | ||
| // important to clear the require.cache in CJS projects | ||
@@ -82,8 +67,4 @@ const require = module.createRequire(import.meta.url); | ||
| lastModifiedPaths.set(absolutePath, newDate); | ||
| addModifiedPath(absolutePath, newDate); | ||
| // post to EsmResolver worker thread | ||
| if (port1) { | ||
| port1.postMessage({ path: absolutePath, newDate }); | ||
| } | ||
| // ESM Eleventy when using `import()` on a CJS project file still adds to require.cache | ||
@@ -90,0 +71,0 @@ if (absolutePath in (require?.cache || {})) { |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
540231
0.12%116
0.87%16124
0.14%31
3.33%Updated
Updated
Updated
Updated
Updated
Updated
Updated