@@ -21,8 +21,8 @@ const noLeadingCommentError = 'dynamic imports require a leading comment with th
21
21
const nonBlockCommentError = 'dynamic imports require a /* foo */ style comment, not a // foo comment'
22
22
const noPaddingCommentError = 'dynamic imports require a block comment padded with spaces - /* foo */'
23
23
const invalidSyntaxCommentError = 'dynamic imports require a "webpack" comment with valid syntax'
24
- const commentFormatError = `dynamic imports require a leading comment in the form /* webpackChunkName: " ${ commentFormat } " ,? */`
25
- const pickyCommentFormatError = `dynamic imports require a leading comment in the form /* webpackChunkName: " ${ pickyCommentFormat } " ,? */`
24
+ const commentFormatError = `dynamic imports require a leading comment in the form /* webpackChunkName: ["'] ${ commentFormat } ["'] ,? */`
25
+ const pickyCommentFormatError = `dynamic imports require a leading comment in the form /* webpackChunkName: ["'] ${ pickyCommentFormat } ["'] ,? */`
26
26
27
27
ruleTester . run ( 'dynamic-import-chunkname' , rule , {
28
28
valid : [
@@ -132,6 +132,14 @@ ruleTester.run('dynamic-import-chunkname', rule, {
132
132
options,
133
133
parser,
134
134
} ,
135
+ {
136
+ code : `import(
137
+ /* webpackChunkName: 'someModule' */
138
+ 'someModule'
139
+ )` ,
140
+ options,
141
+ parser,
142
+ } ,
135
143
{
136
144
code : `import(
137
145
/* webpackChunkName: "someModule" */
@@ -192,17 +200,33 @@ ruleTester.run('dynamic-import-chunkname', rule, {
192
200
} ,
193
201
{
194
202
code : `import(
195
- /* webpackChunkName: ' someModule' */
203
+ /* webpackChunkName: " someModule' */
196
204
'someModule'
197
205
)` ,
198
206
options,
199
207
parser,
200
208
output : `import(
201
- /* webpackChunkName: ' someModule' */
209
+ /* webpackChunkName: " someModule' */
202
210
'someModule'
203
211
)` ,
204
212
errors : [ {
205
- message : commentFormatError ,
213
+ message : invalidSyntaxCommentError ,
214
+ type : 'CallExpression' ,
215
+ } ] ,
216
+ } ,
217
+ {
218
+ code : `import(
219
+ /* webpackChunkName: 'someModule" */
220
+ 'someModule'
221
+ )` ,
222
+ options,
223
+ parser,
224
+ output : `import(
225
+ /* webpackChunkName: 'someModule" */
226
+ 'someModule'
227
+ )` ,
228
+ errors : [ {
229
+ message : invalidSyntaxCommentError ,
206
230
type : 'CallExpression' ,
207
231
} ] ,
208
232
} ,
@@ -421,21 +445,6 @@ ruleTester.run('dynamic-import-chunkname', rule, {
421
445
type : 'CallExpression' ,
422
446
} ] ,
423
447
} ,
424
- {
425
- code : `dynamicImport(
426
- /* webpackChunkName: 'someModule' */
427
- 'someModule'
428
- )` ,
429
- options,
430
- output : `dynamicImport(
431
- /* webpackChunkName: 'someModule' */
432
- 'someModule'
433
- )` ,
434
- errors : [ {
435
- message : commentFormatError ,
436
- type : 'CallExpression' ,
437
- } ] ,
438
- } ,
439
448
{
440
449
code : `dynamicImport(
441
450
/* webpackChunkName "someModule" */
@@ -578,6 +587,14 @@ context('TypeScript', () => {
578
587
type : nodeType ,
579
588
} ] ,
580
589
} ,
590
+ {
591
+ code : `import(
592
+ /* webpackChunkName: 'someModule' */
593
+ 'test'
594
+ )` ,
595
+ options,
596
+ parser : typescriptParser ,
597
+ } ,
581
598
] ,
582
599
invalid : [
583
600
{
@@ -624,17 +641,33 @@ context('TypeScript', () => {
624
641
} ,
625
642
{
626
643
code : `import(
627
- /* webpackChunkName: ' someModule' */
644
+ /* webpackChunkName " someModule' */
628
645
'someModule'
629
646
)` ,
630
647
options,
631
648
parser : typescriptParser ,
632
649
output : `import(
633
- /* webpackChunkName: ' someModule' */
650
+ /* webpackChunkName " someModule' */
634
651
'someModule'
635
652
)` ,
636
653
errors : [ {
637
- message : commentFormatError ,
654
+ message : invalidSyntaxCommentError ,
655
+ type : nodeType ,
656
+ } ] ,
657
+ } ,
658
+ {
659
+ code : `import(
660
+ /* webpackChunkName 'someModule" */
661
+ 'someModule'
662
+ )` ,
663
+ options,
664
+ parser : typescriptParser ,
665
+ output : `import(
666
+ /* webpackChunkName 'someModule" */
667
+ 'someModule'
668
+ )` ,
669
+ errors : [ {
670
+ message : invalidSyntaxCommentError ,
638
671
type : nodeType ,
639
672
} ] ,
640
673
} ,
0 commit comments