问题
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