Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

Errors about custom components not being in/having valid sub components #63

Open
justinmchase opened this issue Jun 26, 2019 · 1 comment

Comments

@justinmchase
Copy link

justinmchase commented Jun 26, 2019

Expected behavior

The editor should respect the metadata about components.

Actual behavior

Despite the parent / child component declarations the editor is showing errors.

Steps to reproduce the problem

  1. Use the boiler plate demo
  2. Fix up the bad .mjmlconfig to have the 3 custom components in it
  3. Open the .mjml file in the repo

Code sample

Follow the steps here:
https://github.com/mjmlio/mjml-component-boilerplate

Use this config:

{
  "packages": [
    "./lib/MjBasicComponent.js",
    "./lib/MjImageText.js",
    "./lib/MjLayout.js"
  ]
}

Screenshot / GIF

Screen Shot 2019-06-26 at 2 26 14 PM

Specifications

  • VS Code version: 1.35.1
  • MJML extension version: 1.6.0
  • Operating system and version: osx 10.14.5

Other information

It actually seems to render fine it just is showing errors in the editor when I don't think it should.

@doolittle
Copy link

@justinmchase I noticed this as well, and found it pretty frustrating.

I think the problem is that MJML is not properly registering dependencies from .mjmlconfig here:

registerDependencies((requiredComp.default || requiredComp).dependencies)

That code is pulling the dependencies object from requiredComp.default (i.e. a static attribute of the default class — default.dependencies, like allowedAttributes), but the boilerplate instructs us to call registerDependencies outside of the class, which would put dependencies on requiredComp — but the above code never gets that far because requiredComp.default exists.

Until this is fixed upstream, it works to just add dependencies as a static object in the default class. You need to restart or reload VSCode to get it to work, but at least it eventually works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants