cevou / openui5-webpack

OpenUI5 support for webpack
Apache License 2.0
27 stars 7 forks source link

Namespace Assumption in openui5-xml-loader #5

Closed ghost closed 6 years ago

ghost commented 6 years ago

I was setting up a webpack.config for a project, and I got some errors. After doing some research and looking in the sources, I came to the conclusion that it's not guaranteed that FragmentDefinition or View are always in the "core:" or "mvc:" namespace. Even in the official libraries this is not always the case. See: RuleUpdate.fragment

This causes an error:

WARNING in ./node_modules/@openui5/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/view/ContentDetails.view.xml
Module build failed (from ./node_modules/openui5-xml-loader/dist/index.js):
TypeError: Cannot read property '$' of undefined
    at [...]\node_modules\openui5-xml-loader\dist\index.js:56:31
    at Parser.<anonymous> ([...]\node_modules\xml2js\lib\parser.js:303:18)
    at Parser.emit (events.js:182:13)
    at SAXParser.onclosetag ( [...]\node_modules\xml2js\lib\parser.js:261:26)
    at emit ( [...]\node_modules\sax\lib\sax.js:624:35)
    at emitNode ( [...]\node_modules\sax\lib\sax.js:629:5)
    at closeTag ( [...]\node_modules\sax\lib\sax.js:889:7)
    at SAXParser.write ( [...]\node_modules\sax\lib\sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString ( [...]\node_modules\xml2js\lib\parser.js:322:31)
    at Parser.parseString ( [...]\node_modules\xml2js\lib\parser.js:5:59)
    at exports.parseString ( [...]\node_modules\xml2js\lib\parser.js:354:19)
    at Object.module.exports ( [...]\node_modules\openui5-xml-loader\dist\index.js:47:27)
 @ . openui5 resources
 @ ./node_modules/@openui5/sap.ui.core/src/sap/ui/core/Component.js
 @ ./node_modules/@openui5/sap.ui.core/src/sap/ui/core/ComponentContainer.js
 @ ./src/index.js

https://github.com/cevou/openui5-webpack/blob/34a64c703674565a47ae6d54d29bc1463d2bff42/packages/openui5-xml-loader/src/index.js#L46

I am using Yarn:

"@openui5/sap.m": "~1.56.3",
"@openui5/sap.tnt": "1.56.3",
"@openui5/sap.ui.core": "^1.56.3",
"@openui5/sap.ui.support": "1.56.3",
"@openui5/sap.ui.table": "^1.56.3",
"@openui5/themelib_sap_belize": "^1.56.3"

and

"openui5-renderer-loader": "^0.1.0",
"openui5-theme-base-loader": "^0.2.0",
"openui5-theme-loader": "^0.2.0",
"openui5-webpack-plugin": "^0.2.1",
"openui5-xml-loader": "^0.2.0",

Thank you.

cevou commented 6 years ago

Thanks for reporting this! I will have a look into it.