-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
export static functions in compile to component #125
Comments
Try export static functions as module values. |
@ruojianll that does work for this case. For example: We export all the components in one go (aka all the default exports) so we can use the following: import {MyComponent1, MyComponent2} from '@mycompany/ui-library'; They would both have a We are following the example given by vite: https://vitejs.dev/guide/build#library-mode so we export all components from the entrypoint in the lib. So basically we have to use (if we follow the example in the initial post) in the lib: import {HelloWorld, staticFunctionCall as HelloWorldStaticFunctionCall } from './HelloWorld.vue';
export {HelloWorld, HelloWorldStaticFunctionCall} And this is the exact example we try to avoid, since the function itself is really tied to the HelloWorld class, why should we need to export something extra for this? This suggestion might fix the TS errors, but is such a shift in the way the ui-library will work, its something we really would like to avoid. Anyhow I'm still of the opinion that a static function should be exported/accesible from the outside, as that is what TS is also exporting. SIdenote: thanks for the amazing work you've done here! |
In the old vue class components we could define a public static function which would be callable from other components/locations.
This original functionality is defined here i believe: https://github.com/vuejs/vue-class-component/blob/master/src/component.ts#L119
Anyhow i think public static functions should be added to the exported class/object in https://github.com/facing-dev/vue-facing-decorator/blob/master/src/component.ts#L74
However i'm not capable enough to make a sane solution for this (e.g. im not sure how to handle inheritance and other side effects).
Normally you can use a seperate ts class or something. But we want to use this for a lib and its really helpfull to have these kind of functions included in the component instead of a "random" other ts file/object/class
Minimal reproducable code:
Error received in the browser:
The code above is perfectly valid by (vue-)tsc and eslint, but fails in the browser.
The text was updated successfully, but these errors were encountered: