Skip to content

Uncaught TypeError when using eval-* devtool source map config #20095

@Ollymid

Description

@Ollymid

Bug Description

With React-PDF and higher - when you select any devtool option that starts with eval- you then end up with an uncaught TypeError

Image

First reported with React-PDF here: wojtekmaj/react-pdf#1813 and replicated by myself here: wojtekmaj/react-pdf#2031

The maintainer of React-pdf, suggested posting an issue here since this only happens with Webpack and only because of this one particular devtool setting.

Environment:
Browser: Chrome Version 141.0.7390.123
React version: 18.3.1
Bundler name and version (if applicable): webpack 5.102.1

Other older react-pdf issue (wojtekmaj/react-pdf#1813) :
Browser (if applicable): Chrome 125.0.6422.113
React version: ^17.0.2
Webpack version (if applicable): [email protected]

Link to Minimal Reproduction and step to reproduce

import React, {useCallback, useRef, useState} from 'react';
import {Document, Page, pdfjs} from 'react-pdf';

pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
interface IProps {
    url: string;
}
const opt =  {
    cMapUrl: `${window.location.origin}/cmaps/`,
    cMapPacked: true,
    isEvalSupported: false,
}

const PageRender = ({url}: IProps) => {
    const [numPages, setNumPages] = useState(1);
    const pageRef = useRef<HTMLDivElement>(null);
    
    const onDocumentLoadSuccess = useCallback(
        (document) => {
            const {numPages: nextNumPages} = document;
            setNumPages(nextNumPages);
        },
        []
    );
   
    return (
        <div
            className={'pageReaderWrap'}
            ref={pageRef}
        >
            <Document
                file={url}
                key={url}
                onLoadSuccess={onDocumentLoadSuccess}
                options={opt}
            >
                {Array.from(new Array(numPages), (el, index) => {
                    return (
                        <Page
                            key={`page_${index + 1}`}
                            renderTextLayer={false}
                            loading={''}
                            renderAnnotationLayer={false}
                            pageNumber={index + 1}
                        />
                    );
                })}
            </Document>
        </div>
    );
};

export default PageRender;
devtool: isDevelopment ? 'eval-source-map' : 'source-map',

Expected Behavior

Expect the React-pdf components to load without issue

Actual Behavior

Ends up with uncaught TypeError:

Image

Environment

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 133.09 MB / 32.00 GB
  Binaries:
    Node: 24.11.0 - ~/.nvm/versions/node/v24.11.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 11.6.1 - ~/.nvm/versions/node/v24.11.0/bin/npm
  Browsers:
    Chrome: 142.0.7444.135
    Safari: 18.5
  Packages:
    babel-loader: ^10.0.0 => 10.0.0
    copy-webpack-plugin: 13.0.1 => 13.0.1
    css-loader: 6.10.0 => 6.10.0
    css-minimizer-webpack-plugin: ^7.0.2 => 7.0.2
    eslint-import-resolver-webpack: ^0.13.10 => 0.13.10
    json-loader: 0.5.7 => 0.5.7
    less-loader: 12.3.0 => 12.3.0
    source-map-loader: 5.0.0 => 5.0.0
    style-loader: 4.0.0 => 4.0.0
    terser-webpack-plugin: ^5.3.14 => 5.3.14
    ts-loader: ^9.5.4 => 9.5.4
    webpack: 5.102.1 => 5.99.9
    webpack-bundle-analyzer: ^4.10.2 => 4.10.2
    webpack-cli: 6.0.1 => 6.0.1
    webpack-dev-server: 5.2.2 => 5.2.2
    webpack-node-externals: 3.0.0 => 3.0.0
    webpack-retry-chunk-load-plugin: ^3.1.1 => 3.1.1

Is this a regression?

No

Last Working Version

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions