Imported variable works but is not defined when accessed in debugger (within same scope)

為{幸葍}努か 提交于 2021-01-26 03:37:47

问题


I am using webpack + es6 to build my files. I exported modules in a Math.js, then imported in Main.js.

In the latter, I used the module to compute, then set a stop in the debugger. The former worked but it was not defined when I tried to use it in the console.

The scope is the same - why would the module not be defined in the console?

// Math.js
export function sum(x, y) {
  return x + y;
}
export var pi = 3.141593;

// Main.js
import * as mathTest from "./Math.js";
console.log("2π = " + mathTest.sum(mathTest.pi, mathTest.pi));
debugger

// Output
// The statement from the file writes properly but the debugger fails (but <this> is the same)

来源:https://stackoverflow.com/questions/42016317/imported-variable-works-but-is-not-defined-when-accessed-in-debugger-within-sam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!