Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbundled JavaScript builds #2890

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Unbundled JavaScript builds #2890

wants to merge 2 commits into from

Conversation

texodus
Copy link
Member

@texodus texodus commented Jan 2, 2025

This PR is a rewrite of a Perspective's initialization API, in an attempt to address framework and build tool integration complexity. This has been a frequent source of Community frustration #2725 #2795 #1734 #2796 etc.

@finos/perspective-esbuild-plugin and @finos/perspective-webpack-plugin have been removed. In their place is an explicit WebAssembly initialization API inspired by DuckDB Wasm which implements a similar API. To use the new API, you must acquire the .wasm binary assets via your bundler's asset packaging, then initialize Perspective via init_client() and init_server() methods. For Vite, this looks like this:

import perspective from "@finos/perspective";
import perspective_viewer from "@finos/perspective-viewer";

import SERVER_WASM from "@finos/perspective/dist/wasm/perspective-server.wasm?url";
import CLIENT_WASM from "@finos/perspective-viewer/dist/wasm/perspective-viewer.wasm?url";

await Promise.all([
    perspective.init_server(fetch(SERVER_WASM)),
    perspective_viewer.init_client(fetch(CLIENT_WASM)),
]);

The downside of this API is its verbosity - it is regrettably noisy, with IKEA-esque nescience. It is also a non-trivial breaking change for any ESM/bundler integration with Perspective. The upside is it requires no plugin at all to import with a bundler, as Perspective now exports pure JavaScript ES modules which should be compatible with any bundler.

Documentation

With this change comes a rewritten User Guide, extracted from docs.rs by popular demand. The beta release can be found here, note it is currently not linked as it describes an unreleased Perspective version!

https://perspective.finos.org/guide/

We've added new sections covering bundling with various bundlers including Vite, ESBuild and Webpack, and added a full-blown Vite example in /examples/vite-example as well.

Deprecated

To be decided, potentially two API deprecations in addition to the API changes above.

@finos/perspective-esbuild-plugin and @finos/perspective-webpack-plugin as mentioned. They will not work with v3.3.0 Perspective (at least - not as described in their docs), so v3.2.1 would be the last release for these. However, they should no longer be necessary, so if there is a strong argument to keep these, I question the value proposition of the unbundled build at all.

With this change, inline build of Perspective are no longer really necessary, as you may now simply inline the .wasm assets in yourself with your bundler's own inlining feature. We'd like to deprecate these entirely, but for now we're still building them (with an explicit deprecation warning in the documentation and console).

Changes

  • New bundle process, as described above.
  • New mdbook docs site.
  • Fixed perspective-viewer overscroll behavior
  • Fixed rust build warnings.
  • Debuggable Web Worker deploy internals.
  • The internal build process is ultimately much simpler - fewer modules, fewer entry points, fewer variations to test and faster development cycles.
  • Better type exports, as the type generation build process now has more complete end-to-end type information.

Partially enabled by #2885, which removed one of the last complex Wasm/JavaScript bridge calls.

Community Call for Testing

We are interested in soliciting community feedback for this change, especially if you've had integration issues with previous Perspective builds. You can try out the new unbundled API today, via the next tag on NPM, by specifying next instead of a version in the CLI or package.json:

npm install @finos/perspective@next

Documentation for the new bundling workflow can be found on the new User Guide. New examples (including the Vite example) can be found in the branch /examples directory.

@texodus texodus force-pushed the unbundled branch 7 times, most recently from 1724f41 to 544061c Compare January 6, 2025 17:29
Signed-off-by: Andrew Stein <[email protected]>
@texodus texodus force-pushed the unbundled branch 3 times, most recently from 5334d3e to 290d106 Compare January 9, 2025 03:16
@texodus texodus added enhancement Feature requests or improvements breaking labels Jan 9, 2025
@texodus texodus marked this pull request as ready for review January 9, 2025 20:53
Signed-off-by: Andrew Stein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement Feature requests or improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant