-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module: use cjsCache over esm injection #34605
Conversation
//cc @nodejs/modules-active-members |
You could also do a weakmap from the |
That's a great way to work around the GC issue! I've pushed that up in the latest commit, which should avoid the problem entirely, thanks. |
Co-authored-by: Antoine du Hamel <[email protected]>
I'd like to merge this tomorrow, it would be great to get a few more approvals if possible. |
PR-URL: #34605 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Landed in 0f4b4ea |
PR-URL: #34605 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: #34605 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: nodejs#34605 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Rich Trott <[email protected]>
PR-URL: #34605 Backport-PR-URL: #35385 Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Rich Trott <[email protected]>
This puts it together with the cjsParseCache and reduces the circular dependency on the singleton loader, which is the only place where this cache is stored. Drive-by: remove always-false module status check because there's no longer a local module variable after nodejs#34605 which is now invalid leftover code at this point and only doesn't throw because we happen to have a top-level variable called module.
This puts it together with the cjsParseCache and reduces the circular dependency on the singleton loader, which is the only place where this cache is stored. Drive-by: remove always-false module status check because there's no longer a local module variable after nodejs#34605 which is now invalid leftover code at this point and only doesn't throw because we happen to have a top-level variable called module.
This puts it together with the cjsParseCache and reduces the circular dependency on the singleton loader, which is the only place where this cache is stored. Drive-by: remove always-false module status check because there's no longer a local module variable after nodejs#34605 which is now invalid leftover code at this point and only doesn't throw because we happen to have a top-level variable called module.
This puts it together with the cjsParseCache and reduces the circular dependency on the singleton loader, which is the only place where this cache is stored. Drive-by: remove always-false module status check because there's no longer a local module variable after #34605 which is now invalid leftover code at this point and only doesn't throw because we happen to have a top-level variable called module. PR-URL: #51157 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
This puts it together with the cjsParseCache and reduces the circular dependency on the singleton loader, which is the only place where this cache is stored. Drive-by: remove always-false module status check because there's no longer a local module variable after #34605 which is now invalid leftover code at this point and only doesn't throw because we happen to have a top-level variable called module. PR-URL: #51157 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
This puts it together with the cjsParseCache and reduces the circular dependency on the singleton loader, which is the only place where this cache is stored. Drive-by: remove always-false module status check because there's no longer a local module variable after #34605 which is now invalid leftover code at this point and only doesn't throw because we happen to have a top-level variable called module. PR-URL: #51157 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
This is the replacement for #34467 as an alternative mechanism to ensure that named exports loaders (such as https://github.com/guybedford/cjs-named-exports-loader) are fully possible without issues. Without this PR such loaders cannot work for CJS loaded via
require()
before it is loaded viaimport()
.As discussed, this PR retains the existing CJS snapshotting behaviour so that the
module.exports
value is captured for all CommonJS modules and stored in theESMLoader.cjsCache
map. This map is changed to be a weakmap keyed by the module object so that deletions inModule._cache
allow this map to be GC'd.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes