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

Symlinks provided as globs are not working #172

Open
2 tasks done
sonntag-philipp opened this issue May 8, 2022 · 1 comment
Open
2 tasks done

Symlinks provided as globs are not working #172

sonntag-philipp opened this issue May 8, 2022 · 1 comment

Comments

@sonntag-philipp
Copy link

sonntag-philipp commented May 8, 2022

Checklist

  • Did you run the analyzer with the --dev flag to get more information?
  • Did you create a minimal reproduction in the playground?

Hello there,

at first, thank you for this project. It did a really good job for me in the past and I hope to see it having a good future :)

I noticed some flaws while using symlinks within the provided globs. The analyzer seems to ignore symlinks, e.g. the ones used by pnpm. A minimal demo project is located here - I'm afraid I wasn't able to simulate this error on the Nelify playground but I think the repository should help.
You can install the dependencies using pnpm install. After that, a working script which doesn't use symlinks and a malfunctioning script which uses symlinks that analyze the same files are provided in the packages/analyze-project .

At a first look I thought this had something to do with Chokidar, but it seems that they have an followSymlinks option activated by default. So I don't really know what to look for now. If you have any ideas on how this can be fixed - I'm happy to help :)

Working manifest

[COLLECT PHASE]:  ../custom-elements/my-counter.ts
[ANALYZE PHASE]:  ../custom-elements/my-counter.ts
[MODULE LINK PHASE]:  ../custom-elements/my-counter.ts
[PACKAGE LINK PHASE]
{
  "schemaVersion": "1.0.0",
  "readme": "",
  "modules": [
    {
      "kind": "javascript-module",
      "path": "../custom-elements/my-counter.ts",
      "declarations": [
        {
          "kind": "class",
          "description": "\r\nCustom element copied from https://webcomponents.dev\r\nhttps://webcomponents.dev/edit/cbsc5Dn005PCusmFZ6MQ/package.json?p=stories",          "name": "SimpleGreeting",
          "members": [
            {
              "kind": "field",
              "name": "count",
              "type": {
                "text": "number"
              },
              "privacy": "public",
              "default": "0",
              "attribute": "count"
            },
            {
              "kind": "method",
              "name": "inc"
            },
            {
              "kind": "method",
              "name": "dec"
            }
          ],
          "attributes": [
            {
              "name": "count",
              "type": {
                "text": "number"
              },
              "default": "0",
              "fieldName": "count"
            }
          ],
          "superclass": {
            "name": "LitElement",
            "package": "lit"
          },
          "tagName": "my-counter",
          "customElement": true
        }
      ],
      "exports": [
        {
          "kind": "js",
          "name": "SimpleGreeting",
          "declaration": {
            "name": "SimpleGreeting",
            "module": "../custom-elements/my-counter.ts"
          }
        },
        {
          "kind": "custom-element-definition",
          "name": "my-counter",
          "declaration": {
            "name": "SimpleGreeting",
            "module": "../custom-elements/my-counter.ts"
          }
        }
      ]
    }
  ]
}
[23:13:11] @custom-elements-manifest/analyzer: Created new manifest.

Not working manifest

[PACKAGE LINK PHASE]
{
  "schemaVersion": "1.0.0",
  "readme": "",
  "modules": []
}
[23:28:44] @custom-elements-manifest/analyzer: Created new manifest.
@lschierer
Copy link

I hit this by working in a repository that was using pnpm workspaces, such that I have multiple node_module directories and some packages in the children are symlinks to the root level node_modules, with the symlinks managed by pnpm.
I was running the analyze command from one of the subdirectories.

The error I get is

officium:web luke$ pnpm run analyze --exclude ../../../node_modules/.pnpm

> evony-tips@0.0.0 analyze /Users/luke/src/EvonyTKRTips/packages/web
> cem analyze --litelement "--exclude" "../../../node_modules/.pnpm"

file:///Users/luke/src/EvonyTKRTips/node_modules/.pnpm/@custom-elements-manifest+analyzer@0.4.17/node_modules/@custom-elements-manifest/analyzer/src/utils/index.js:67
    throw new Error(`\n\n[${name ?? 'unnamed-plugin'}]: ${errorMessage}\n\n ${e.stack}\n`);
          ^

and the node_modules directory looks like

officium:web luke$ ls -l node_modules/
total 0
drwxr-xr-x   3 luke  staff   96 Apr 22 02:21 @babel
drwxr-xr-x   3 luke  staff   96 Apr 22 02:21 @custom-elements-manifest
drwxr-xr-x   5 luke  staff  160 Apr 22 02:50 @open-wc
drwxr-xr-x   4 luke  staff  128 Apr 22 02:21 @rollup
drwxr-xr-x   5 luke  staff  160 Apr 22 02:26 @spectrum-css
drwxr-xr-x  19 luke  staff  608 Apr 22 02:29 @spectrum-web-components
drwxr-xr-x   9 luke  staff  288 Apr 22 02:51 @types
drwxr-xr-x   4 luke  staff  128 Apr 22 02:31 @typescript-eslint
drwxr-xr-x   6 luke  staff  192 Apr 22 02:31 @web
drwxr-xr-x   3 luke  staff   96 Apr 22 02:31 @webcomponents
lrwxr-xr-x   1 luke  staff  118 Apr 22 02:21 babel-plugin-template-html-minifier -> ../../../node_modules/.pnpm/babel-plugin-template-html-minifier@4.1.0/node_modules/babel-plugin-template-html-minifier
lrwxr-xr-x   1 luke  staff   72 Apr 22 02:21 concurrently -> ../../../node_modules/.pnpm/concurrently@5.3.0/node_modules/concurrently
lrwxr-xr-x   1 luke  staff   52 Apr 22 02:29 d3 -> ../../../node_modules/.pnpm/d3@7.8.4/node_modules/d3
lrwxr-xr-x   1 luke  staff   64 Apr 22 02:29 d3-array -> ../../../node_modules/.pnpm/d3-array@3.2.3/node_modules/d3-array
lrwxr-xr-x   1 luke  staff   60 Apr 22 02:29 d3-dsv -> ../../../node_modules/.pnpm/d3-dsv@3.0.1/node_modules/d3-dsv
lrwxr-xr-x   1 luke  staff   72 Apr 22 02:29 d3-hierarchy -> ../../../node_modules/.pnpm/d3-hierarchy@3.1.2/node_modules/d3-hierarchy
lrwxr-xr-x   1 luke  staff   72 Apr 22 02:29 d3-selection -> ../../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection
lrwxr-xr-x   1 luke  staff   66 Apr 22 02:21 deepmerge -> ../../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge
lrwxr-xr-x   1 luke  staff   61 Apr 22 02:21 eslint -> ../../../node_modules/.pnpm/eslint@8.39.0/node_modules/eslint
lrwxr-xr-x   1 luke  staff  106 Apr 22 02:21 eslint-config-prettier -> ../../../node_modules/.pnpm/eslint-config-prettier@8.8.0_eslint@8.39.0/node_modules/eslint-config-prettier
lrwxr-xr-x   1 luke  staff   58 Apr 22 02:21 husky -> ../../../node_modules/.pnpm/husky@4.3.8/node_modules/husky
lrwxr-xr-x   1 luke  staff   71 Apr 22 02:50 lint-staged -> ../../../node_modules/.pnpm/lint-staged@13.2.1/node_modules/lint-staged
lrwxr-xr-x   1 luke  staff   54 Apr 22 02:21 lit -> ../../../node_modules/.pnpm/lit@2.7.2/node_modules/lit
lrwxr-xr-x   1 luke  staff   64 Apr 22 02:21 prettier -> ../../../node_modules/.pnpm/prettier@2.8.7/node_modules/prettier
lrwxr-xr-x   1 luke  staff   60 Apr 22 02:21 rimraf -> ../../../node_modules/.pnpm/rimraf@3.0.2/node_modules/rimraf
lrwxr-xr-x   1 luke  staff   61 Apr 22 02:21 rollup -> ../../../node_modules/.pnpm/rollup@2.79.1/node_modules/rollup
lrwxr-xr-x   1 luke  staff  120 Apr 22 02:21 rollup-plugin-esbuild -> ../../../node_modules/.pnpm/rollup-plugin-esbuild@5.0.0_esbuild@0.17.17_rollup@2.79.1/node_modules/rollup-plugin-esbuild
lrwxr-xr-x   1 luke  staff  102 Apr 22 02:31 rollup-plugin-styles -> ../../../node_modules/.pnpm/rollup-plugin-styles@4.0.0_rollup@2.79.1/node_modules/rollup-plugin-styles
lrwxr-xr-x   1 luke  staff  110 Apr 22 02:31 rollup-plugin-visualizer -> ../../../node_modules/.pnpm/rollup-plugin-visualizer@5.9.0_rollup@2.79.1/node_modules/rollup-plugin-visualizer
lrwxr-xr-x   1 luke  staff  104 Apr 22 02:21 rollup-plugin-workbox -> ../../../node_modules/.pnpm/rollup-plugin-workbox@6.2.2_rollup@2.79.1/node_modules/rollup-plugin-workbox
lrwxr-xr-x   1 luke  staff   58 Apr 22 02:21 tslib -> ../../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib
lrwxr-xr-x   1 luke  staff   68 Apr 22 02:31 typescript -> ../../../node_modules/.pnpm/typescript@5.0.4/node_modules/typescript
lrwxr-xr-x   1 luke  staff   62 Apr 22 02:29 zero-md -> ../../../node_modules/.pnpm/zero-md@2.4.0/node_modules/zero-md
officium:web luke$ 

notice that the module it is failing on is because is because while it may exclude the current directory's node_module directory, it doesn't exclude the files that are in ../../../node_modules/.pnpm/ though it has expanded that out to a full path, so it took me a few minutes to realize what is going on.

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

2 participants