You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importurlfrom'url';importpathfrom'path';importprocessfrom'process';importModulefrom'module';constbuiltins=Module.builtinModules;constJS_EXTENSIONS=newSet(['.js','.mjs']);exportfunctionresolve(specifier,parentModuleURL='file://',defaultResolve){console.log(specifier,parentModuleURL);if(builtins.includes(specifier)){return{url: specifier,format: 'builtin'};}if(/^\.{0,2}[/]/.test(specifier)!==true&&!specifier.startsWith('file:')){// For node_modules support:returndefaultResolve(specifier,parentModuleURL);// throw new Error(// `imports must begin with '/', './', or '../'; '${specifier}' does not`);}constresolved=newurl.URL(specifier,parentModuleURL);constext=path.extname(resolved.pathname);letresult=resolved.href;if(!JS_EXTENSIONS.has(ext)){// throw new Error(// `Cannot load file with non-JavaScript file extension ${ext}.`);result=resolved.href+'.js';}return{url: result,format: 'esm'};}
下面是我的理解:
调试 ES6 modules,现在的方案是先编译成 es5,加上 sourcemap 进行调试。
如果要直接调试,可以使用 babel-node,但是在调试上下文中变量有问题。
使用 nodejs 原生 es6 modules 调试理论上没有问题。
但是 Chrome 中调试有可能不能在 Filesystem 中看到文件,不方便打断点(需要添加 debugger 语句)
可以在 vscode 中调试:launch.json 中添加
runtimeArgs
The text was updated successfully, but these errors were encountered: