@@ -41,7 +41,6 @@ import { preprocess } from "./external/builder/builder.mjs";
4141import relative from "metalsmith-html-relative" ;
4242import rename from "gulp-rename" ;
4343import replace from "gulp-replace" ;
44- import sourcemaps from "gulp-sourcemaps" ;
4544import stream from "stream" ;
4645import TerserPlugin from "terser-webpack-plugin" ;
4746import Vinyl from "vinyl" ;
@@ -1618,20 +1617,15 @@ function buildLibHelper(bundleDefines, inputStream, outputDir) {
16181617 }
16191618 }
16201619
1621- let pipeline = inputStream ;
1622- if ( enableSourceMaps ) {
1623- pipeline = pipeline . pipe ( sourcemaps . init ( { loadMaps : true } ) ) ;
1624- }
1625- pipeline = pipeline . pipe (
1620+ const pipeline = inputStream . pipe (
16261621 new stream . Transform ( {
16271622 objectMode : true ,
16281623 transform : preprocessLib ,
16291624 } )
16301625 ) ;
1631- if ( enableSourceMaps ) {
1632- pipeline = pipeline . pipe ( sourcemaps . write ( "." ) ) ;
1633- }
1634- return pipeline . pipe ( gulp . dest ( outputDir ) ) ;
1626+ return pipeline . pipe (
1627+ gulp . dest ( outputDir , enableSourceMaps ? { sourcemaps : "." } : { } )
1628+ ) ;
16351629}
16361630
16371631function buildLib ( defines , dir ) {
@@ -1645,23 +1639,45 @@ function buildLib(defines, dir) {
16451639 DEFAULT_FTL : getDefaultFtl ( ) ,
16461640 } ;
16471641
1642+ const enableSourceMaps = bundleDefines . TESTING ;
16481643 const inputStream = ordered ( [
16491644 gulp . src (
16501645 [
16511646 "src/{core,display,shared}/**/*.js" ,
16521647 "src/{pdf,pdf.image_decoders,pdf.worker}.js" ,
16531648 ] ,
1654- { base : "src/" , encoding : false }
1649+ { base : "src/" , encoding : false , sourcemaps : enableSourceMaps }
16551650 ) ,
16561651 gulp . src ( [ "web/*.js" , "!web/{pdfjs,viewer}.js" ] , {
16571652 base : "." ,
16581653 encoding : false ,
1654+ sourcemaps : enableSourceMaps ,
1655+ } ) ,
1656+ gulp . src ( "test/unit/*.js" , {
1657+ base : "." ,
1658+ encoding : false ,
1659+ sourcemaps : enableSourceMaps ,
1660+ } ) ,
1661+ gulp . src ( "external/openjpeg/*.js" , {
1662+ base : "openjpeg/" ,
1663+ encoding : false ,
1664+ sourcemaps : enableSourceMaps ,
1665+ } ) ,
1666+ gulp . src ( "external/qcms/*.js" , {
1667+ base : "qcms/" ,
1668+ encoding : false ,
1669+ sourcemaps : enableSourceMaps ,
1670+ } ) ,
1671+ gulp . src ( "external/jbig2/*.js" , {
1672+ base : "jbig2/" ,
1673+ encoding : false ,
1674+ sourcemaps : enableSourceMaps ,
1675+ } ) ,
1676+ gulp . src ( "external/brotli/*.js" , {
1677+ base : "brotli/" ,
1678+ encoding : false ,
1679+ sourcemaps : enableSourceMaps ,
16591680 } ) ,
1660- gulp . src ( "test/unit/*.js" , { base : "." , encoding : false } ) ,
1661- gulp . src ( "external/openjpeg/*.js" , { base : "openjpeg/" , encoding : false } ) ,
1662- gulp . src ( "external/qcms/*.js" , { base : "qcms/" , encoding : false } ) ,
1663- gulp . src ( "external/jbig2/*.js" , { base : "jbig2/" , encoding : false } ) ,
1664- gulp . src ( "external/brotli/*.js" , { base : "brotli/" , encoding : false } ) ,
16651681 ] ) ;
16661682
16671683 return buildLibHelper ( bundleDefines , inputStream , dir ) ;
0 commit comments