plasmo icon indicating copy to clipboard operation
plasmo copied to clipboard

[BUG] file beginning with _ generates in build/chrome-mv3-dev, breaking development

Open Fiattarone opened this issue 1 year ago • 3 comments

What happened?

Load Package Error in chrome:

Failed to load extension from: /../../build/chrome-mv3-dev. Cannot load extension with file or directory name empty.f6fb76d8.js. Filenames starting with "" are reserved for use by the system.

I can see _empty.f6fb76d8.js being generated in the aforementioned dir, deleting/renaming it doesn't help. Tried deleting the whole of chrome-mv3-dev and it regenerates with the same breaking file.

Looks like this is some kind of issue with plasmo, as I've gone back several commits that were tested tried and true and the _empty is still being generated upon pnpm dev

Version

Latest

What OS are you seeing the problem on?

MacOSX

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

(OPTIONAL) Contribution

  • [ ] I would like to fix this BUG via a PR

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct
  • [X] I checked the current issues for duplicate problems.

Fiattarone avatar Nov 24 '23 17:11 Fiattarone

It actually looks like this is due to a dependency of mine called pdfjs-dist... no idea how to begin debugging it though as no other errors are being thrown.

Friend of mine suggested downloading the lib to my project folder directly as a workaround, but I really try avoiding suggestions that look like they fell out of the early 2000's and bumped their head.

Fiattarone avatar Nov 25 '23 04:11 Fiattarone

I've encountered the same error @Fiattarone with pdfjs-dist. Moreover, if you try to build with code like this:

const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
  const response = await fetch(url)
  const arrayBuffer = await response.arrayBuffer()
  // This line below causes the error.
  const loadingTask = pdfJS.getDocument({ data: arrayBuffer })
}

You'll receive:

  × await isn't allowed in non-async function
       ╭─[16181:1]
 16181 │ /\*\*\*\*\*\*/ // Load entry module and return exports
 16182 │ /\*\*\*\*\*\*/ // This entry module used 'module' so it can't be inlined
 16183 │ /\*\*\*\*\*\*/ var \_\_webpack\_exports\_\_ = \_\_webpack\_require\_\_(907);
 16184 │ /\*\*\*\*\*\*/ \_\_webpack\_exports\_\_ = globalThis.pdfjsLib = await (globalThis.pdfjsLibPromise = \_\_webpack\_exports\_\_);
       ·                                                            ─
 16185 │ /\*\*\*\*\*\*/ var \_\_webpack\_exports\_\_AbortException = \_\_webpack\_exports\_\_.AbortException;
 16186 │ /\*\*\*\*\*\*/ var \_\_webpack\_exports\_\_AnnotationEditorLayer = \_\_webpack\_exports\_\_.AnnotationEditorLayer;
 16187 │ /\*\*\*\*\*\*/ var \_\_webpack\_exports\_\_AnnotationEditorParamsType = \_\_webpack\_exports\_\_.AnnotationEditorParamsType;

Adding in case it's helpful for resolving this problem.

the-wc avatar Nov 28 '23 20:11 the-wc

Follow up here, @Fiattarone

the-wc avatar Dec 07 '23 01:12 the-wc