diff options
author | 2023-08-02 16:27:36 -0700 | |
---|---|---|
committer | 2023-08-02 16:27:36 -0700 | |
commit | c2a77cf7ec9de9eadf938046bdf78e58561c8a6d (patch) | |
tree | 0f90f1b323061455875333c9f40592b303585973 /src/bun.js/bindings/CommonJSModuleRecord.h | |
parent | 7656b4b17e91f15b58eeab8f45b78c416ec6a045 (diff) | |
download | bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.tar.gz bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.tar.zst bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.zip |
Rewrite built-in modules to use CommonJS over ESM (#3814)
* stfdsafsd
sadffdsa
stuff
finish commonjs stuff
asdf
not done but work
not done but work
not done yet but this is how far i am
remove files
lol
update built files
uncomment everything in events lol
export default
stuff
* afdsafsd
* its not perfect but almost done
* okay
* cool
* remove temp file
* finish rebase
* revert settings.json
* a
* ch-ch-ch-ch-changes
* okay
* remove this check in release for now
* sxdcfghnjm,
* lkjhgf
* fmt
* filename can be null
* Update NodeModuleModule.h
* weee
* fmt
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/bindings/CommonJSModuleRecord.h')
-rw-r--r-- | src/bun.js/bindings/CommonJSModuleRecord.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/bun.js/bindings/CommonJSModuleRecord.h b/src/bun.js/bindings/CommonJSModuleRecord.h index 20941f454..e38d2e083 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.h +++ b/src/bun.js/bindings/CommonJSModuleRecord.h @@ -1,3 +1,4 @@ +#pragma once #include "root.h" #include "headers-handwritten.h" @@ -22,7 +23,7 @@ public: static constexpr unsigned StructureFlags = Base::StructureFlags | JSC::OverridesPut; mutable JSC::WriteBarrier<JSC::JSString> m_id; - mutable JSC::WriteBarrier<JSC::JSString> m_filename; + mutable JSC::WriteBarrier<JSC::Unknown> m_filename; mutable JSC::WriteBarrier<JSC::JSString> m_dirname; mutable JSC::WriteBarrier<Unknown> m_paths; mutable JSC::WriteBarrier<JSC::JSSourceCode> sourceCode; @@ -32,18 +33,22 @@ public: ~JSCommonJSModule(); void finishCreation(JSC::VM& vm, - JSC::JSString* id, JSC::JSString* filename, + JSC::JSString* id, JSValue filename, JSC::JSString* dirname, JSC::JSSourceCode* sourceCode); static JSC::Structure* createStructure(JSC::JSGlobalObject* globalObject); - bool evaluate(Zig::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource resolvedSource); + bool evaluate(Zig::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource resolvedSource, bool isBuiltIn); + inline bool evaluate(Zig::GlobalObject* globalObject, const WTF::String& sourceURL, ResolvedSource resolvedSource) + { + return evaluate(globalObject, sourceURL, resolvedSource, false); + } bool evaluate(Zig::GlobalObject* globalObject, const WTF::String& key, const SyntheticSourceProvider::SyntheticSourceGenerator& generator); bool evaluate(Zig::GlobalObject* globalObject, const WTF::String& key, JSSourceCode* sourceCode); static JSCommonJSModule* create(JSC::VM& vm, JSC::Structure* structure, JSC::JSString* id, - JSC::JSString* filename, + JSValue filename, JSC::JSString* dirname, JSC::JSSourceCode* sourceCode); static JSCommonJSModule* create( @@ -96,7 +101,15 @@ JSC::Structure* createCommonJSModuleStructure( std::optional<JSC::SourceCode> createCommonJSModule( Zig::GlobalObject* globalObject, - ResolvedSource source); + ResolvedSource source, + bool isBuiltIn); + +inline std::optional<JSC::SourceCode> createCommonJSModule( + Zig::GlobalObject* globalObject, + ResolvedSource source) +{ + return createCommonJSModule(globalObject, source, false); +} class RequireResolveFunctionPrototype final : public JSC::JSNonFinalObject { public: |