PlasmoHQ / plasmo

๐Ÿงฉ The Browser Extension Framework
https://www.plasmo.com
MIT License
10.14k stars 350 forks source link

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

Open Fiattarone opened 9 months ago

Fiattarone commented 9 months ago

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

Code of Conduct

Fiattarone commented 9 months ago

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.

the-wc commented 9 months ago

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 commented 9 months ago

Follow up here, @Fiattarone