@@ -21,8 +21,8 @@ const noLeadingCommentError = 'dynamic imports require a leading comment with th
2121const nonBlockCommentError = 'dynamic imports require a /* foo */ style comment, not a // foo comment'
2222const noPaddingCommentError = 'dynamic imports require a block comment padded with spaces - /* foo */'
2323const 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 } ["'] ,? */`
2626
2727ruleTester . run ( 'dynamic-import-chunkname' , rule , {
2828 valid : [
@@ -132,6 +132,14 @@ ruleTester.run('dynamic-import-chunkname', rule, {
132132 options,
133133 parser,
134134 } ,
135+ {
136+ code : `import(
137+ /* webpackChunkName: 'someModule' */
138+ 'someModule'
139+ )` ,
140+ options,
141+ parser,
142+ } ,
135143 {
136144 code : `import(
137145 /* webpackChunkName: "someModule" */
@@ -192,17 +200,33 @@ ruleTester.run('dynamic-import-chunkname', rule, {
192200 } ,
193201 {
194202 code : `import(
195- /* webpackChunkName: ' someModule' */
203+ /* webpackChunkName: " someModule' */
196204 'someModule'
197205 )` ,
198206 options,
199207 parser,
200208 output : `import(
201- /* webpackChunkName: ' someModule' */
209+ /* webpackChunkName: " someModule' */
202210 'someModule'
203211 )` ,
204212 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 ,
206230 type : 'CallExpression' ,
207231 } ] ,
208232 } ,
@@ -421,21 +445,6 @@ ruleTester.run('dynamic-import-chunkname', rule, {
421445 type : 'CallExpression' ,
422446 } ] ,
423447 } ,
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- } ,
439448 {
440449 code : `dynamicImport(
441450 /* webpackChunkName "someModule" */
@@ -578,6 +587,14 @@ context('TypeScript', () => {
578587 type : nodeType ,
579588 } ] ,
580589 } ,
590+ {
591+ code : `import(
592+ /* webpackChunkName: 'someModule' */
593+ 'test'
594+ )` ,
595+ options,
596+ parser : typescriptParser ,
597+ } ,
581598 ] ,
582599 invalid : [
583600 {
@@ -624,17 +641,33 @@ context('TypeScript', () => {
624641 } ,
625642 {
626643 code : `import(
627- /* webpackChunkName: ' someModule' */
644+ /* webpackChunkName " someModule' */
628645 'someModule'
629646 )` ,
630647 options,
631648 parser : typescriptParser ,
632649 output : `import(
633- /* webpackChunkName: ' someModule' */
650+ /* webpackChunkName " someModule' */
634651 'someModule'
635652 )` ,
636653 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 ,
638671 type : nodeType ,
639672 } ] ,
640673 } ,
0 commit comments