Saving old-style JS module name of dist libraries.
This commit is contained in:
parent
a048519fa1
commit
0759066be0
18
gulpfile.js
18
gulpfile.js
@ -167,6 +167,15 @@ function replaceWebpackRequire() {
|
|||||||
return replace('__webpack_require__', '__w_pdfjs_require__');
|
return replace('__webpack_require__', '__w_pdfjs_require__');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceJSRootName(amdName) {
|
||||||
|
// Saving old-style JS module name.
|
||||||
|
var jsName = amdName.replace(/[\-_\.\/]\w/g, function (all) {
|
||||||
|
return all[1].toUpperCase();
|
||||||
|
});
|
||||||
|
return replace('root["' + amdName + '"] = factory()',
|
||||||
|
'root["' + amdName + '"] = root.' + jsName + ' = factory()');
|
||||||
|
}
|
||||||
|
|
||||||
function createBundle(defines) {
|
function createBundle(defines) {
|
||||||
console.log();
|
console.log();
|
||||||
console.log('### Bundling files into pdf.js');
|
console.log('### Bundling files into pdf.js');
|
||||||
@ -186,7 +195,8 @@ function createBundle(defines) {
|
|||||||
});
|
});
|
||||||
var mainOutput = gulp.src('./src/pdf.js')
|
var mainOutput = gulp.src('./src/pdf.js')
|
||||||
.pipe(webpack2Stream(mainFileConfig))
|
.pipe(webpack2Stream(mainFileConfig))
|
||||||
.pipe(replaceWebpackRequire());
|
.pipe(replaceWebpackRequire())
|
||||||
|
.pipe(replaceJSRootName(mainAMDName));
|
||||||
if (defines.SINGLE_FILE) {
|
if (defines.SINGLE_FILE) {
|
||||||
return mainOutput; // don't need a worker file.
|
return mainOutput; // don't need a worker file.
|
||||||
}
|
}
|
||||||
@ -202,7 +212,8 @@ function createBundle(defines) {
|
|||||||
});
|
});
|
||||||
var workerOutput = gulp.src('./src/pdf.worker.js')
|
var workerOutput = gulp.src('./src/pdf.worker.js')
|
||||||
.pipe(webpack2Stream(workerFileConfig))
|
.pipe(webpack2Stream(workerFileConfig))
|
||||||
.pipe(replaceWebpackRequire());
|
.pipe(replaceWebpackRequire())
|
||||||
|
.pipe(replaceJSRootName(workerAMDName));
|
||||||
return merge([mainOutput, workerOutput]);
|
return merge([mainOutput, workerOutput]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +239,8 @@ function createComponentsBundle(defines) {
|
|||||||
});
|
});
|
||||||
return gulp.src('./web/pdf_viewer.component.js')
|
return gulp.src('./web/pdf_viewer.component.js')
|
||||||
.pipe(webpack2Stream(componentsFileConfig))
|
.pipe(webpack2Stream(componentsFileConfig))
|
||||||
.pipe(replaceWebpackRequire());
|
.pipe(replaceWebpackRequire())
|
||||||
|
.pipe(replaceJSRootName(componentsAMDName));
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkFile(path) {
|
function checkFile(path) {
|
||||||
|
Loading…
Reference in New Issue
Block a user