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

feature: ignore nested node modules #258

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"workspaces": [
"packages/*",
"packages/analyzer/fixtures/11-nested-node-modules/01-basic",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to generate a nested node_modules folder

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I removed the new test case and used the existing one. Annoyingly, the test case (even after I added a node_modules directory) passes on both the old and the new regex. My previous test failed on the old regex, but passed with the new one.

I can investigate further, but again it would probably complicate the repo structure a bit, what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah id prefer not to use the workspaces field for it, it muddies the water a bit

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽 the latest change removes the changes to the workspaces

The PR's ready for review, but I couldn't quite get the 05-external-in-monorepo test case to fail on the previous regex. It passes on both. I can investigate further, but not sure if it's a blocker

"plugins/*"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"schemaVersion": "1.0.0",
"readme": "",
"modules": [
{
"kind": "javascript-module",
"path": "my-element.js",
"declarations": [
{
"kind": "class",
"description": "",
"name": "MyElement",
"members": [
{
"kind": "field",
"name": "foo",
"type": {
"text": "string"
},
"default": "'bar'"
}
],
"superclass": {
"name": "HTMLElement"
},
"tagName": "my-element",
"customElement": true
},
{
"kind": "class",
"description": "",
"name": "MyWindow",
"superclass": {
"name": "HTMLElement"
},
"tagName": "my-window",
"customElement": true
},
{
"kind": "class",
"description": "",
"name": "anonymous_4",
"superclass": {
"name": "HTMLElement"
},
"tagName": "anon-1",
"customElement": true
},
{
"kind": "class",
"description": "",
"name": "MyEl",
"superclass": {
"name": "HTMLElement"
},
"tagName": "anon-2",
"customElement": true
}
],
"exports": [
{
"kind": "custom-element-definition",
"name": "my-foo",
"declaration": {
"name": "MyFoo",
"module": "/foo.js"
}
},
{
"kind": "custom-element-definition",
"name": "my-bar",
"declaration": {
"name": "MyBar",
"package": "foo"
}
},
{
"kind": "custom-element-definition",
"name": "my-element",
"declaration": {
"name": "MyElement",
"module": "my-element.js"
}
},
{
"kind": "custom-element-definition",
"name": "my-window",
"declaration": {
"name": "MyWindow",
"module": "my-element.js"
}
},
{
"kind": "custom-element-definition",
"name": "anon-1",
"declaration": {
"name": "anonymous_4",
"module": "my-element.js"
}
},
{
"kind": "custom-element-definition",
"name": "anon-2",
"declaration": {
"name": "MyEl",
"module": "my-element.js"
}
}
]
}
]
}
112 changes: 112 additions & 0 deletions packages/analyzer/fixtures/11-nested-node-modules/01-basic/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"schemaVersion": "1.0.0",
"readme": "",
"modules": [
{
"kind": "javascript-module",
"path": "my-element.js",
"declarations": [
{
"kind": "class",
"description": "",
"name": "MyElement",
"members": [
{
"kind": "field",
"name": "foo",
"type": {
"text": "string"
},
"default": "'bar'"
}
],
"superclass": {
"name": "HTMLElement"
},
"tagName": "my-element",
"customElement": true
},
{
"kind": "class",
"description": "",
"name": "MyWindow",
"superclass": {
"name": "HTMLElement"
},
"tagName": "my-window",
"customElement": true
},
{
"kind": "class",
"description": "",
"name": "anonymous_4",
"superclass": {
"name": "HTMLElement"
},
"tagName": "anon-1",
"customElement": true
},
{
"kind": "class",
"description": "",
"name": "MyEl",
"superclass": {
"name": "HTMLElement"
},
"tagName": "anon-2",
"customElement": true
}
],
"exports": [
{
"kind": "custom-element-definition",
"name": "my-foo",
"declaration": {
"name": "MyFoo",
"module": "/foo.js"
}
},
{
"kind": "custom-element-definition",
"name": "my-bar",
"declaration": {
"name": "MyBar",
"package": "foo"
}
},
{
"kind": "custom-element-definition",
"name": "my-element",
"declaration": {
"name": "MyElement",
"module": "my-element.js"
}
},
{
"kind": "custom-element-definition",
"name": "my-window",
"declaration": {
"name": "MyWindow",
"module": "my-element.js"
}
},
{
"kind": "custom-element-definition",
"name": "anon-1",
"declaration": {
"name": "anonymous_4",
"module": "my-element.js"
}
},
{
"kind": "custom-element-definition",
"name": "anon-2",
"declaration": {
"name": "MyEl",
"module": "my-element.js"
}
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {MyFoo} from './foo.js';
import {MyBar} from 'foo';

class MyElement extends HTMLElement {
foo = 'bar';
}
class MyWindow extends HTMLElement {}

customElements.define('my-foo', MyFoo);
customElements.define('my-bar', MyBar);
customElements.define('my-element', MyElement);
window.customElements.define('my-window', MyWindow);

customElements.define('anon-1', class extends HTMLElement {});

customElements.define('anon-2', class MyEl extends HTMLElement {});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "nested-node-modules-test",
"version": "0.0.1",
"description": "Used to generate a fixutres with nested node_module",
"author": "open-wc",
"license": "MIT",
"type": "module",
"main": "index.js",
"dependencies": {
"@custom-elements-manifest/to-markdown": "^0.0.13"
}
}
4 changes: 2 additions & 2 deletions packages/analyzer/src/utils/cli-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const require = createRequire(import.meta.url);
const { version } = require('../../package.json');

const IGNORE = [
'!node_modules/**/*.*',
'!**/node_modules/**',
'!bower_components/**/*.*',
'!**/*.test.{js,ts}',
'!**/*.suite.{js,ts}',
Expand Down Expand Up @@ -160,4 +160,4 @@ Available commands:

Examples:
custom-elements-manifest analyze --litelement --globs "**/*.js" --exclude "foo.js" "bar.js"
`
`
46 changes: 2 additions & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1401,19 +1401,6 @@
"@babel/helper-module-imports" "^7.10.4"
"@rollup/pluginutils" "^3.1.0"

"@rollup/plugin-commonjs@^19.0.0":
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why the yarn.lock changed when I installed the dependencies. I can revert these changes if it's a problem

version "19.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-19.0.0.tgz#8c3e71f9a66908e60d70cc1be205834ef3e45f71"
integrity sha512-adTpD6ATGbehdaQoZQ6ipDFhdjqsTgpOAhFiPwl+dzre4pPshsecptDPyEFb61JMJ1+mGljktaC4jI8ARMSNyw==
dependencies:
"@rollup/pluginutils" "^3.1.0"
commondir "^1.0.1"
estree-walker "^2.0.1"
glob "^7.1.6"
is-reference "^1.2.1"
magic-string "^0.25.7"
resolve "^1.17.0"

"@rollup/plugin-node-resolve@^11.0.1":
version "11.2.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz#82aa59397a29cd4e13248b106e6a4a1880362a60"
Expand All @@ -1426,18 +1413,6 @@
is-module "^1.0.0"
resolve "^1.19.0"

"@rollup/plugin-node-resolve@^13.0.0":
version "13.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.0.0.tgz#352f07e430ff377809ec8ec8a6fd636547162dc4"
integrity sha512-41X411HJ3oikIDivT5OKe9EZ6ud6DXudtfNrGbC4nniaxx2esiWjkLOzgnZsWq1IM8YIeL2rzRGLZLBjlhnZtQ==
dependencies:
"@rollup/pluginutils" "^3.1.0"
"@types/resolve" "1.17.1"
builtin-modules "^3.1.0"
deepmerge "^4.2.2"
is-module "^1.0.0"
resolve "^1.19.0"

"@rollup/plugin-replace@^2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-2.4.2.tgz#a2d539314fbc77c244858faa523012825068510a"
Expand Down Expand Up @@ -1534,11 +1509,6 @@
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.6.tgz#0b7018723084918a865eff99249c490505df2163"
integrity sha512-7fDOJFA/x8B+sO1901BmHlf5dE1cxBU8mRXj8QOEDnn16hhGJv/IHxJtZhvsabZsIMn0eLIyeOKAeqSNJJYTpA==

"@types/estree@*":
version "0.0.50"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83"
integrity sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw==

"@types/[email protected]":
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
Expand Down Expand Up @@ -2738,11 +2708,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.2.4.tgz#489f3ee55dfd184a6e4bffb31baba284453cb760"
integrity sha512-pm0b+qv+CkWNriSTMsfnjChF9kH0kxz55y44Wo5le9qLxMj5xDQAaEd9ZN1ovSuk9CsrncWaFwgpOMg7ClJwkw==

commondir@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1"
Expand Down Expand Up @@ -4375,13 +4340,6 @@ is-promise@^2.0.0:
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.2.2.tgz#39ab959ccbf9a774cf079f7b40c7a26f763135f1"
integrity sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==

is-reference@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7"
integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==
dependencies:
"@types/estree" "*"

is-regex@^1.0.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f"
Expand Down Expand Up @@ -6587,7 +6545,7 @@ resolve-path@^1.4.0:
http-errors "~1.6.2"
path-is-absolute "1.0.1"

resolve@^1.1.6, resolve@^1.14.2, resolve@^1.17.0, resolve@^1.19.0:
resolve@^1.1.6, resolve@^1.14.2, resolve@^1.19.0:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
Expand Down Expand Up @@ -6670,7 +6628,7 @@ rollup-plugin-terser@^7.0.2:
serialize-javascript "^4.0.0"
terser "^5.0.0"

rollup@^2.35.1, rollup@^2.52.8:
rollup@^2.35.1:
version "2.53.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.53.1.tgz#b60439efd1eb41bdb56630509bd99aae78b575d3"
integrity sha512-yiTCvcYXZEulNWNlEONOQVlhXA/hgxjelFSjNcrwAAIfYx/xqjSHwqg/cCaWOyFRKr+IQBaXwt723m8tCaIUiw==
Expand Down