1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Adds RequireJS to worker.

This commit is contained in:
Yury Delendik 2015-12-16 18:37:43 -06:00
parent 85e95d34ed
commit fc3282db56
8 changed files with 143 additions and 152 deletions

View file

@ -303,36 +303,6 @@ function build(setup) {
}
exports.build = build;
function getWorkerSrcFiles(filePath) {
var src = fs.readFileSync(filePath).toString();
var reSrcFiles = /var\s+otherFiles\s*=\s*(\[[^\]]*\])/;
var match = reSrcFiles.exec(src);
if (!match) {
throw new Error('Cannot find otherFiles array in ' + filePath);
}
var files = match[1].replace(/'/g, '"').replace(/^\s*\/\/.*/gm, '')
.replace(/,\s*]$/, ']');
try {
files = JSON.parse(files);
} catch (e) {
throw new Error('Failed to parse otherFiles in ' + filePath + ' as JSON, ' +
e);
}
var srcFiles = files.filter(function(name) {
return name.indexOf('external') === -1;
});
var externalSrcFiles = files.filter(function(name) {
return name.indexOf('external') > -1;
});
return {
srcFiles: srcFiles,
externalSrcFiles: externalSrcFiles
};
}
exports.getWorkerSrcFiles = getWorkerSrcFiles;
/**
* Merge two defines arrays. Values in the second param will override values in
* the first.