crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.92k stars 190 forks source link

[crx:content-script-resources] RangeError: Maximum call stack size exceeded #908

Open rezasohrabi opened 3 months ago

rezasohrabi commented 3 months ago

Build tool

Rollup

Where do you see the problem?

Describe the bug

hi i use jspdf and html2canvas-pro to generate pdf of current page, everythin in development is ok, but when i try build the extension this error occurs how to fix this build error?

Reproduction

when i import and use jspdf in my extension this error occurs

import { jsPDF } from 'jspdf'; const pdf = new jsPDF('p', 'mm', 'a4');

Logs

│ [crx:content-script-resources] RangeError: Maximum call stack size exceeded
│     at SetIterator.next (<anonymous>)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3289:24)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│     at getResources (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/vite-plugi
│ n/dist/index.mjs:3292:19)
│ ✓ built in 21.06s
│ error during build:
│ Error: [crx:manifest-post] Error in crx:content-script-resources.renderCrxManifest
│     at Object.generateBundle (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@5.1.1/node_modules/@crxjs/v
│ ite-plugin/dist/index.mjs
│ :2933:19)
│     at async Bundle.generate (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry
│ .js:17059:9)
│     at async file:///C:/Users/ACER/Desktop/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:19605:27
│     at async catchUnfinishedHookActions (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared
│ /node-entry.js:19036:16) 
│     at async build (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/vite@5.1.1_@types+node@20.12.12/node_modules/vite/dist/node/chunks/d
│ ep-94_H5fT6.js:66899:22) 
│     at async CAC.<anonymous> (file:///C:/Users/ACER/Desktop/node_modules/.pnpm/vite@5.1.1_@types+node@20.12.12/node_modules/vite/dist/nod
│ e/cli.js:842:9)
│  ELIFECYCLE  Command failed with exit code 1.

System Info

OS: Windows 10
CPU: (12) x64 Intel(R) Core(TM) i7-9750H 
Memory: 15.85 GB
pnpm: 8.15.0 
browser: chrome

Severity

annoyance

cwc1222 commented 3 months ago

I had a similar issue, then solved the issue by increasing the version from

"@crxjs/vite-plugin": "^1.0.14",
"vite": "^2.9.15",

to


"@crxjs/vite-plugin": "^2.0.0-beta.25",
"vite": "^4.2.2"
Toumash commented 2 months ago

Yeah, works for me no problem

    "jspdf": "^2.5.1",
    "@crxjs/vite-plugin": "^2.0.0-beta.23",
    "vite": "^5.2.11",