Skip to content
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

EXT-1403-nicer-error-message-to-replace-the-one-from-the-failing-fieldtype-wrapper-js #140

Conversation

johannes-lindgren
Copy link
Contributor

@johannes-lindgren johannes-lindgren commented Apr 25, 2023

What?

Nicer error message from failing fieldtype-wrapper.js.

Replaces the uncaught error from #107

image

with

image

Why?

When a client upload code to the field plugin editor, Storyblok will serve a document with a script that contains that code. But the content of the script element will not be exactly the code that the client uploaded; it will be appended with a code snippet from Storyblok. For example, the if the client uploads

console.log('hello')

Storyblok will serve a document with

<script type="text/javascript">
  console.log('hello')

  var customComp = window.Storyblok.vue.extend(window.storyblok.field_types['sb-dummy'])
  window.Storyblok.vue.component('custom-plugin', customComp)
  window.StoryblokPluginRegistered = true
</script>

This last part causes an error to be thrown. The only way to prevent these last three lines from being executed is by throwing an error before it's executed.

For Storyblok internals, see the feature requests:

How to test? (optional)

Build one of the templates and upload the export bundle to the field plugin editor. You should see the new error message instead, and the app should load normally.

@vercel
Copy link

vercel bot commented Apr 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
field-plugin-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2023 10:39am

@johannes-lindgren
Copy link
Contributor Author

Once this is merged, we should reply in #107

Copy link
Contributor

@BibiSebi BibiSebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you also added the link to the repo 👏

@johannes-lindgren johannes-lindgren merged commit 6172412 into main Apr 25, 2023
10 checks passed
@johannes-lindgren johannes-lindgren deleted the EXT-1403-nicer-error-message-to-replace-the-one-from-the-failing-fieldtype-wrapper-js branch April 25, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vue3 Template - Failed to mount component: template or render function not defined.
2 participants