@@ -11,6 +11,13 @@ const moduleCache = new Map();
1111const owningPackageCache = new Map ( ) ;
1212const wildcardExportsCache = new Map ( ) ;
1313
14+ // Barrels we deliberately don't rewrite imports from. `@glimmer/component`
15+ // has its own legacy-resolution tsconfig that can't follow deep paths;
16+ // `@ember/version` is a one-line shim that re-exports from `ember/version`
17+ // (a different package), and we want to keep `@ember/version` as the canonical
18+ // import path for the framework version.
19+ const EXCLUDED_BARRELS = new Set ( [ '@glimmer/component' , '@ember/version' ] ) ;
20+
1421const idOrStr = ( n ) => ( n . type === 'Identifier' ? n . name : n . value ) ;
1522
1623function resolveBarrelPath ( specifier ) {
@@ -156,9 +163,14 @@ const SCOPE_PREFIXES = [
156163 path . join ( PACKAGES_ROOT , '@ember' ) + path . sep ,
157164 path . join ( PACKAGES_ROOT , '@glimmer' ) + path . sep ,
158165] ;
166+ const EXCLUDED_FILE_PREFIXES = [
167+ path . join ( PACKAGES_ROOT , '@glimmer/component' ) + path . sep ,
168+ ] ;
159169const TEST_DIR_RE = / [ \\ / ] (?: t e s t | t e s t s ) [ \\ / ] / ;
160170
161171const isInScope = ( filename ) => SCOPE_PREFIXES . some ( ( p ) => filename . startsWith ( p ) ) ;
172+ const isExcludedFile = ( filename ) =>
173+ EXCLUDED_FILE_PREFIXES . some ( ( p ) => filename . startsWith ( p ) ) ;
162174const isInTestFile = ( filename ) =>
163175 TEST_DIR_RE . test ( filename ) || filename . includes ( `${ path . sep } internal-test-helpers${ path . sep } ` ) ;
164176
@@ -299,7 +311,9 @@ module.exports = {
299311 } ,
300312 create ( context ) {
301313 const { filename } = context ;
302- if ( ! filename || ! isInScope ( filename ) || isInTestFile ( filename ) ) return { } ;
314+ if ( ! filename || ! isInScope ( filename ) || isInTestFile ( filename ) || isExcludedFile ( filename ) ) {
315+ return { } ;
316+ }
303317
304318 function resolveSpecifier ( moduleExports , importedName , barrelPath , originalSpec ) {
305319 const entry = moduleExports . get ( importedName ) ;
@@ -360,6 +374,7 @@ module.exports = {
360374 function check ( node ) {
361375 const spec = node . source ?. value ;
362376 if ( typeof spec !== 'string' ) return ;
377+ if ( EXCLUDED_BARRELS . has ( spec ) ) return ;
363378 const barrelPath = resolveBarrelPath ( spec ) ;
364379 if ( ! barrelPath || filename === barrelPath ) return ;
365380
0 commit comments