@@ -297,23 +297,39 @@ function installXletImporter(extension) {
297297 // extension.dir is the actual directory containing the JS files,
298298 // which might be a versioned subdirectory (e.g., .../uuid/6.0/)
299299 // or the uuid directory itself for non-versioned xlets.
300- let parentPath = extension . dir . get_parent ( ) . get_path ( ) ;
301300 let dirName = extension . dir . get_basename ( ) ;
301+ let uuidDir = extension . dir . get_parent ( ) ;
302+ let parentPath , importPath ;
303+
304+ // Versioned subdirectories (e.g., "6.2") start with a digit and
305+ // can't be used as importer keys directly. Navigate through the
306+ // uuid directory instead.
307+ if ( dirName . match ( / ^ [ 0 - 9 ] / ) ) {
308+ parentPath = uuidDir . get_parent ( ) . get_path ( ) ;
309+ importPath = [ uuidDir . get_basename ( ) , dirName ] ;
310+ } else {
311+ parentPath = uuidDir . get_path ( ) ;
312+ importPath = [ dirName ] ;
313+ }
302314
303315 let oldSearchPath = imports . searchPath . slice ( ) ;
304316 imports . searchPath = [ parentPath ] ;
305317
306318 try {
307- extension . imports = imports [ dirName ] ;
319+ let importer = imports ;
320+ for ( let part of importPath ) {
321+ importer = importer [ part ] ;
322+ }
323+ extension . imports = importer ;
308324 } catch ( e ) {
309325 imports . searchPath = oldSearchPath ;
310- throw new Error ( `Failed to create importer for ${ extension . uuid } at ${ parentPath } /${ dirName } : ${ e . message } ` ) ;
326+ throw new Error ( `Failed to create importer for ${ extension . uuid } at ${ parentPath } /${ importPath . join ( '/' ) } : ${ e . message } ` ) ;
311327 }
312328
313329 imports . searchPath = oldSearchPath ;
314330
315331 if ( ! extension . imports ) {
316- throw new Error ( `Importer is null for ${ extension . uuid } at ${ parentPath } /${ dirName } ` ) ;
332+ throw new Error ( `Importer is null for ${ extension . uuid } at ${ parentPath } /${ importPath . join ( '/' ) } ` ) ;
317333 }
318334}
319335
0 commit comments