📦 Goodbye, bundled JavaScript runtime 📦
This release changes how ElementaryUI integrates with JavaScriptKit.
Until now, ElementaryUI bundled its own JavaScript browser runtime in the form of the now deprecated runApplication bootstrap function. With @elementary-swift/vite-plugin-swift-wasm 0.2, this is no longer necessary: the Vite plugin now integrates directly with JavaScriptKit’s SwiftPM plugin and uses its generated package output.
This removes the duplicated runtime setup from ElementaryUI and lets JavaScriptKit fully own the Swift ↔ JavaScript build integration - including BridgeJS - going forward.
When upgrading an existing project:
# Add JavaScriptKit as a dependency
swift package add-dependency https://github.com/swiftwasm/JavaScriptKit --from "0.58.0"
# Remove the bundled browser runtime from your package.json
npm remove elementary-ui-browser-runtime
# Upgrade the Vite plugin
npm install -D @elementary-swift/vite-plugin-swift-wasm@~0.2Then adjust how you initialize the Swift module:
-import { runApplication } from "elementary-ui-browser-runtime";
-import appInit from "virtual:swift-wasm?init";
+import { init } from "virtual:swift-wasm?js";
-await runApplication(appInit);
+await init();The ?js mode uses JavaScriptKit’s generated runtime and takes care of initializing it together with your Swift WebAssembly binary.
What's Changed
- upgrade to JavaScriptKit 0.58 by @sliemeobn in #122
- migrate examples to
virtual:swift-wasm?jsby @sliemeobn in #123 - added CI for 6.4.x and main snapshots by @sliemeobn in #124
- deprecate the bundled
elementary-ui-browser-runtimepackage by @sliemeobn in #125
⚠️ JavaScriptKit runtime update (one last time)
# install/update the local BrowserRuntime package
npm install
# clear vite dev build cache
rm -rf node_modules/.vite
Full Changelog: 0.6.1...0.7.0