New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix 'Cannot read properties of undefined (reading '0')' #4804
Conversation
❌ Deploy Preview for remarkable-travesseiro-a49bb0 failed.
|
I suppose you cannot provide a failing test case or reproduction for this so that we can figure out and fix the root cause? |
I'd love to, but this is part of a pretty involved project, and I don't know a lot about the workings of rollup, so I'm not 100% sure what the minimum repro would look like. I can tell you a little about how I ran into this: We have a private repo called which we'll call LIB, and inside LIB's package.json is:
export * as formatters from './formatters.js';
export { LANGUAGES } from './types.js';
// snip And inside formatters.ts: // formatters.ts
import { LANGUAGES } from "./index.js";
// snip
export function getFormatter(name: string): {
formatter: (fieldValue: number | string | Date, metadata?: any) => string,
options?: FormattingOptions
} {
if (formatters[name]) {
return formatters[name];
}
return {
formatter: (v: number | string) => v.toString()
};
} (Why does this import LANGUAGES from ./index.js instead of from ./types.js? -_- But, that's off topic.) Now, over in APP we in various places do: import { formatters } from '@privaterepo/LIB'; And we also import other things from LIB in various places. Roll-up was trying to print something along the lines of:
But, of course, fails. I assume there's more to this than just having different parts of these dependencies in different chunks, or else some existing test would fail already? |
Are you using |
The project in question is a React application, and we're using dynamic import to split up the project. The options are whatever the defaults Vite is supplying. |
Looks like this is fixed in #4829, so I'll close this. |
This issue has been resolved via #4829 as part of rollup@3.12.1. You can test it via |
This PR contains:
Are tests included?
I have no idea how to test this - suggestions welcome. But, this is hopefully a pretty obivously "safe" change.
Breaking Changes?
List any relevant issue numbers:
I was going to raise an issue, but I don't have a minimal reproduction. :P
Description
When bundling my project (via vite), I get:
Rollup is trying to print this warning:
The problem here is that this snippet:
fails, because despite the
!
,get(variable)
does in fact return undefined in my case. This doesn't fix the underlying issue here, but it at least stops rollup from crashing.