#1001631 pdf.js: FTBFS with webpack5: Error: Missing file or directory

Package:
src:pdf.js
Source:
pdf.js
Submitter:
Ayoyimika Ajibade
Date:
2022-07-04 16:51:03 UTC
Severity:
serious
Tags:
Blocked By:
Bug Title
1012009

  2

ITP: node-dommatrix -- ES6+ shim for DOMMatrix

wishlist about 4 years ago

#1001631#5
Date:
2021-12-13 13:20:37 UTC
From:
To:
Hi,

We are starting to build against webpack5 in experimental and the
package needed for local build is webpack and node-webpack-source from
experimental.
During a test rebuild, pdf.js was found to fail to build in that situation.

Relevant part (hopefully):

webpack 5.65.0 compiled successfully
[12:40:32] Finished '<anonymous>' after 1.32 min
[12:40:32] Finished 'minified-pre' after 1.32 min
[12:40:32] Starting '<anonymous>'...
[12:40:32] '<anonymous>' errored after 6.04 ms
[12:40:32] Error: ENOENT: no such file or directory, open
'build/minified//build/pdf.js'
     at Object.openSync (fs.js:462:3)
     at Object.readFileSync (fs.js:364:35)
     at parseMinified (/<<PKGBUILDDIR>>/gulpfile.js:907:20)
     at /<<PKGBUILDDIR>>/gulpfile.js:966:5
     at bound (domain.js:427:14)
     at runBound (domain.js:440:12)
     at asyncRunner
(/usr/share/nodejs/gulp/node_modules/async-done/index.js:55:18)
     at processTicksAndRejections (internal/process/task_queues.js:79:11)
[12:40:32] 'minified' errored after 1.32 min
[12:40:32] 'dist-pre' errored after 5.87 min
make[1]: *** [debian/rules:9: override_dh_auto_build] Error 1
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:6: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit
status 2

The full log is attached to this mail

#1001631#10
Date:
2022-05-24 20:08:45 UTC
From:
To:
On Mon, 13 Dec 2021 14:20:37 +0100 Ayoyimika Ajibade  <ayoyimikaajibade@gmail.com> wrote:
 > Relevant part (hopefully):
 >
 > webpack 5.65.0 compiled successfully
 > [12:40:32] Finished '<anonymous>' after 1.32 min
 > [12:40:32] Finished 'minified-pre' after 1.32 min
 > [12:40:32] Starting '<anonymous>'...
 > [12:40:32] '<anonymous>' errored after 6.04 ms
 > [12:40:32] Error: ENOENT: no such file or directory, open
 > 'build/minified//build/pdf.js'

This happens becuase the default output directory is dist/ and not ./

So on the command line we have to pass --output-path
build/minified/build --output-filename pdf.js, we have to find the
equivalent in gulpfile.js

#1001631#21
Date:
2022-05-28 15:38:43 UTC
From:
To:
On Wed, 25 May 2022 01:38:45 +0530 Pirate Praveen
<praveen@onenetbeyond.org> wrote:
 > Control: tags -1 help
 >
 > On Mon, 13 Dec 2021 14:20:37 +0100 Ayoyimika Ajibade
 > <ayoyimikaajibade@gmail.com> wrote:
 >  > Relevant part (hopefully):
 >  >
 >  > webpack 5.65.0 compiled successfully
 >  > [12:40:32] Finished '<anonymous>' after 1.32 min
 >  > [12:40:32] Finished 'minified-pre' after 1.32 min
 >  > [12:40:32] Starting '<anonymous>'...
 >  > [12:40:32] '<anonymous>' errored after 6.04 ms
 >  > [12:40:32] Error: ENOENT: no such file or directory, open
 >  > 'build/minified//build/pdf.js'
 >
 > This happens becuase the default output directory is dist/ and not ./
 >
 > So on the command line we have to pass --output-path
 > build/minified/build --output-filename pdf.js, we have to find the
 > equivalent in gulpfile.js

I made some progress in the build, some webpack builds now pass, still
some more errors need fixing. Pushed my changes to salsa. Help is
welcome to fix the remaining errors.

   debian/rules override_dh_auto_build
make[1]: Entering directory '/home/pravi/forge/js-team/pdf.js'
gulp dist-pre
[15:30:21] Local gulp not found in ~/forge/js-team/pdf.js
[15:30:21] Try running: npm install gulp
[15:30:21] Using globally installed gulp
postcss-calc: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
[15:30:22] Using gulpfile ~/forge/js-team/pdf.js/gulpfile.js
[15:30:22] Starting 'dist-pre'...
[15:30:22] Starting 'generic'...
[15:30:22] Starting 'createBuildNumber'...

### Getting extension build number
This is not a Git repository; using default build number.
Extension build number: 0
[15:30:22] Finished 'createBuildNumber' after 38 ms
[15:30:22] Starting 'locale'...

### Building localization files
[15:30:22] Finished 'locale' after 221 ms
[15:30:22] Starting 'scriptingGeneric'...

### Building default preferences
[15:30:24] asset pdf.scripting.js 102 KiB [emitted] (name: main)

webpack 5.65.0 compiled successfully
(node:22093) [DEP0005] DeprecationWarning: Buffer() is deprecated due
to security and usability issues. Please use the Buffer.alloc(),
Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was
created)
[15:30:24] Finished 'scriptingGeneric' after 2.23 s
[15:30:24] Starting 'createGeneric'...

### Creating generic viewer
[BABEL] Note: The code generator has deoptimised the styling of
/home/pravi/forge/js-team/pdf.js/external/quickjs/quickjs-eval.js as it
exceeds the max of 500KB.
[15:30:30] asset pdf.sandbox.js 615 KiB [emitted] [big] (name: main) 1
related asset

webpack 5.65.0 compiled successfully
[15:30:32] 'createGeneric' errored after 7.72 s
[15:30:32] Error in plugin "webpack-stream"
Message:
    Module build failed (from ./external/webpack/pdfjsdev-loader.js):
TypeError: this[type] is not a function
    at CodeGenerator.generateExpression
(/usr/share/nodejs/escodegen/escodegen.js:2496:28)
    at /usr/share/nodejs/escodegen/escodegen.js:1129:38

#1001631#26
Date:
2022-05-28 15:56:06 UTC
From:
To:
On Sat, 28 May 2022 21:08:43 +0530 Pirate Praveen  <praveen@onenetbeyond.org> wrote:
After embedding @javascript-obfuscator/escodegen and
@javascript-obfuscator/estraverse

The error changes to (we can probably embed this too or package it)

[15:45:31] 'createGenericLegacy' errored after 30 s
[15:45:31] Error in plugin "webpack-stream"
Message:
    Module not found: Error: Can't resolve
'dommatrix/dist/dommatrix.js' in
'/home/pravi/forge/js-team/pdf.js/src/shared'
Details:
    domainEmitter: [object Object]
    domainThrown: false

[15:45:31] 'generic-legacy' errored after 32 s
[15:45:31] 'dist-pre' errored after 51 s

#1001631#31
Date:
2022-05-28 17:22:25 UTC
From:
To:
On ശ, മേയ് 28 2022 at 09:26:06 വൈകു +05:30:00 +05:30:00, Pirate Praveen <praveen@onenetbeyond.org> wrote:

After adding domhandler in debian/build_modules, it goes further in the
build and fails at

[17:18:19] 'compressMinified' errored after 156 ms
[17:18:19] TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must
be of type string or an instance of Buffer, TypedArray, or DataView.
Received undefined
    at Object.writeFileSync (node:fs:2150:5)
    at parseMinified
(/home/pravi/forge/js-team/pdf.js/gulpfile.js:1040:6)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections
(node:internal/process/task_queues:96:5)
    at async compressMinified
(/home/pravi/forge/js-team/pdf.js/gulpfile.js:1102:7)
[17:18:19] 'minified' errored after 15 s
[17:18:19] 'dist-pre' errored after 1.4 min

#1001631#38
Date:
2022-05-28 18:49:11 UTC
From:
To:
On Sat, 28 May 2022 22:52:25 +0530 Pirate Praveen  <praveen@onenetbeyond.org> wrote:
 > [17:18:19] 'compressMinified' errored after 156 ms
 > [17:18:19] TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must
 > be of type string or an instance of Buffer, TypedArray, or DataView.
 > Received undefined

This requires terser 5. So I have disabled minification in gulpfile via
a patch. If we need to generate the minified files, we can use terser
command line.

Once node-dommatrix clears NEW, we can upload these changes.