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

@finos/perspective 3.1.0 fails to build due to src dependency from dist #2795

Open
rajsite opened this issue Oct 17, 2024 · 8 comments
Open

Comments

@rajsite
Copy link

rajsite commented Oct 17, 2024

Bug Report

Steps to Reproduce:

Trying to update the vite example to perspective 3.1.0 fails for two reasons:

  1. 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.ts and updates to package.json script commands to include config file)
  2. The built dist output has dependencies on the src/ts resulting 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/perspective version: 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

  • node version
  • OS

For Python
N/A

  • python interpreter 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:

Related issues / discussions:

@rajsite
Copy link
Author

rajsite commented Oct 17, 2024

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): #2796

@MPizzotti
Copy link

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.

@leestorm4520
Copy link

Do you know where we can see documentation for 2.10.1?

@MPizzotti
Copy link

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.

@aszenz
Copy link
Contributor

aszenz commented Oct 25, 2024

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/

@rajsite
Copy link
Author

rajsite commented Oct 25, 2024

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?

@MPizzotti
Copy link

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 ?

@tobilg
Copy link

tobilg commented Dec 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants