3636 * @property {Array<string> } components
3737 * @property {Array<string> } tags
3838 * @property {Record<string, {node: JSXElement, component: boolean}> } references
39- * @property {Map<string|number , string> } idToInvalidComponentName
39+ * @property {Map<string, string> } idToInvalidComponentName
4040 * @property {EstreeFunction } node
4141 */
4242
@@ -246,7 +246,7 @@ export function recmaJsxRewrite(options) {
246246 /** @type {string } */
247247 let name
248248
249- for ( name of scope . tags ) {
249+ for ( name of scope . tags . sort ( ) ) {
250250 defaults . push ( {
251251 type : 'Property' ,
252252 kind : 'init' ,
@@ -270,6 +270,8 @@ export function recmaJsxRewrite(options) {
270270 }
271271 }
272272
273+ actual . sort ( )
274+
273275 /** @type {Array<Statement> } */
274276 const statements = [ ]
275277
@@ -363,18 +365,20 @@ export function recmaJsxRewrite(options) {
363365 }
364366
365367 if ( isNamedFunction ( scope . node , '_createMdxContent' ) ) {
366- for ( const [
367- id ,
368- componentName
369- ] of scope . idToInvalidComponentName ) {
368+ for ( const [ id , componentName ] of [
369+ ...scope . idToInvalidComponentName
370+ ] . sort ( ( [ a ] , [ b ] ) => a . localeCompare ( b ) ) ) {
370371 // For JSX IDs that can’t be represented as JavaScript IDs (as in,
371372 // those with dashes, such as `custom-element`), generate a
372373 // separate variable that is a valid JS ID (such as `_component0`),
373374 // and takes it from components:
374375 // `const _component0 = _components['custom-element']`
375376 declarations . push ( {
376377 type : 'VariableDeclarator' ,
377- id : { type : 'Identifier' , name : componentName } ,
378+ id : {
379+ type : 'Identifier' ,
380+ name : componentName
381+ } ,
378382 init : {
379383 type : 'MemberExpression' ,
380384 object : { type : 'Identifier' , name : '_components' } ,
0 commit comments