`@finos/perspective` 3.1.0 fails to build due to src dependency from dist
Bug Report
Steps to Reproduce:
Trying to update the vite example to perspective 3.1.0 fails for two reasons:
- Top-level async-await usage was added. Possible to resolve by adding a vite config and updating the target (shown in stackblitz example with addition of
vite.config.tsand updates to package.json script commands to include config file) - The built
distoutput has dependencies on thesrc/tsresulting in build errors like the following:[ERROR] No matching export in "../node_modules/@finos/perspective/src/ts/perspective-server.worker.ts" for import "default" ../node_modules/@finos/perspective/dist/esm/perspective.js:1:65: 1 │ import u from"../../dist/pkg/web/perspective-server.wasm";import w from"../../src/ts/perspective-server.worker.js";function p(){let e,t=new Promise(r=>{e=r});return[e,t]}async function d(e,t){let[r,n]=p();e.addEventListener("message",function o(s){e.removeEventListener("message",o),r(null)}),e... ╵ ^
See stackblitz example based on vite example to target es2022 for tla support: https://stackblitz.com/edit/perspective-vite-build-fail
Expected Result:
Library builds successfully
Actual Result:
See above
- Win 10
If you are reporting a UX/UI error:
N/A
If you are reporting a library error:
N/A
If you are reporting a build or install error:
done, see above.
Environment:
For JavaScript (browser):
@finos/perspectiveversion: 3.1.0- Browser and version Chrome 129
- OS Win 10
- (if websocket) Language/version/OS of perspective server N/A
For Node.js: N/A
nodeversion- OS
For Python N/A
pythoninterpreter version (Only CPython).- package manager and version (conda/pip/*)
- Are you compiling from an sdist of wheel?
- Platform and version (Jupyter/tornado/lib/*)
- OS
Additional Context:
N/A Add any other context about the problem here.
Maybe I was just misinterpreting the docs, they seem to indicate that by default the inline builds are used and a bundler is not needed: https://docs.rs/perspective-js/latest/perspective_js/#installation
By default, Perspective inlines these assets into the .js scripts, and delivers them in one file. This has no runtime performance impact, but does increase asset load time.
And then conversation continues about using bundlers, presumable for the non-default use case of more optimal builds.
Maybe the docs are outdated with 3.0 changes? It seems like the inline builds are not the default and instead using the inline builds requires referencing @finos/perspective-viewer/dist/esm/perspective-viewer.inline.js and @finos/perspective/dist/esm/perspective.inline.js.
If that is the case then maybe this issue is a documentation should have a specific example of showing the now non-default inline builds? If that is the case I can create a PR to update that documentation.
However, even with the inline build I ran into a runtime issue (so not completely sure this is the right direction): https://github.com/finos/perspective/issues/2796
same problem here, i've tried everything without success. note: version 2.10.1 works. i'm still getting an import error but is not blocking the build process.
Do you know where we can see documentation for 2.10.1?
I don't think the documentation is available for the order version (2.xx) as far as building goes, the documentation has remained the same between the 2 major versions.
Do you know where we can see documentation for 2.10.1?
You can use the Wayback machine to see old docs:
https://web.archive.org/web/20240605134744/https://perspective.finos.org/
I found a workaround by using the inline builds in the latest package with vite as shown here: https://github.com/finos/perspective/issues/2796#issuecomment-2438383909
Maybe this issue should be open to capture documentation updates / updating the vite example for v3.1.2 via inline builds?
I found a workaround by using the inline builds in the latest package with vite as shown here: #2796 (comment)
Maybe this issue should be open to capture documentation updates / updating the vite example for v3.1.2 via inline builds?
Here's a code example of the workaround:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { purgeCss } from 'vite-plugin-tailwind-purgecss';
//import { PerspectiveEsbuildPlugin } from '@finos/perspective-esbuild-plugin';
//import wasm from 'vite-plugin-wasm';
//import topLevelAwait from 'vite-plugin-top-level-await';
//import typescript from '@rollup/plugin-typescript';
export default defineConfig({
plugins: [
sveltekit(),
purgeCss(),
// // {
// // content: ['./src/**/*.svelte', './src/**/*.html', './src/**/*.ts', './src/**/*.js'],
// //}
//),
],
resolve: {
alias: {
'@finos/perspective': '@finos/perspective/dist/esm/perspective.inline.js',
'@finos/perspective-viewer': '@finos/perspective-viewer/dist/esm/perspective-viewer.inline.js',
'@finos/perspective-styles': '@finos/perspective-viewer/dist/css',
//'@finos/perspective-viewer/dist/css/solarized-dark.css': '@finos/perspective-viewer/dist/css/solarized-dark.css',
//'@finos/perspective-viewer/dist/css/themes.css': '@finos/perspective-viewer/dist/css/themes.css'
},
},
optimizeDeps: {
esbuildOptions: {
target: 'es2022',
},
},
build: {
target: 'es2022',
},
});
note that the code commented out was from trial and error.
when importing styles, you now have to import them using the new @finos/perspective-styles.
the only catch (quite irritating) is that i'm unable to found a workaround for getting back typescrit Types. Cold you please help me guys ?
Do you know where we can see documentation for 2.10.1?
It's here: https://docs.rs/crate/perspective/2.10.1
I'm having the exact same problems with the latest v3 versions unfortunately.
Duplicate #2725
We've released Perspective 3.3.0 with official Vite support (docs) and sample project. This new unbundled build does not require a plugin, but does require special bundler setup (see docs).