Skip to content

Commit 296f83c

Browse files
authored
Merge pull request #104 from open-wc/fix/comment-parser
fix: comment parser
2 parents e6b824a + 1a39aef commit 296f83c

File tree

8 files changed

+16
-20
lines changed

8 files changed

+16
-20
lines changed

packages/analyzer/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Release 0.4.14
2+
- Fix comment-parser dependency
3+
14
## Release 0.4.13
25
- Add support for class expressions in `customElements.define` calls, e.g.: `customElements.define('m-e', class extends HTMLElement{})`
36
- Fixed bug in lit-plugin to avoid duplicate attributes

packages/analyzer/browser/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/analyzer/demo/browser/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
<script type="module">
66
import {ts, create} from '../../browser/index.js';
77

8-
const code = `export class MyEl extends HTMLElement {
8+
const code = `
9+
/**
10+
* @prop {string} name - The name of the person.
11+
*/
12+
export class MyEl extends HTMLElement {
913
/**
1014
* @attr
1115
*/

packages/analyzer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@web/config-loader": "^0.1.3",
4242
"chokidar": "^3.5.2",
4343
"command-line-args": "^5.1.2",
44-
"comment-parser": "^1.1.5",
44+
"comment-parser": "^1.2.0",
4545
"custom-elements-manifest": "^1.0.0",
4646
"debounce": "^1.2.1",
4747
"globby": "^11.0.4",

packages/analyzer/rollup.browser.config.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import resolve from '@rollup/plugin-node-resolve';
22
import commonjs from '@rollup/plugin-commonjs';
33
import {terser} from 'rollup-plugin-terser';
4-
const commentParser = require.resolve('comment-parser');
54

65
const IGNORE = [
76
'perf_hooks',
@@ -25,16 +24,6 @@ export default [
2524
commonjs({
2625
ignore: (id) => IGNORE.includes(id),
2726
}),
28-
{
29-
load(id) {
30-
if (id === commentParser) {
31-
return `
32-
import { parse } from 'comment-parser/es6/index.js'
33-
export default { parse: parse };
34-
`;
35-
}
36-
}
37-
},
3827
resolve(),
3928
terser()
4029
],

packages/analyzer/src/features/analyse-phase/class-jsdoc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import parse from 'comment-parser';
1+
import { parse } from 'comment-parser';
22
import { handleJsDocType, normalizeDescription } from '../../utils/jsdoc.js';
33
import { safe } from '../../utils/index.js';
44

@@ -25,7 +25,7 @@ export function classJsDocPlugin() {
2525
* Checks to see if the item is already in the classDoc, and if so merge and overwrite (JSDoc takes precedence)
2626
*/
2727
node?.jsDoc?.forEach(jsDoc => {
28-
const parsed = parse.parse(jsDoc?.getFullText());
28+
const parsed = parse(jsDoc?.getFullText());
2929
parsed?.forEach(parsedJsDoc => {
3030

3131
/**

packages/analyzer/src/features/analyse-phase/creators/createClass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createFunctionLike } from './createFunctionLike.js';
33
import { createAttribute, createAttributeFromField } from './createAttribute.js';
44
import { createField } from './createClassField.js';
55
import { handleHeritage, handleJsDoc, handleAttrJsDoc, handleTypeInference, handleDefaultValue } from './handlers.js';
6-
import { hasAttrAnnotation, hasIgnoreJSDoc, isDispatchEvent, isPrimitive, isProperty, isReturnStatement, isStaticMember } from '../../../utils/ast-helpers.js';
6+
import { hasAttrAnnotation, hasIgnoreJSDoc, isDispatchEvent, isProperty, isReturnStatement } from '../../../utils/ast-helpers.js';
77
import { resolveModuleOrPackageSpecifier } from '../../../utils/index.js';
88

99

packages/analyzer/src/features/analyse-phase/creators/handlers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import ts from 'typescript';
2-
import parse from 'comment-parser';
2+
import { parse } from 'comment-parser';
33

44
import { has, resolveModuleOrPackageSpecifier, safe } from '../../../utils/index.js';
55
import { handleJsDocType, normalizeDescription } from '../../../utils/jsdoc.js';
6-
import { isPrimitive, isWellKnownType } from '../../../utils/ast-helpers.js';
6+
import { isWellKnownType } from '../../../utils/ast-helpers.js';
77

88
/**
99
* @example static foo;
@@ -197,7 +197,7 @@ export function handleHeritage(classTemplate, moduleDoc, context, node) {
197197
*/
198198
export function handleAttrJsDoc(node, doc) {
199199
node?.jsDoc?.forEach(jsDoc => {
200-
const docs = parse.parse(jsDoc?.getFullText())?.find(doc => doc?.tags?.some(({tag}) => tag === 'attr'));
200+
const docs = parse(jsDoc?.getFullText())?.find(doc => doc?.tags?.some(({tag}) => tag === 'attr'));
201201
const attrTag = docs?.tags?.find(({tag}) => tag === 'attr');
202202

203203
if(attrTag?.name) {

0 commit comments

Comments
 (0)