summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/env.h1
-rw-r--r--src/node_file.cc3
-rw-r--r--test/es-module/test-esm-default-type.mjs8
-rw-r--r--test/fixtures/es-modules/package-type-module/nested-default-type/module.js1
-rw-r--r--test/fixtures/es-modules/package-type-module/nested-default-type/package.json1
-rw-r--r--test/parallel/test-module-binding.js5
6 files changed, 14 insertions, 5 deletions
diff --git a/src/env.h b/src/env.h
index 3e3aacc8f7..6113d3adbf 100644
--- a/src/env.h
+++ b/src/env.h
@@ -217,6 +217,7 @@ constexpr size_t kFsStatsBufferLength =
V(done_string, "done") \
V(duration_string, "duration") \
V(emit_warning_string, "emitWarning") \
+ V(empty_object_string, "{}") \
V(encoding_string, "encoding") \
V(entries_string, "entries") \
V(entry_type_string, "entryType") \
diff --git a/src/node_file.cc b/src/node_file.cc
index 8b6a90989f..48b382986c 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -18,7 +18,6 @@
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
#include "node_file.h"
#include "aliased_buffer.h"
#include "memory_tracker-inl.h"
@@ -787,7 +786,7 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo<Value>& args) {
size == SearchString(&chars[start], size, "\"main\"") &&
size == SearchString(&chars[start], size, "\"exports\"") &&
size == SearchString(&chars[start], size, "\"type\""))) {
- return;
+ args.GetReturnValue().Set(env->empty_object_string());
} else {
Local<String> chars_string =
String::NewFromUtf8(isolate,
diff --git a/test/es-module/test-esm-default-type.mjs b/test/es-module/test-esm-default-type.mjs
new file mode 100644
index 0000000000..7e63dab349
--- /dev/null
+++ b/test/es-module/test-esm-default-type.mjs
@@ -0,0 +1,8 @@
+// Flags: --experimental-modules
+import '../common/index.mjs';
+import { strictEqual } from 'assert';
+
+import asdf from
+ '../fixtures/es-modules/package-type-module/nested-default-type/module.js';
+
+strictEqual(asdf, 'asdf');
diff --git a/test/fixtures/es-modules/package-type-module/nested-default-type/module.js b/test/fixtures/es-modules/package-type-module/nested-default-type/module.js
new file mode 100644
index 0000000000..683f2d8ba6
--- /dev/null
+++ b/test/fixtures/es-modules/package-type-module/nested-default-type/module.js
@@ -0,0 +1 @@
+module.exports = 'asdf';
diff --git a/test/fixtures/es-modules/package-type-module/nested-default-type/package.json b/test/fixtures/es-modules/package-type-module/nested-default-type/package.json
new file mode 100644
index 0000000000..0967ef424b
--- /dev/null
+++ b/test/fixtures/es-modules/package-type-module/nested-default-type/package.json
@@ -0,0 +1 @@
+{}
diff --git a/test/parallel/test-module-binding.js b/test/parallel/test-module-binding.js
index 07c4965f22..d0e122605d 100644
--- a/test/parallel/test-module-binding.js
+++ b/test/parallel/test-module-binding.js
@@ -8,9 +8,8 @@ const { readFileSync } = require('fs');
const { strictEqual } = require('assert');
strictEqual(internalModuleReadJSON('nosuchfile'), undefined);
-strictEqual(internalModuleReadJSON(fixtures.path('empty.txt')), undefined);
-strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt')),
- undefined);
+strictEqual(internalModuleReadJSON(fixtures.path('empty.txt')), '{}');
+strictEqual(internalModuleReadJSON(fixtures.path('empty-with-bom.txt')), '{}');
{
const filename = fixtures.path('require-bin/package.json');
strictEqual(internalModuleReadJSON(filename), readFileSync(filename, 'utf8'));