open-pioneer / trails-build-tools

Build tools for the Open Pioneer Trails web client framework.
Apache License 2.0
2 stars 0 forks source link

Exports from app.ts are not preserved #53

Closed mbeckem closed 6 months ago

mbeckem commented 11 months ago

Reproduction:

Create an app, for example:

// app.ts
import { createCustomElement } from "@open-pioneer/runtime";
import * as appMetadata from "open-pioneer:app";
import { AppUI } from "./AppUI";

const Element = createCustomElement({
    component: AppUI,
    appMetadata
});

customElements.define("empty-app", Element);

// Additional export
export const foo = "test-string";

Configure the app in apps (since we want to distribute the JS):

// vite.config.ts
pioneer({
    apps: [
        "the-app"
    ]
}),

Build the app using vite build.

Expected result:

The app's compiled JavaScript entry point in dist/the-app.js also contains an export of foo with the given value.

Actual result:

The exports were optimized out.

Notes

Vite appears to default to rollup's preserveEntrySignatures = false during build (see docs). Entry points generated for apps should use strict or allow-extension instead.