Skip to content

Commit a258b7c

Browse files
ameotokoKocal
authored andcommitted
Fix lazy-controller detection when controller contain static properties (update acorn ECMAScript version)
1 parent c50a7a9 commit a258b7c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

dist/webpack/lazy-controller-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5583,7 +5583,7 @@ function getCommentsFromSource(source) {
55835583
parse(source, {
55845584
onComment: comments,
55855585
sourceType: 'module',
5586-
ecmaVersion: 2020,
5586+
ecmaVersion: 2022,
55875587
});
55885588
return comments;
55895589
}

src/util/get-stimulus-comment-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function getCommentsFromSource(source: string) {
2424
parse(source, {
2525
onComment: comments,
2626
sourceType: 'module',
27-
ecmaVersion: 2020,
27+
ecmaVersion: 2022,
2828
});
2929

3030
return comments;

test/util/get-stimulus-comment-options.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,12 @@ describe('getStimulusCommentOptions', () => {
4242
errors: [],
4343
});
4444
});
45+
46+
it('parses source with static properties', () => {
47+
const src = '/* stimulusFetch: "lazy" */ export default class extends Controller { static targets = []; }';
48+
expect(getStimulusCommentOptions(src)).toEqual({
49+
options: { stimulusFetch: 'lazy' },
50+
errors: [],
51+
});
52+
});
4553
});

0 commit comments

Comments
 (0)