chrome-extension-tools
chrome-extension-tools copied to clipboard
<all_urls> in manifest.json -> content_scripts.matches fails build
Build tool
Vite
Where do you see the problem?
- [ ] In the browser
- [X] In the terminal
Describe the bug
Hello
This looks like a consequence from https://github.com/crxjs/chrome-extension-tools/issues/282. In [1] during build paths are stripped from content_scripts.matches
in manifest.json
. Which is generally fine until somebody wants to use <all_urls>
which is "special pattern" described in Chrome docs [2] (and also for Firefox [3]).
For http
/https
this could be replaced with *://*/
but this will not match file
, ftp
or urn
scheme according to documentation.
I will submit a small PR regarding this for this in next couple of minutes.
- [1] helpers.ts#L164
- [2] Match patters on developer.chrome.com
- [3] Match patters on developer.mozilla.org
Reproduction
URL: https://github.com/elwin013/crxjs-vite-all_urls
Running npm run dev
works.
Running npm run build
errors (log below in logs)
Logs
[crx:content-script-resources] TypeError: Cannot read property 'split' of undefined
at stubMatchPattern (file:///redacted_path/node_modules/@crxjs/vite-plugin/dist/index.mjs:104:35)
at Array.map (<anonymous>)
at Object.renderCrxManifest (file:///redacted_path/node_modules/@crxjs/vite-plugin/dist/index.mjs:3322:59)
at Object.generateBundle (file:///redacted_path/node_modules/@crxjs/vite-plugin/dist/index.mjs:2919:60)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Bundle.generate (file:///redacted_path/node_modules/rollup/dist/es/shared/rollup.js:15973:9)
at async file:///redacted_path/node_modules/rollup/dist/es/shared/rollup.js:23709:27
at async catchUnfinishedHookActions (file:///redacted_path/node_modules/rollup/dist/es/shared/rollup.js:23041:20)
at async doBuild (file:///redacted_path/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:43524:20)
at async build (file:///redacted_path/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:43347:16)
[crx:manifest-post] Error in crx:content-script-resources.renderCrxManifest
error during build:
Error: Error in crx:content-script-resources.renderCrxManifest
at Object.generateBundle (file:///redacted_path/node_modules/@crxjs/vite-plugin/dist/index.mjs:2930:19)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Bundle.generate (file:///redacted_path/node_modules/rollup/dist/es/shared/rollup.js:15973:9)
at async file:///redacted_path/node_modules/rollup/dist/es/shared/rollup.js:23709:27
at async catchUnfinishedHookActions (file:///redacted_path/node_modules/rollup/dist/es/shared/rollup.js:23041:20)
at async doBuild (file:///redacted_path/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:43524:20)
at async build (file:///redacted_path/node_modules/vite/dist/node/chunks/dep-71eb12cb.js:43347:16)
at async CAC.<anonymous> (file:///redacted_path/node_modules/vite/dist/node/cli.js:747:9)
System Info
System:
OS: Linux 5.16 Manjaro Linux
CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
Memory: 765.77 MB / 43.00 GB
Container: Yes
Shell: 5.9 - /bin/zsh
Binaries:
Node: 14.19.0 - ~/.nvm/versions/node/v14.19.0/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v14.19.0/bin/yarn
npm: 6.14.16 - ~/.nvm/versions/node/v14.19.0/bin/npm
Browsers:
Chromium: 103.0.5060.134
Firefox: 103.0
npmPackages:
@crxjs/vite-plugin: ^1.0.13 => 1.0.13
vite: ^3.0.0 => 3.0.4
Severity
blocking an upgrade
+1, am also experiencing this issue
@elwin013 thanks for your investigation and PR fix. I referenced the changes you made so I could patch @crxjs/vite-plugin
locally until (hopefully) this is merged and released officially.
I edited the same lines in the equivalent node_modules
files, and used https://github.com/ds300/patch-package to commit that to my repo as a stopgap so the build is up and running. 👌
@jacksteamdev Thanks! :tada: