Skip to content

Commit

Permalink
Add Module
Browse files Browse the repository at this point in the history
  • Loading branch information
paperdave committed Aug 9, 2023
1 parent 4544070 commit f3c975e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/bun.js/modules/NodeModuleModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,13 @@ DEFINE_NATIVE_MODULE(NodeModule) {
exportNames.append(name);
exportValues.append(value);
};
exportNames.reserveCapacity(14);
exportValues.ensureCapacity(14);
exportNames.reserveCapacity(15);
exportValues.ensureCapacity(15);
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(defaultObject);

put(Identifier::fromString(vm, "Module"_s), defaultObject);

putNativeFn(Identifier::fromString(vm, "createRequire"_s),
jsFunctionNodeModuleCreateRequire);
putNativeFn(Identifier::fromString(vm, "paths"_s),
Expand Down
4 changes: 4 additions & 0 deletions test/js/node/module/node-module-module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ test("Module exists", () => {
expect(Module).toBeDefined();
});

test("module.Module exists", () => {
expect(Module.Module === Module).toBeTrue();
});

test("_nodeModulePaths() works", () => {
expect(() => {
_nodeModulePaths();
Expand Down

0 comments on commit f3c975e

Please sign in to comment.