@@ -353,36 +353,35 @@ function generateDefaultExportDts(
353353 * The mapping is created as follows:
354354 * a.module.css:
355355 * 1 | @value b_1, b_2 from './b.module.css';
356- * | ^ ^ ^ mapping.sourceOffsets[1 ]
357- * | ^ ^ mapping.sourceOffsets[3], mapping.sourceOffsets[4 ]
358- * | ^ mapping.sourceOffsets[0], mapping.sourceOffsets[2 ]
356+ * | ^ ^ ^ mapping.sourceOffsets[0 ]
357+ * | ^ ^ mapping.sourceOffsets[2 ]
358+ * | ^ mapping.sourceOffsets[1 ]
359359 * |
360360 * 2 | @value c_1 as aliased_c_1 from './c.module.css';
361- * | ^ ^ ^ mapping.sourceOffsets[6 ]
362- * | ^ ^ mapping.sourceOffsets[5 ]
363- * | ^ mapping.sourceOffsets[7 ]
361+ * | ^ ^ ^ mapping.sourceOffsets[4 ]
362+ * | ^ ^ mapping.sourceOffsets[3 ]
363+ * | ^ mapping.sourceOffsets[5 ]
364364 * |
365365 *
366366 * a.module.css.d.ts:
367367 * 1 | declare const styles = {
368368 * 2 | b_1: (await import('./b.module.css')).default.b_1,
369- * | ^ ^ ^ mapping.generatedOffsets[2], linkedCodeMapping.generatedOffsets[0]
369+ * | ^ ^ ^ linkedCodeMapping.generatedOffsets[0]
370370 * | ^ ^ mapping.generatedOffsets[1]
371371 * | ^ mapping.generatedOffsets[0], linkedCodeMapping.sourceOffsets[0]
372372 * |
373373 * 3 | b_2: (await import('./b.module.css')).default.b_2,
374- * | ^ ^ mapping.generatedOffsets[4], linkedCodeMapping.generatedOffsets[1]
375- * | ^ mapping.generatedOffsets[3 ], linkedCodeMapping.sourceOffsets[1]
374+ * | ^ ^ linkedCodeMapping.generatedOffsets[1]
375+ * | ^ mapping.generatedOffsets[2 ], linkedCodeMapping.sourceOffsets[1]
376376 * |
377377 * 4 | aliased_c_1: (await import('./c.module.css')).default.c_1,
378- * | ^ ^ ^ mapping.generatedOffsets[7 ], linkedCodeMapping.generatedOffsets[2]
379- * | ^ ^ mapping.generatedOffsets[6 ]
380- * | ^ mapping.generatedOffsets[5 ], linkedCodeMapping.sourceOffsets[2]
378+ * | ^ ^ ^ mapping.generatedOffsets[5 ], linkedCodeMapping.generatedOffsets[2]
379+ * | ^ ^ mapping.generatedOffsets[4 ]
380+ * | ^ mapping.generatedOffsets[3 ], linkedCodeMapping.sourceOffsets[2]
381381 * |
382382 * 5 | };
383383 *
384384 * NOTE: Not only the specifier but also the surrounding quotes are included in the mapping.
385- * TODO: Stop generating unnecessary mappings for tokens that do not have a `localName`.
386385 */
387386
388387 // eslint-disable-next-line no-loop-func
@@ -403,9 +402,11 @@ function generateDefaultExportDts(
403402 mapping . generatedOffsets . push ( text . length ) ;
404403 }
405404 text += `'${ tokenImporter . from } ')).default.` ;
406- mapping . sourceOffsets . push ( value . loc . start . offset ) ;
407- mapping . lengths . push ( value . name . length ) ;
408- mapping . generatedOffsets . push ( text . length ) ;
405+ if ( 'localName' in value ) {
406+ mapping . sourceOffsets . push ( value . loc . start . offset ) ;
407+ mapping . lengths . push ( value . name . length ) ;
408+ mapping . generatedOffsets . push ( text . length ) ;
409+ }
409410 linkedCodeMapping . generatedOffsets . push ( text . length ) ;
410411 linkedCodeMapping . generatedLengths . push ( value . name . length ) ;
411412 text += `${ value . name } ,\n` ;
0 commit comments