Skip to content

Render errors for pure typescript (or javascript) components #3

@ReinisV

Description

@ReinisV

Hey,

I'm getting an error when the vue-source mixin tries to execute it's mounted hook on components that are written in pure TS (e.g. they are not SFC, the file name is MyTsOnlyComponent.ts and the DOM is expressed in the render method).

[Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'match' of undefined"

found in

---> <MyTSOnlyComponent>


TypeError: Cannot read property 'match' of undefined
    at VueComponent.mounted (bundle.esm.js:46)
    at invokeWithErrorHandling (<webpack-package-path-omitted>:1864)
    at callHook (<webpack-package-path-omitted>.js:4195)
    at Object.insert (<webpack-package-path-omitted>.js:3140)
    at invokeInsertHook (<webpack-package-path-omitted>:6308)

This happens because, I'm guessing, the component is not passed through the vue-loader when webpack builds it, since the file does not end in .vue, and the $options.__file field is not being populated like it is being done for SFC files

image

Since there is an option to disable exposing the filename for SFCs and, based on documentation, vue-loader is not meant to compile non SFCs at all (and thus for those the field will never be set), maybe there should be an extra null check for the $options.__file field?

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