Skip to content

[Bug]: Webpack >=5.99.0 breaks the exposed API unit test #19808

@timvandermeij

Description

@timvandermeij

Attach (recommended) or Link to PDF file

N/A

Web browser and its version

137.0.1

Operating system and its version

Arch Linux

PDF.js version

5.1.91+

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

  1. Change https://github.com/mozilla/pdf.js/blob/master/test/unit/pdf_spec.js#L142 from it to fit.
  2. Run npx gulp unittest and notice that the test passes.
  3. Run npm install webpack@5.99.0 (or higher; as of writing everything until the most recent 5.99.5 version is broken)
  4. Run npx gulp unittest and notice that the test fails with globalThis.pdfjsLib being undefined:
TEST-UNEXPECTED-FAIL | checks that the viewer re-exports the expected API functionality | in firefox | TypeError: globalThis.pdfjsLib is undefined in http://127.0.0.1:43601/web/pdfjs.js (line 67) 
TEST-UNEXPECTED-FAIL | checks that the viewer re-exports the expected API functionality | in chrome | TypeError: Cannot destructure property 'AbortException' of 'globalThis.pdfjsLib' as it is undefined

What is the expected behavior?

The test should pass after the Webpack update.

What went wrong?

The test fails after the Webpack update.

Link to a viewer

No response

Additional context

It looks related to webpack/webpack#19394, but that was closed and I can't find other reports about similar issues. We should probably try to create a reduced test case that we can report upstream for this since it might be another case of that issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions