| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 742a456 commit b719b77
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ lib/internal/v8_prof_polyfill.js | |||
| 2 | 2 | lib/punycode.js | |
| 3 | 3 | test/addons/??_* | |
| 4 | 4 | test/fixtures | |
| 5 | + test/message/esm_display_syntax_error.mjs | ||
| 5 | 6 | tools/eslint | |
| 6 | 7 | tools/icu | |
| 7 | 8 | tools/remark-* | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | const NativeModule = require('native_module'); | |
| 25 | 25 | const util = require('util'); | |
| 26 | + const { decorateErrorStack } = require('internal/util'); | ||
| 26 | 27 | const internalModule = require('internal/module'); | |
| 27 | 28 | const { getURLFromFilePath } = require('internal/url'); | |
| 28 | 29 | const vm = require('vm'); | |
@@ -471,6 +472,7 @@ Module._load = function(request, parent, isMain) { | |||
| 471 | 472 | await ESMLoader.import(getURLFromFilePath(request).pathname); | |
| 472 | 473 | })() | |
| 473 | 474 | .catch((e) => { | |
| 475 | + decorateErrorStack(e); | ||
| 474 | 476 | console.error(e); | |
| 475 | 477 | process.exit(1); | |
| 476 | 478 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,9 +103,17 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) { | |||
| 103 | 103 | False(isolate), // is opaque (?) | |
| 104 | 104 | False(isolate), // is WASM | |
| 105 | 105 | True(isolate)); // is ES6 module | |
| 106 | + TryCatch try_catch(isolate); | ||
| 106 | 107 | ScriptCompiler::Source source(source_text, origin); | |
| 107 | - if (!ScriptCompiler::CompileModule(isolate, &source).ToLocal(&module)) | ||
| 108 | + if (!ScriptCompiler::CompileModule(isolate, &source).ToLocal(&module)) { | ||
| 109 | + CHECK(try_catch.HasCaught()); | ||
| 110 | + CHECK(!try_catch.Message().IsEmpty()); | ||
| 111 | + CHECK(!try_catch.Exception().IsEmpty()); | ||
| 112 | + AppendExceptionLine(env, try_catch.Exception(), try_catch.Message(), | ||
| 113 | + ErrorHandlingMode::MODULE_ERROR); | ||
| 114 | + try_catch.ReThrow(); | ||
| 108 | 115 | return; | |
| 116 | + } | ||
| 109 | 117 | } | |
| 110 | 118 | ||
| 111 | 119 | Local<Object> that = args.This(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -262,7 +262,7 @@ constexpr size_t arraysize(const T(&)[N]) { return N; } | |||
| 262 | 262 | ||
| 263 | 263 | bool IsExceptionDecorated(Environment* env, v8::Local<v8::Value> er); | |
| 264 | 264 | ||
| 265 | - enum ErrorHandlingMode { FATAL_ERROR, CONTEXTIFY_ERROR }; | ||
| 265 | + enum ErrorHandlingMode { CONTEXTIFY_ERROR, FATAL_ERROR, MODULE_ERROR }; | ||
| 266 | 266 | void AppendExceptionLine(Environment* env, | |
| 267 | 267 | v8::Local<v8::Value> er, | |
| 268 | 268 | v8::Local<v8::Message> message, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + await async () => 0; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + // Flags: --experimental-modules | ||
| 2 | + 'use strict'; | ||
| 3 | + await async () => 0; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + (node:*) ExperimentalWarning: The ESM module loader is experimental. | ||
| 2 | + file:///*/test/message/esm_display_syntax_error.mjs:3 | ||
| 3 | + await async () => 0; | ||
| 4 | + ^^^^^ | ||
| 5 | + SyntaxError: Unexpected reserved word | ||
| 6 | + at loaders.set (internal/loader/ModuleRequest.js:*:*) | ||
| 7 | + at <anonymous> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + // Flags: --experimental-modules | ||
| 2 | + import '../common'; | ||
| 3 | + import '../fixtures/es-module-loaders/syntax-error'; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + (node:*) ExperimentalWarning: The ESM module loader is experimental. | ||
| 2 | + file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2 | ||
| 3 | + await async () => 0; | ||
| 4 | + ^^^^^ | ||
| 5 | + SyntaxError: Unexpected reserved word | ||
| 6 | + at loaders.set (internal/loader/ModuleRequest.js:*:*) | ||
| 7 | + at <anonymous> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -114,18 +114,18 @@ def __init__(self, context, root): | |||
| 114 | 114 | ||
| 115 | 115 | def Ls(self, path): | |
| 116 | 116 | if isdir(path): | |
| 117 | - return [f[:-3] for f in os.listdir(path) if f.endswith('.js')] | ||
| 117 | + return [f for f in os.listdir(path) | ||
| 118 | + if f.endswith('.js') or f.endswith('.mjs')] | ||
| 118 | 119 | else: | |
| 119 | - return [] | ||
| 120 | + return [] | ||
| 120 | 121 | ||
| 121 | 122 | def ListTests(self, current_path, path, arch, mode): | |
| 122 | 123 | all_tests = [current_path + [t] for t in self.Ls(self.root)] | |
| 123 | 124 | result = [] | |
| 124 | 125 | for test in all_tests: | |
| 125 | 126 | if self.Contains(path, test): | |
| 126 | - file_prefix = join(self.root, reduce(join, test[1:], "")) | ||
| 127 | - file_path = file_prefix + ".js" | ||
| 128 | - output_path = file_prefix + ".out" | ||
| 127 | + file_path = join(self.root, reduce(join, test[1:], '')) | ||
| 128 | + output_path = file_path[:file_path.rfind('.')] + '.out' | ||
| 129 | 129 | if not exists(output_path): | |
| 130 | 130 | raise Exception("Could not find %s" % output_path) | |
| 131 | 131 | result.append(MessageTestCase(test, file_path, output_path, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments