Skip to content

Setting sensibleDefaults globally before they're used in components #48

@fourpixels

Description

@fourpixels

In our current project we stumbled upon a problem with setting the sensible defaults before they are being used. It's a bit deeper (as we're building a library), but simplified it's about setting the defaults before they are actually used.

Imports (ESM) are executed before the logic itself. Therefore in our case we're importing some specific components (even in App.vue) that are using VueTypes (even more complex as our models are in separate files). Our code of setting sensibleDefaults comes as a first line of actual code after the imports in main.js, but as you can guess, App is already imported, so other child components are imported as well, and their exports return VueTypes without newest sensible defaults.

In the most basic scenario we were able to load the root component (App.vue) asynchronously and fix this issue. But talking about building a library and importing a single component out of it, as there is no main.js, the only solution we had is to wrap VueTypes and execute setting sensible defaults inside the wrapper.

Is there any more elegant solution you could think of? 😄

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions