如何将使用lit-element的Electron应用程序升级到Electron v7.0.0?

时间:2019-11-01 13:06:06

标签: typescript electron lit-element lit-html

在Electron v5.0.11中运行我的应用程序可以正常工作,但是当我尝试升级到任何较新版本(即Electron v7.0.0)时,我的元素Web组件无法呈现,并且在Chrome控制台中出现此错误:< / p>

Error: Cannot find module './dist/renderer.js'

屏幕截图:https://imgur.com/a/ovhTIvH

我的应用程序使用index.html中的esm来转换照明元件节点模块。这似乎是应用程序中断的地方。

我的nodeIntegration文件中的

true也设置为main.ts

index.html


    <body>
        <app-component></app-component>
        <script>
            require = require("esm")(module);
            module.exports = require("./dist/renderer.js");
        </script>
    </body>

renderer.ts


    import "./components/app-component";

app-component.ts


    import { customElement, html, LitElement } from "lit-element";

    @customElement("app-component")
    export class AppComponent extends LitElement {
        render() {
            return html`
                <div id="app-container">
                    <h1>Test</h1>
                </div>
            `;
        }
    }

package.json


    "devDependencies": {
        "electron": "7.0.0", * App works fine when this value is "5.0.11" *
        "esm": "^3.2.25",
        "lit-element": "^2.2.1",
        "tslint": "^5.20.0",
        "typescript": "^3.6.4"
    }

tsconfig.json


    {
        "compilerOptions": {
            "module": "commonjs",
            "target": "es2015",
            "noImplicitAny": true,
            "sourceMap": true,
            "outDir": "dist",
            "baseUrl": ".",
            "moduleResolution": "node",
            "experimentalDecorators": true
        },
        "include": ["src/**/*"]
    }

0 个答案:

没有答案