rollup / rollup

Next-generation ES module bundler
https://rollupjs.org
Other
25.27k stars 1.5k forks source link

code[code.length-1]: It could be undefined #4961

Open jxs7754 opened 1 year ago

jxs7754 commented 1 year ago

https://github.com/rollup/rollup/blame/da74c5929b66d45e1bbd4400899a8be9a3e25d33/src/utils/renderChunks.ts#L142

lukastaegert commented 1 year ago

Do you have a reproduction where this causes an issue?

so1ve commented 1 year ago

Do you mean ''[''.length - 1] === undefined? IMO this won't cause a crash.

roberto-sanchez-azumo commented 4 months ago

hi, while I'm unable to provide a reproduction of this error, It's actually possible to get a crash, when code is undefined - this is what happened to me, using @vitejs/plugin-legacy


TypeError: Cannot read properties of undefined (reading 'length')
    at transformChunk (file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:17955:31)
    at async file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:18013:17
    at async Promise.all (index 4)
    at async transformChunksAndGenerateContentHashes (file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:18008:5)
    at async renderChunks (file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:17916:137)
    at async Bundle.generate (file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:18150:13)
    at async file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:20697:27
    at async catchUnfinishedHookActions (file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/rollup@4.17.2/node_modules/rollup/dist/es/shared/node-entry.js:20124:16)
    at async build (file:///Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/vite@5.2.9_@types+node@18.19.31_sass@1.75.0_terser@5.30.3/node_modules/vite/dist/node/chunks/dep-_QLjGPdL.js:67458:22)
    at async viteBuildExecutor (/Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/@nx+vite@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107_@types+node@18.19.31_nx@19.0.2_typ_tg2xsbhfpy5khdodoi6yr5b4oy/node_modules/@nx/vite/src/executors/build/build.impl.js:63:29)
    at async getLastValueFromAsyncIterableIterator (/Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/nx@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/utils/async-iterator.js:15:19)
    at async iteratorToProcessStatusCode (/Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/nx@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/command-line/run/run.js:43:29)
    at async handleErrors (/Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/nx@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/utils/params.js:10:16)
    at async process.<anonymous> (/Users/rsanchez/azumo/spinwheel/pricechopper-rewards-platform/node_modules/.pnpm/nx@19.0.2_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/bin/run-executor.js:59:28)```