我很好奇嵌套函数的node.js模式如何与v8的垃圾收集器一起工作.这是一个简单的例子
readfile("blah", function(str) {
var val = getvaluefromstr(str);
function restofprogram(val2) { ... } (val)
})
Run Code Online (Sandbox Code Playgroud)
如果restofprogram长时间运行,这是不是意味着str永远不会被垃圾收集?我的理解是,对于节点,你最终会使用嵌套函数.如果在外部声明restofprogram,这是否会收集垃圾,因此str不在范围内?这是推荐的做法吗?
编辑我不打算让问题复杂化.那只是粗心大意,所以我修改了它.
在Webpack中使用@babel 7.0.0-beta.36。当我包括无论是填充工具或运行时库,我碰到一个编译错误。
请参阅附件https://gist.github.com/pathsny/af270f61390380c8d948973ed9e09787 我的.babelrc,package.json,package-lock.json和webpack.config.js
在上述要点中,对文件“违规文件”中的async函数取消注释行或对webpack.config.js中的条目@ babel / polyfill进行注释,然后编译代码将导致错误
ERROR in ./node_modules/@babel/polyfill/node_modules/regenerator-runtime/runtime.js
Module not found: Error: Can't resolve 'imports' in '/project_path/node_modules/@babel/polyfill/node_modules/regenerator-runtime'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
You need to specify 'imports-loader' instead of 'imports',
see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed
webpack: Failed to compile.
我将不胜感激,以帮助您找出我在这里缺少的内容。