html5 堆栈不足,javascript

我正在使用gulp-inject插件将html文件注入到另一个html fiile中。 我已经使用以下任务来做到这一点。

gulp.task("inject:component:html", () => {

let paths = getSelectedComponentHtml();

var sources = gulp.src([path.join(CONFIG.dest, CONFIG.downloads, downloadDir, CONFIG.componentDownloadPath + 'js/ui-pattern.js'), path.join(CONFIG.dest, CONFIG.downloads, downloadDir, 'uxpl/components/ui-pattern.css')]);

var source = '';

var visitedDirectories = [];

if (takeHeaderHtml) {

// isHeader = true;

source = gulp.src(CONFIG.site + "/components/header-navigation.html");

} else {

// isHeader = false;

source = gulp.src(CONFIG.componentsSrc + '/index.html');

}

// var sources = gulp.src([path.join(CONFIG.dest, CONFIG.downloads, downloadDir, CONFIG.componentDownloadPath + 'js/ui-pattern.js'), path.join(CONFIG.dest, CONFIG.downloads, downloadDir, 'uxpl/components/ui-pattern.css')]);

var stream = source

.pipe(inject(gulp.src(paths), {

starttag: '',

transform: function (filePath, file, i, length) {

let contents = '';

try {

console.log('In transform method');

var url = filePath;

var fileName = url.substring(url.lastIndexOf('/') + 1);

console.log("arguments====" + arguments);

var snippet = file.contents.toString('utf8');

console.log("snippet====");

contents = snippet;

console.log("contents====");

// return file contents as string

let snipp = snippet.match(/\

if (snipp && snipp.length) {

let snipp = snippet.substring(snippet.indexOf(''));

contents = fs.readFileSync(snipp.trim(), 'utf8');

console.log("contents reading====");

}

let folderName = filePath.replace(fileName, '');

console.log("folderName replace====");

if (visitedDirectories.length == 0) {

contents = '

\n' + contents + '\n';

console.log("In iff====");

visitedDirectories.push(folderName);

} else if (visitedDirectories.indexOf(folderName) === -1) {

contents = '

\n
\n' + contents + '\n';

console.log("In else====");

visitedDirectories.push(folderName);

}

if (i == length - 1) {

contents = contents + '

\n

}

console.log("just before return ======");

}catch(e){

console.log("in catch block===>>"+e);

}

return contents.toString('utf8');

}

}))

.pipe($.replace('/vendor', '../../../../vendor'))

.pipe($.replace('/assets', '../../../../assets'))

.pipe(gulp.dest(path.join(CONFIG.dest, CONFIG.downloads, downloadDir, CONFIG.componentDownloadPath)));

console.log("just before return stream ======");

return stream;

});

一切正常,但无法完成trasnform方法。

直到** console.log("just before return stream ======"); ** ** console.log("just before return stream ======"); **此日志一切正常,但在此之后我得到以下错误。

0: ExitFrame [pc: 0000002ADA6DC5C1]

Security context: 0x03557309e6e1

1: exec [0000035573089231](this=0x020817aaadb9 >>,0x02fdbcf49f69 )

2: inject(aka inject) [000003A1B6355319] [C:\Users\scheripa\Documents\2019\UXPL_Master\origin\master\node_modules\gulp-inject\src\inject\index.js:190] [bytecode=000000EBD2958729 offset=19](this=0x00

ac6b3826f...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

1: 00007FF68F630EFA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4810

2: 00007FF68F60A296 node::MakeCallback+4518

3: 00007FF68F60AC80 node_module_register+2160

4: 00007FF68F8A09BE v8::internal::FatalProcessOutOfMemory+846

5: 00007FF68F8A08EF v8::internal::FatalProcessOutOfMemory+639

6: 00007FF68FDDE954 v8::internal::Heap::MaxHeapGrowingFactor+11476

7: 00007FF68FDDC6E8 v8::internal::Heap::MaxHeapGrowingFactor+2664

8: 00007FF68F97F0CB v8::internal::Factory::AllocateRawWithImmortalMap+59

9: 00007FF68F981BCD v8::internal::Factory::NewRawTwoByteString+77

10: 00007FF68FB95C58 v8::internal::Smi::SmiPrint+536

11: 00007FF68F893ECB v8::internal::StringHasher::UpdateIndex+219

12: 00007FF68FB03173 v8::internal::RegExpImpl::Exec+131

13: 00007FF68FA3B483 v8::internal::wasm::WasmInterpreter::Thread::Step+32195

14: 0000002ADA6DC5C1

我尝试给出--max-old-space-size = 4096,但仍然遇到相同的错误。 如果有人有任何想法,请检查此问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值