Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Using PDF.js (pdfjs-dist) in Plasmo project generates file with name "_empty.<random number>.js" that is reserved by the system #936

Open
2 of 3 tasks
felixswang opened this issue Apr 11, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@felixswang
Copy link

What happened?

Tried in both background index.ts and content scripts, both have the issue.

My code:

import * as pdfjsLib from 'pdfjs-dist';

pdfjsLib.GlobalWorkerOptions.workerSrc = `//mozilla.github.io/pdf.js/build/pdf.worker.js`;

const pdf = await pdfjsLib.getDocument(msg.pdfUrl).promise;

const numPages = pdf.numPages;

let fullText = '';

for (let pageNumber = 1; pageNumber <= numPages; pageNumber++) {
    const page = await pdf.getPage(pageNumber);
    const textContent = await page.getTextContent();
    textContent.items.forEach(item => {
        fullText += item.str;
    });
}

When the extension is compiled and loaded in Chrome, Chrome pops an alert saying:

Failed to load extension
File
~/Products/GPTPlugin/gpt-plugin/build/chrome-mv3-dev
Error
Cannot load extension with file or directory name _empty.c3437ec2.js. Filenames starting with "_" are reserved for use by the system.
Could not load manifest.

Version

Latest

What OS are you seeing the problem on?

MacOSX

What browsers are you seeing the problem on?

Chrome

Relevant log output

No log because the error occurs when the extension is loaded

(OPTIONAL) Contribution

  • I would like to fix this BUG via a PR

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I checked the current issues for duplicate problems.
@felixswang felixswang added the bug Something isn't working label Apr 11, 2024
@felixswang
Copy link
Author

Is there any update regarding this bug?

@123wwwa
Copy link

123wwwa commented Apr 26, 2024

I have same issue using pdfjs-dist

@123wwwa
Copy link

123wwwa commented Apr 29, 2024

I solved error by using
import { pdfjs } from "react-pdf"
pdfjs.GlobalWorkerOptions.workerSrc = //cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js
instead of
import * as pdfjs from 'pdfjs-dist'

@muqsitnawaz
Copy link

Same here. Tried a few different packages pdfjs-dist, pdf-text-reader, couldn't get any of these pdf readers to extract text when using Plasmo.

What's the purpose of _empty file and why is plasmo generating it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants