Conversation
1724f41 to
544061c
Compare
Signed-off-by: Andrew Stein <steinlink@gmail.com>
5334d3e to
290d106
Compare
a7b139b to
c678ebc
Compare
Signed-off-by: Andrew Stein <steinlink@gmail.com>
|
Amazing Work!
|
|
This seems to be much better overall, however there are still issues with typescript and node. The biggest one is that if you have tsc configured to use import statements/ESM with a bundler (tsc) you can't import the node library. By making node a CommonJS module (require) it creates a lot of snowflake configuration just to import This is a pain since I would say the majority of libraries support both or just ESM these days. |
|
Okay I think I see what is going on. It looks like I was able to work around this by re-exporting table in a local // @ts-expect-error we have to fix this manually until they do
import { table as pspTable } from "@finos/perspective/node";
import { Client } from "@finos/perspective/dist/wasm/perspective-js.js";
const table = pspTable as Client["table"];
export default {
table,
}; |
I've successfully managed the migration, it wasn't as easy as i tought but still very smooth. i have created this helper file for handling the instanziation as a "singleton". by doing so i'm fixing SSR problem on perspective-viewer (since in my case i don't need it, i'm using perspective mainly for his dataframe and query capabilites) for using the module above you can simply run it everywhere (server side, client side, inside a component etc) by simply calling here's some more examples on how i've used it . I hope this will help fellow Sveltekit devs |
|
I’ve tested this with a repo built using nx@20.4.0, react@19.0.0, and perspective@3.3.2, but I ran into the following errors: TS2307: Cannot find module '@finos/perspective/dist/wasm/perspective-server.wasm' or its corresponding type declarations.
TS2307: Cannot find module '@finos/perspective-viewer/dist/wasm/perspective-viewer.wasm' or its corresponding type declarations.I couldn’t find examples in previous comments specifically covering this environment setup (nx, react) or addressing TypeScript issues with these imports. That’s why I wanted to contribute this example. The repo used for testing can be found here: https://github.com/kryaksy/perspective-react-unbundled-build. Any advice on how to resolve these issues would be appreciated! Thanks. |
Same issue previously the perspective-web-plugin worked perfectly fine for me, but struggling to upgrade for > 3.2.1 onward |
|
Y'all - please stop necroposting to this closed PR. The window for comments on this change has expired - please use the Issue template to file a bug with a repro, or Discussion to ask a question. @kryaksy I appreciate the repro, but this is too big for me to debug - there are 40 dev dependencies, including 3 different bundlers that I can recognize (webpack, swc, nx) as well as TypeScript stacked on top of Babel. Your error however does not even look like a bundler error - it is a TypeScript error complaining you haven't declared types for whatever format it output by whichever of your bundlers is doing the outputting. Assuming your bundler does not do this automatically you can declare the module or workaround by just declare module '*.wasm' {
const value: <<< I legit don't know what type goes here lol >>>;
export default value;
} |
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-pluginand@finos/perspective-webpack-pluginhave 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.wasmbinary assets via your bundler's asset packaging, then initialize Perspective viainit_client()andinit_server()methods. For Vite, this looks like this: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.rsby 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-exampleas well.Deprecated
To be decided, potentially two API deprecations in addition to the API changes above.
@finos/perspective-esbuild-pluginand@finos/perspective-webpack-pluginas 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
.wasmassets 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
mdbookdocs site.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
nexttag on NPM, by specifyingnextinstead of a version in the CLI orpackage.json: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
/examplesdirectory.