@@ -8,39 +8,58 @@ module.exports = function(source) {
88 let namespaces = [ ] ;
99 const parser = new XmlParser ( ( event ) => {
1010 const { namespace, elementName } = event ;
11+ const moduleName = `${ namespace } /${ elementName } ` ;
1112
1213 if (
1314 namespace &&
1415 ! namespace . startsWith ( "http" ) &&
15- ! namespaces . some ( n => n . name === namespace )
16+ ! namespaces . some ( n => n . name === moduleName )
1617 ) {
1718 const localNamespacePath = join ( this . rootContext , namespace ) ;
1819 const localModulePath = join ( localNamespacePath , elementName ) ;
1920 const resolvedPath = tryResolve ( localNamespacePath ) ||
20- tryResolve ( localModulePath ) ||
21- namespace ;
21+ tryResolve ( localModulePath ) ;
22+
23+ if ( ! resolvedPath ) {
24+ const xml = tryResolve ( `${ localModulePath } .xml` ) ;
25+ if ( ! xml ) {
26+ namespaces . push ( { name : namespace , path : namespace } ) ;
27+ namespaces . push ( { name : moduleName , path : namespace } ) ;
28+
29+ return ;
30+ } else {
31+ namespaces . push ( { name : `${ moduleName } .xml` , path : xml } ) ;
32+ namespaces . push ( { name : moduleName , path : xml } ) ;
33+ this . addDependency ( xml ) ;
34+ }
35+
36+ const css = tryResolve ( `${ localModulePath } .css` ) ;
37+ if ( css ) {
38+ namespaces . push ( { name : `${ moduleName } .css` , path : css } ) ;
39+ this . addDependency ( css ) ;
40+ }
41+
42+ return ;
43+ }
2244
2345 this . addDependency ( resolvedPath ) ;
24- namespaces . push ( { name : namespace , path : resolvedPath } ) ;
2546
26- const moduleName = ` ${ namespace } / ${ elementName } ` ;
47+ namespaces . push ( { name : namespace , path : resolvedPath } ) ;
2748 namespaces . push ( { name : moduleName , path : resolvedPath } ) ;
2849
2950 const { dir, name } = parse ( resolvedPath ) ;
3051 const noExtFilename = join ( dir , name ) ;
3152
32- const xmlFile = `${ noExtFilename } .xml` ;
33- const xmlFileResolved = tryResolve ( xmlFile ) ;
34- if ( xmlFileResolved ) {
35- this . addDependency ( xmlFileResolved ) ;
36- namespaces . push ( { name : `${ moduleName } .xml` , path : xmlFileResolved } ) ;
53+ const xml = tryResolve ( `${ noExtFilename } .xml` ) ;
54+ if ( xml ) {
55+ this . addDependency ( xml ) ;
56+ namespaces . push ( { name : `${ moduleName } .xml` , path : xml } ) ;
3757 }
3858
39- const cssFile = `${ noExtFilename } .css` ;
40- const cssFileResolved = tryResolve ( cssFile ) ;
41- if ( cssFileResolved ) {
42- this . addDependency ( cssFileResolved ) ;
43- namespaces . push ( { name : `${ moduleName } .css` , path : cssFileResolved } ) ;
59+ const css = tryResolve ( `${ noExtFilename } .css` ) ;
60+ if ( css ) {
61+ this . addDependency ( css ) ;
62+ namespaces . push ( { name : `${ moduleName } .css` , path : css } ) ;
4463 }
4564 }
4665 } , undefined , true ) ;
@@ -72,3 +91,4 @@ function tryResolve(path) {
7291 return ;
7392 }
7493}
94+
0 commit comments