1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Adds UMD header to pdf.js and pdf.worker.js files.

This commit is contained in:
Yury Delendik 2015-12-23 17:46:08 -06:00
parent e8db825512
commit cbbb9bb82d
6 changed files with 77 additions and 39 deletions

20
make.js
View file

@ -484,7 +484,7 @@ target.bundle = function(args) {
echo();
echo('### Bundling files into ' + BUILD_TARGET);
function bundle(filename, outfilename, files) {
function bundle(filename, outfilename, files, distname) {
var bundleContent = cat(files),
bundleVersion = VERSION,
bundleBuild = exec('git log --format="%h" -n 1',
@ -500,12 +500,18 @@ target.bundle = function(args) {
// Removes AMD and CommonJS branches from UMD headers.
bundleContent = stripUMDHeaders(bundleContent);
var amdName = 'pdfjs-dist/build/' + distname.replace(/\.js$/, '');
var jsName = amdName.replace(/[\-_\.\/]\w/g, function (all) {
return all[1].toUpperCase();
});
// This just preprocesses the empty pdf.js file, we don't actually want to
// preprocess everything yet since other build targets use this file.
builder.preprocess(filename, outfilename, builder.merge(defines,
{BUNDLE: bundleContent,
BUNDLE_VERSION: bundleVersion,
BUNDLE_BUILD: bundleBuild}));
BUNDLE_BUILD: bundleBuild,
BUNDLE_AMD_NAME: amdName,
BUNDLE_JS_NAME: jsName}));
}
if (!test('-d', BUILD_DIR)) {
@ -524,6 +530,9 @@ target.bundle = function(args) {
SRC_DIR + 'core/worker.js'
];
var mainFileName = 'pdf.js';
var workerFileName = 'pdf.worker.js';
// Extension does not need svg.js and network.js files.
if (!defines.FIREFOX && !defines.MOZCENTRAL) {
MAIN_SRC_FILES.push(SRC_DIR + 'display/svg.js');
@ -535,6 +544,8 @@ target.bundle = function(args) {
// the main pdf.js output.
MAIN_SRC_FILES = MAIN_SRC_FILES.concat(WORKER_SRC_FILES);
WORKER_SRC_FILES = null; // no need for worker file
mainFileName = 'pdf.combined.js';
workerFileName = null;
}
// Reading UMD headers and building loading orders of modules. The
@ -549,12 +560,13 @@ target.bundle = function(args) {
cd(SRC_DIR);
bundle('pdf.js', ROOT_DIR + BUILD_TARGET, mainFiles);
bundle('pdf.js', ROOT_DIR + BUILD_TARGET, mainFiles, mainFileName);
if (workerFiles) {
var srcCopy = ROOT_DIR + BUILD_DIR + 'pdf.worker.js.temp';
cp('pdf.js', srcCopy);
bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, workerFiles);
bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, workerFiles,
workerFileName);
rm(srcCopy);
}
};