Skip to content

Commit c99ff74

Browse files
authored
Feat/update ts 5.4.2 (open-wc#244)
* feat: update ts to version 4.9 * chore: yarn lock * chore: update ts to 5.4.2 and update browser build
1 parent cf56660 commit c99ff74

File tree

17 files changed

+205703
-78
lines changed

17 files changed

+205703
-78
lines changed

package.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,12 @@
2222
"@rocket/cli": "^0.9.6",
2323
"@rocket/launch": "^0.5.3",
2424
"@rocket/search": "^0.4.0",
25-
"@rollup/plugin-commonjs": "^19.0.0",
26-
"@rollup/plugin-node-resolve": "^13.0.0",
27-
"@rollup/plugin-replace": "^2.4.2",
2825
"custom-elements-manifest": "^1.0.0",
29-
"esbuild": "^0.12.15",
26+
"esbuild": "^0.20.2",
3027
"globby": "^12.0.2",
3128
"nodemon": "^2.0.13",
3229
"request": "^2.88.2",
3330
"rocket-preset-code-tabs": "^0.2.2",
34-
"rollup": "^2.52.8",
35-
"rollup-plugin-terser": "^7.0.2",
3631
"watchexec-bin": "^1.0.0"
3732
},
3833
"workspaces": [

packages/analyzer/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Release 0.9.4
2+
- Updated the internally used TS version to `~5.4.2`. This is a breaking change for plugin authors, because the AST that typescript exposes has changed; specifically for decorators; `node.decorators` no longer exists, but decorators can now be found in `node.modifiers`. There may be other AST changes as well.
3+
14
## Release 0.9.3
25
- Fix missing type for `initialize` hook
36

packages/analyzer/browser/index.js

+205,528-15
Large diffs are not rendered by default.

packages/analyzer/fixtures/07-plugin-lit/01-basic/fixture/custom-elements.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
},
196196
{
197197
"kind": "mixin",
198-
"description": "Picks up @property decorator on mixins as well",
198+
"description": "Picks up property decorator on mixins as well",
199199
"name": "InputMixin",
200200
"members": [
201201
{

packages/analyzer/fixtures/07-plugin-lit/01-basic/output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
},
196196
{
197197
"kind": "mixin",
198-
"description": "Picks up @property decorator on mixins as well",
198+
"description": "Picks up property decorator on mixins as well",
199199
"name": "InputMixin",
200200
"members": [
201201
{

packages/analyzer/fixtures/07-plugin-lit/01-basic/package/my-element.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class MyElement extends LitElement {
5353
}
5454

5555
/**
56-
* Picks up @property decorator on mixins as well
56+
* Picks up property decorator on mixins as well
5757
*/
5858
export function InputMixin(superClass) {
5959
class InputElement extends superClass {

packages/analyzer/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@custom-elements-manifest/analyzer",
3-
"version": "0.9.3",
3+
"version": "0.9.4",
44
"description": "",
55
"license": "MIT",
66
"type": "module",
@@ -24,7 +24,7 @@
2424
"prepublishOnly": "npm test && npm run build:browser",
2525
"start": "nodemon --ignore './custom-elements.json' cem.js analyze --dev --fast",
2626
"test": "asdgf",
27-
"build:browser": "rollup -c rollup.browser.config.js",
27+
"build:browser": "esbuild src/browser-entrypoint.js --bundle --format=esm --outfile=browser/index.js",
2828
"test:watch": "watchexec -w src -w test npm test",
2929
"update-fixtures": "node scripts/update-version.js --version 1.0.0"
3030
},
@@ -47,7 +47,7 @@
4747
"custom-elements-manifest": "1.0.0",
4848
"debounce": "1.2.1",
4949
"globby": "11.0.4",
50-
"typescript": "~4.3.2"
50+
"typescript": "~5.4.2"
5151
},
5252
"devDependencies": {},
5353
"contributors": [

packages/analyzer/rollup.browser.config.js

-31
This file was deleted.

packages/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function controllerPlugin() {
99
/**
1010
* handle @controller
1111
*/
12-
const hasController = node?.decorators?.find(decorator('controller'));
12+
const hasController = node?.modifiers?.find(decorator('controller'));
1313

1414
if(hasController) {
1515
const className = node?.name?.getText();

packages/analyzer/src/features/framework-plugins/catalyst/controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function controllerPlugin() {
99
/**
1010
* handle @controller
1111
*/
12-
const hasController = node?.decorators?.find(decorator('controller'));
12+
const hasController = node?.modifiers?.find(decorator('controller'));
1313

1414
if(hasController) {
1515
const className = node?.name?.getText();

packages/analyzer/src/features/framework-plugins/decorators/attr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function attrDecoratorPlugin(converter) {
1515
* If a field has the @attr decorator, create an attr from the field in the classDoc
1616
*/
1717
node?.members?.forEach(member => {
18-
const hasAttrDecorator = member?.decorators?.find(decorator('attr'));
18+
const hasAttrDecorator = member?.modifiers?.find(decorator('attr'));
1919
if(hasAttrDecorator) {
2020
const correspondingField = classDoc?.members?.find(classMember => classMember.name === member.name.getText());
2121

packages/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export function customElementDecoratorPlugin() {
1111
return {
1212
name: 'CORE - CUSTOM-ELEMENT-DECORATOR',
1313
analyzePhase({node, moduleDoc, context}){
14-
if(has(node.decorators)) {
15-
const customElementDecorator = node.decorators?.find(decorator('customElement'));
14+
if (has(node.modifiers)) {
15+
const customElementDecorator = node.modifiers?.find(decorator('customElement'));
1616

1717
if(customElementDecorator) {
1818
const className = node.name.text;
@@ -27,7 +27,6 @@ export function customElementDecoratorPlugin() {
2727
},
2828
};
2929

30-
3130
moduleDoc.exports = [...(moduleDoc.exports || []), definitionDoc];
3231
}
3332
}

packages/analyzer/src/features/framework-plugins/lit/property-decorator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function handlePropertyDecorator(classNode, moduleDoc, mixinName = null) {
4949
*/
5050
classNode?.members?.forEach(member => {
5151
if (hasPropertyDecorator(member)) {
52-
const propertyDecorator = member.decorators.find(decorator('property'));
52+
const propertyDecorator = member.modifiers.find(decorator('property'));
5353
const propertyOptions = propertyDecorator?.expression?.arguments?.find(arg => ts.isObjectLiteralExpression(arg));
5454

5555
/**

packages/analyzer/src/features/framework-plugins/lit/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function getAttributeName(node) {
5050
}
5151

5252
export function hasPropertyDecorator(node) {
53-
return node?.decorators?.some((decorator) => {
53+
return node?.modifiers?.some((decorator) => {
5454
return ts.isDecorator(decorator) && decorator?.expression?.expression?.getText() === 'property'
5555
});
5656
}

packages/analyzer/src/features/framework-plugins/stencil/stencil.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function stencilPlugin() {
1515
* Add tagName to classDoc, extracted from `@Component({tag: 'foo-bar'})` decorator
1616
* Add custom-element-definition to exports
1717
*/
18-
const componentDecorator = node?.decorators?.find(decorator('Component'))?.expression;
18+
const componentDecorator = node?.modifiers?.find(decorator('Component'))?.expression;
1919

2020
const tagName = componentDecorator?.arguments?.[0]?.properties?.find(prop => {
2121
return prop?.name?.getText() === 'tag'
@@ -39,9 +39,9 @@ export function stencilPlugin() {
3939
* Collect fields with `@Event()` decorator so we can process them in `moduleLinkPhase`
4040
*/
4141
const eventFields = node?.members
42-
?.filter(member => member?.decorators?.find(decorator('Event')))
42+
?.filter(member => member?.modifiers?.find(decorator('Event')))
4343
?.map(member => {
44-
const eventDecorator = member?.decorators?.find(decorator('Event'));
44+
const eventDecorator = member?.modifiers?.find(decorator('Event'));
4545
const eventName = eventDecorator?.expression?.arguments?.[0]?.properties?.find(prop => {
4646
return prop?.name?.getText() === 'eventName'
4747
})?.initializer?.text;
@@ -58,13 +58,13 @@ export function stencilPlugin() {
5858
* - add fieldName to attr
5959
*/
6060
node?.members
61-
?.filter(member => member?.decorators?.find(decorator('Prop')))
61+
?.filter(member => member?.modifiers?.find(decorator('Prop')))
6262
?.forEach(property => {
6363
const fieldName = property?.name?.text;
64-
const attrNameFromDecorator = property?.decorators?.[0]?.expression?.arguments?.[0]?.properties?.find(prop => prop?.name?.getText() === 'attribute')?.initializer?.text;
64+
const attrNameFromDecorator = property?.modifiers?.[0]?.expression?.arguments?.[0]?.properties?.find(prop => prop?.name?.getText() === 'attribute')?.initializer?.text;
6565
const attrName = attrNameFromDecorator || toKebabCase(property?.name?.text);
6666

67-
const reflects = property?.decorators?.[0]?.expression?.arguments?.[0]?.properties?.find(prop => prop?.name?.getText() === 'reflects')?.initializer?.getText?.() === 'true';
67+
const reflects = property?.modifiers?.[0]?.expression?.arguments?.[0]?.properties?.find(prop => prop?.name?.getText() === 'reflects')?.initializer?.getText?.() === 'true';
6868
const member = currClass?.members?.find(mem => mem?.name === fieldName);
6969
if(reflects) {
7070
member.reflects = true;

packages/analyzer/src/utils/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import ts from 'typescript';
2+
13
/**
24
* GENERAL UTILITIES
35
*/
46

57
export const has = arr => Array.isArray(arr) && arr.length > 0;
68

79
/**
8-
* @example node?.decorators?.find(decorator('Component'))
10+
* @example node?.modifiers?.find(decorator('Component'))
911
*/
10-
export const decorator = type => decorator => decorator?.expression?.expression?.getText() === type || decorator?.expression?.getText() === type;
12+
export const decorator = type => decorator => ts.isDecorator(decorator) && decorator?.expression?.expression?.getText() === type || decorator?.expression?.getText() === type;
1113

1214
export function isBareModuleSpecifier(specifier) {
1315
return !!specifier?.replace(/'/g, '')[0].match(/[@a-zA-Z]/g);

0 commit comments

Comments
 (0)