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
If the render function is called from within an anonymous function, an exception occurs. Typically this might happen in a callback, but the following examples demonstrate the problem.
(()=>{// ANONYMOUS FUNCTIONapi.render('./template')// EXCEPTION})()(function(){// ANONYMOUS FUNCTIONapi.render('./template')// EXCEPTION})()(functionisCompleted(){// NAMED FUNCTIONapi.render('./template')// WORKS CORRECTLY})()
What is expected?
It should be possible to call api.render() from within an anonymous function.
What is actually happening?
An exception is thrown when api.render() is called from within an anonymous function. This occurs because the stack trace used by extractCallDir() to get the project directory does not contain parenthesis:
ERROR TypeError: Cannot read property '1' of null
TypeError: Cannot read property '1' of null
at extractCallDir (/Users/philcal/.config/yarn/global/node_modules/@vue/cli/lib/GeneratorAPI.js:406:57)
at GeneratorAPI.render (/Users/philcal/.config/yarn/global/node_modules/@vue/cli/lib/GeneratorAPI.js:227:21)
[THE FOLLOWING LINE CONTAINS NO PARENTHESES]
at /private/tmp/my-project/node_modules/vue-cli-plugin-xyz/generator/index.js:39:9
at runGenerator (/Users/philcal/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:141:13)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async invoke (/Users/philcal/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:101:3)
Workaround:
In the plugin code, give a name to the anonymous function that calls api.render(), however that solution is not obvious to a person experiencing this problem.
Full resolution:
The function extractCallDir() should handle stack trace lines for anonymous functions, but the line containing callSite.match(..) only matches lines containing parentheses. (See stack trace example above)
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Version
4.0.5
Environment info
Steps to reproduce
If the render function is called from within an anonymous function, an exception occurs. Typically this might happen in a callback, but the following examples demonstrate the problem.
What is expected?
It should be possible to call api.render() from within an anonymous function.
What is actually happening?
An exception is thrown when api.render() is called from within an anonymous function. This occurs because the stack trace used by extractCallDir() to get the project directory does not contain parenthesis:
Workaround:
In the plugin code, give a name to the anonymous function that calls api.render(), however that solution is not obvious to a person experiencing this problem.
Full resolution:
The function
extractCallDir()
should handle stack trace lines for anonymous functions, but the line containing callSite.match(..) only matches lines containing parentheses. (See stack trace example above)The text was updated successfully, but these errors were encountered: