implement require.extensions attempt 2 - #18686
Merged
Merged
Conversation
Collaborator
|
Updated 2:04 PM PT - Apr 1st, 2025
✅ @paperclover, your commit 7c5b39729493bb93462606411d387e0c2fd1841a passed in 🧪 try this PR locally: bunx bun-pr 18686 |
paperclover
commented
Apr 1, 2025
|
|
||
| // When adding to this list, please comment why the package is using extensions incorrectly. | ||
|
|
||
| WTF::String url = frame.sourceURL(vm); |
paperclover
commented
Apr 1, 2025
| { | ||
| if (propertyName.isSymbol()) return; | ||
| auto* name = propertyName.publicName(); | ||
| if (!name->startsWith("."_s)) return; |
paperclover
commented
Apr 1, 2025
| auto& vm = globalObject->vm(); | ||
| auto scope = DECLARE_THROW_SCOPE(vm); | ||
| if (!compileFunction || !compileFunction.isCallable()) { | ||
| throwTypeError(globalObject, scope, makeString("overridden module._compile is not a function (called from overridden Module._extensions)"_s)); |
paperclover
commented
Apr 1, 2025
| if (JSValue compileFunction = this->m_overriddenCompile.get()) { | ||
| auto& vm = globalObject->vm(); | ||
| auto scope = DECLARE_THROW_SCOPE(vm); | ||
| if (!compileFunction || !compileFunction.isCallable()) { |
paperclover
commented
Apr 1, 2025
| throwTypeError(globalObject, scope, makeString("overridden module._compile is not a function (called from overridden Module._extensions)"_s)); | ||
| return; | ||
| } | ||
| WTF::String sourceString = source.source_code.toWTFString(BunString::ZeroCopy); |
paperclover
commented
Apr 1, 2025
| Bun::JSCommonJSExtensions* extensions = globalObject->lazyRequireExtensionsObject(); | ||
| JSValue extension = extensions->m_registeredFunctions[extensionIndex].get(); | ||
|
|
||
| if (!extension || !extension.isCallable()) { |
paperclover
commented
Apr 1, 2025
| visitor.append(thisObject->m_currentNapiHandleScopeImpl); | ||
|
|
||
| thisObject->m_moduleResolveFilenameFunction.visit(visitor); | ||
| thisObject->m_modulePrototypeUnderscoreCompileFunction.visit(visitor); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #18570