GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — fix: localStorage exception in Node 25+ by tophf · Pull Request #1880 · jantimon/html-webpack-plugin Conversation
Contributor
The problem I'm fixing here is that Node 25+ throws on reading const vmContext = vm.createContext({ ...global, My fix is to use a "meta" clone via Object.getOwnPropertyDescriptors + Object.defineProperties, which copies literally every global and is arguably what f269fc0 intended to achieve. Hopefully there are no secret/sensitive globals used by this plugin.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
I tried this patch locally for Docusaurus, and it didn't work under Node 25.2: I tried adding back the "require" removed, leading to another error: I tried adding back everything you removed and keeping the spread: ...Object.defineProperties({}, Object.getOwnPropertyDescriptors(global)) No idea how to fix it. Need to double check, but I also think it fails on Node 24: Repro?: git clone [email protected]:facebook/docusaurus.git cd docusaurus yarn install yarn start:website |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@slorber Yeah, I think we will need to wait Node.js answer here, we need to pass globals here, technically we can filter as a workaround, but I still think it is a Node.js regression, let's wait an answer from them |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This change in node is spec-compliant, so it's unlikely they'll revert it. I've re-worked the fix to handle one problem that turned out to be caused by The |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## main #1880 +/- ## ======================================= Coverage ? 92.38% ======================================= Files ? 18 Lines ? 749 Branches ? 209 ======================================= Hits ? 692 Misses ? 54 Partials ? 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tophf I still think it is a bug and should be reverted, any way I am fine with these changes too, do can fix eslint problem? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
In this PR? But that code is completely unrelated, so it'd be weird to change it here. What if I just exclude the file from eslint checks altogether and someone will deal with those issues separately? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tophf I mean fix prettier - https://github.com/jantimon/html-webpack-plugin/actions/runs/19344385065/job/55400556942?pr=1880 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Yeah, I saw that. Thing is, it doesn't say what's wrong. If the project is using prettier I would expect it to be applied automatically without me doing anything. Should I run prettier explicitly myself? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Okay, I found and ran |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@tophf Thanks for this PR |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…ty (#1889) Templates whose child compilation output is a CommonJS module (for example Rspack's HtmlWebpackPlugin child compilation, which wraps the evaluated template in `module.exports = ...`) were failing at evaluation time with `ReferenceError: module is not defined` under Node.js 25+. In 5.6.5 the VM context was switched away from a `...global` spread because spreading `global` on Node 25 throws once `localStorage` is touched without `--localstorage-file`. The replacement clone only exposes the standard globals plus `require`, so any CommonJS-wrapped source that assigned to `module.exports` hit the ReferenceError. Provide a throwaway `module = { exports: {} }` pair (plus `exports` aliasing it) in the sandbox so CommonJS-style outputs can evaluate without assuming the host Node version populates them. Refs: PR #1880, meta/docusaurus#11545
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.