openUI5 为具有自定义数据的应用程序做描述符-sap-ui-resourceroots 无法加载组件-preload.js

openUI5 doing descriptor for application with custom data-sap-ui-resourceroots fail to load component-preload.js

我还是 OpenUI5 的新手,我尝试在我的项目中应用 descriptor for application,我通过 npm 获得了合适的 openUI5 文件,所以我的 foler 结构如下:

/node_modules
    /resources
/webapp
    /controller
    /i18n
    /view
    /Component.js
    /index.html
    /manifest.json
/package.json

我想使用 manifest.json 所以我有 index.html :

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Sylvain's page</title>
    <script id="sap-ui-bootstrap"
        src="../node_modules/resources/sap-ui-core.js"
        data-sap-ui-theme="sap_belize"
        data-sap-ui-libs="sap.m"
        data-sap-ui-compatVersion="edge"
        data-sap-ui-async="true"
        data-sap-ui-resourceroots='{
            "openui5.sylvain": "./"
        }'
        data-sap-ui-onInit="module:sap/ui/core/ComponentSupport">
    </script>
</head>
<body class="sapUiBody" id="content"></body>
<div data-sap-ui-component data-name="openui5.sylvain" data-id="container" data-settings='{"id" : "sylvain"}'></div>
</html>

我收到错误:

GET file: C:/Users/Documents/test/webapp/Component-preload.js net::ERR_FILE_NOT_FOUND

我同意这个错误文件不在 webapp/ 但在 node_module/resources/sap/ui/core

然后我尝试通过替换 data-sap-ui-onInit 如下:

data-sap-ui-onInit="module:../node_modules/resources/sap/ui/core/ComponentSupport"

然后我得到

ui5loader-dbg.js:471 Uncaught (in promise) Error: relative name not supported ('../node_modules/resources/sap/ui/core/ComponentSupport.js'

然后我尝试替换为:

data-sap-ui-onInit="module:node_modules/resources/sap/ui/core/ComponentSupport">

我得到:

Uncaught (in promise) Error: failed to load 'node_modules/resources/sap/ui/core/ComponentSupport.js' from ../node_modules/resources/node_modules/resources/sap/ui/core/ComponentSupport.js: script load error at HTMLScriptElement.b (ui5loader-dbg.js:1336)

那我应该怎么做才能让它正常工作呢?

最初,你做的一切都是对的。

在开发和测试过程中浏览器的控制台中出现此错误。它不会影响任何东西,并且会在应用程序构建后消失。我建议你不要修复任何东西,忽略错误并继续开发。

这个builder任务负责生成这个文件,这里是link到API:

https://sap.github.io/ui5-tooling/api/module-@ui5_builder.tasks.html#.generateComponentPreload