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

Fails to get dependency information if using an import alias #214

Open
1 of 2 tasks
matteematt opened this issue May 19, 2023 · 2 comments
Open
1 of 2 tasks

Fails to get dependency information if using an import alias #214

matteematt opened this issue May 19, 2023 · 2 comments

Comments

@matteematt
Copy link
Contributor

matteematt commented May 19, 2023

Checklist

  • Did you run the analyzer with the --dev flag to get more information?
  • Did you create a minimal reproduction in the playground? - It isn't possible to recreate this issue in the playground as it is quite complicated. See below

Apologies because this is quite compliated

Abstract: cem analyzer does not correctly find the package dependency of an import if it is aliased upon import

Basic Example

Lib code:

export class Avatar extends FoundationElement {
   @attr title = 'default title';
}

This will produce the following in the cem manifest:

...
            {
              "name": "title",
              "type": {
                "text": "string"
              },
              "fieldName": "title"
            },
...

App code:

import {Avatar as BaseAvatar } from 'test-lib';

export class Avatar extends BaseAvatar {
   @attr avatar = ':)';
}

In this case we expect the manifest from the library to be picked up and add the title attribute with an inherited from. But it seems to not pick it up. However if we change the app code to:

import {Avatar } from 'test-lib';

export class AvatarTwo extends Avatar {
   @attr avatar = ':)';
}

This does work as a workaround.

Real Example

  1. I have a fork of microsoft fast here in which I am setitng up the manifest for a deprecated library.
  2. it contains a base class called button which is generated in a manifest (exporting attributes such as autofocus
  3. there is a seperate package that also defines a button class, which extends the button from the above link and uses a type alias to avoid a name clash
  4. The output manifest only contains the attribute for the button subclass
  5. I then do a commit which removes the type alias import
  6. Observe that the attributes are now pulled in from the superclass in the manifest (You will need to expand the large manifest file to see my linked line, github collapses the manifest by default)

Notes

I can't recreate this in the playground as this is an issue with the interaction between the analyzer and a package that contains a manifest. Using an import alias in the same package is no issue, and therefore I cannot recreate it in the playground

@matteematt
Copy link
Contributor Author

Hi. It has been a few month since I raised this, any movement or investigation? Cheers

@matteematt
Copy link
Contributor Author

I ended up writing a plugin that lets you work around for this https://www.npmjs.com/package/@genesiscommunitysuccess/analyzer-import-alias-plugin

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

No branches or pull requests

1 participant