custom-elements-manifest
custom-elements-manifest copied to clipboard
Symlinks provided as globs are not working
Checklist
- [x] Did you run the analyzer with the
--dev
flag to get more information? - [x] 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.
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
> [email protected] analyze /Users/luke/src/EvonyTKRTips/packages/web
> cem analyze --litelement "--exclude" "../../../node_modules/.pnpm"
file:///Users/luke/src/EvonyTKRTips/node_modules/.pnpm/@[email protected]/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/[email protected]/node_modules/babel-plugin-template-html-minifier
lrwxr-xr-x 1 luke staff 72 Apr 22 02:21 concurrently -> ../../../node_modules/.pnpm/[email protected]/node_modules/concurrently
lrwxr-xr-x 1 luke staff 52 Apr 22 02:29 d3 -> ../../../node_modules/.pnpm/[email protected]/node_modules/d3
lrwxr-xr-x 1 luke staff 64 Apr 22 02:29 d3-array -> ../../../node_modules/.pnpm/[email protected]/node_modules/d3-array
lrwxr-xr-x 1 luke staff 60 Apr 22 02:29 d3-dsv -> ../../../node_modules/.pnpm/[email protected]/node_modules/d3-dsv
lrwxr-xr-x 1 luke staff 72 Apr 22 02:29 d3-hierarchy -> ../../../node_modules/.pnpm/[email protected]/node_modules/d3-hierarchy
lrwxr-xr-x 1 luke staff 72 Apr 22 02:29 d3-selection -> ../../../node_modules/.pnpm/[email protected]/node_modules/d3-selection
lrwxr-xr-x 1 luke staff 66 Apr 22 02:21 deepmerge -> ../../../node_modules/.pnpm/[email protected]/node_modules/deepmerge
lrwxr-xr-x 1 luke staff 61 Apr 22 02:21 eslint -> ../../../node_modules/.pnpm/[email protected]/node_modules/eslint
lrwxr-xr-x 1 luke staff 106 Apr 22 02:21 eslint-config-prettier -> ../../../node_modules/.pnpm/[email protected][email protected]/node_modules/eslint-config-prettier
lrwxr-xr-x 1 luke staff 58 Apr 22 02:21 husky -> ../../../node_modules/.pnpm/[email protected]/node_modules/husky
lrwxr-xr-x 1 luke staff 71 Apr 22 02:50 lint-staged -> ../../../node_modules/.pnpm/[email protected]/node_modules/lint-staged
lrwxr-xr-x 1 luke staff 54 Apr 22 02:21 lit -> ../../../node_modules/.pnpm/[email protected]/node_modules/lit
lrwxr-xr-x 1 luke staff 64 Apr 22 02:21 prettier -> ../../../node_modules/.pnpm/[email protected]/node_modules/prettier
lrwxr-xr-x 1 luke staff 60 Apr 22 02:21 rimraf -> ../../../node_modules/.pnpm/[email protected]/node_modules/rimraf
lrwxr-xr-x 1 luke staff 61 Apr 22 02:21 rollup -> ../../../node_modules/.pnpm/[email protected]/node_modules/rollup
lrwxr-xr-x 1 luke staff 120 Apr 22 02:21 rollup-plugin-esbuild -> ../../../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/rollup-plugin-esbuild
lrwxr-xr-x 1 luke staff 102 Apr 22 02:31 rollup-plugin-styles -> ../../../node_modules/.pnpm/[email protected][email protected]/node_modules/rollup-plugin-styles
lrwxr-xr-x 1 luke staff 110 Apr 22 02:31 rollup-plugin-visualizer -> ../../../node_modules/.pnpm/[email protected][email protected]/node_modules/rollup-plugin-visualizer
lrwxr-xr-x 1 luke staff 104 Apr 22 02:21 rollup-plugin-workbox -> ../../../node_modules/.pnpm/[email protected][email protected]/node_modules/rollup-plugin-workbox
lrwxr-xr-x 1 luke staff 58 Apr 22 02:21 tslib -> ../../../node_modules/.pnpm/[email protected]/node_modules/tslib
lrwxr-xr-x 1 luke staff 68 Apr 22 02:31 typescript -> ../../../node_modules/.pnpm/[email protected]/node_modules/typescript
lrwxr-xr-x 1 luke staff 62 Apr 22 02:29 zero-md -> ../../../node_modules/.pnpm/[email protected]/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.