You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BAU, or if an error case arises, a deliberate and descriptive Rollup thrown error (e.g. entry module does not exist) when using the Browser distribution of Rollup.
In the browser (or Deno) results in the following thrown error:
error: Uncaught TypeError: Cannot read property 'split' of undefined
at Et (https://unpkg.com/rollup@2.38.0/dist/es/rollup.browser.js:11:65715)
at ja (https://unpkg.com/rollup@2.38.0/dist/es/rollup.browser.js:11:325076)
at async Qa.loadEntryModule (https://unpkg.com/rollup@2.38.0/dist/es/rollup.browser.js:11:334442)
at async Promise.all (index 0)
Rollup's browser implementation of resolve() does not cater for no arguments being passed.
Rollup's module resolution code calls resolve() with no arguments in certain scenarios.
In NodeJS, calling resolve() with no arguments is valid and will return the CWD, but in the Rollup browser implementation results in attempting to call .split() on undefined.
given that if the provided arguments are insufficient to form an absolute path then the behaviour of resolve() is to prepend the CWD, and therefore the inclusion of the resolve() currently is both superfluous according to specification, and causing the Rollup browser distribution to thrown an Uncaught TypeError in very simple cases.
If, after processing all given path segments, an absolute path has not yet been generated, the current working directory is used.
No this does not happen in Node. It is specifically a problem with the Browser distribution of Rollup which afaik is officially supported (it drives the online REPL for instance).
I have updated the original description to primarily reference this is an issue with the browser distribution, it is simply a happy coincidence that the browser dist is compatible with Deno, and that is how I originally spotted the issue.
Expected Behavior
BAU, or if an error case arises, a deliberate and descriptive Rollup thrown error (e.g. entry module does not exist) when using the Browser distribution of Rollup.
Actual Behavior
Executing:
In the browser (or Deno) results in the following thrown error:
Please see the reproduction (https://gist.github.com/cmorten/fdffbd9ce521b6436f5fcbce429e752d) for complementary details. Summary below:
Rollup's browser implementation of
resolve()
does not cater for no arguments being passed.Rollup's module resolution code calls
resolve()
with no arguments in certain scenarios.In NodeJS, calling
resolve()
with no arguments is valid and will return the CWD, but in the Rollup browser implementation results in attempting to call.split()
onundefined
.I suspect the fix may be as simple as replacing the code at https://github.com/rollup/rollup/blob/master/browser/path.ts#L61 with
but it may well not be that simple. Alternatively, removing the use of
resolve()
with no arguments from https://github.com/rollup/rollup/blob/master/src/utils/resolveId.ts#L31 with something likegiven that if the provided arguments are insufficient to form an absolute path then the behaviour of
resolve()
is to prepend the CWD, and therefore the inclusion of theresolve()
currently is both superfluous according to specification, and causing the Rollup browser distribution to thrown anUncaught TypeError
in very simple cases.REF: https://nodejs.org/api/path.html#path_path_resolve_paths
Context: I am using the browser distribution as the core for a Deno port of Rollup in which I am having to work around this issue currently.
Happy to put in a PR if the issue stands (and haven't missed something obvious!)
The text was updated successfully, but these errors were encountered: