finos / perspective

A data visualization and analytics component, especially well-suited for large and/or streaming datasets.
https://perspective.finos.org/
Apache License 2.0
7.72k stars 1.04k forks source link

Should not import the named export 'version' (imported as 'Q') #2646

Closed ruimarques-lseg closed 6 days ago

ruimarques-lseg commented 6 days ago

Bug Report

I have bumped into an error similar to what's described here:

https://github.com/finos/perspective/discussions/2507

Should not import the named export 'version' (imported as 'Q') from default-exporting module (only default export is available soon)

I get this message by building (with webpack) an app importing perspective 4.7.1 and adding the webpack plugin.

Additional Context:

Issue seems to be in migrate.ts, line:

import { version as PKG_VERSION } from "@finos/perspective/package.json" assert { type: "json" };

Replacing it with::

import packageInfo from "@finos/perspective/package.json" assert { type: "json" };

and then PKG_VERSION with

packageInfo.version

seems to fix it.

Note that i tested this fix by hacking my way and changing the compiled perspective-viewer.js file installed at node_modules, so i did not test changing the migrate.ts source but i think it is very likely to be analogous.

Note this is a common issue with imports as it can be seen here: https://stackoverflow.com/questions/64993118/error-should-not-import-the-named-export-version-imported-as-version

ruimarques-lseg commented 6 days ago

Closing as it seems to be solved from 4.8.0:

https://github.com/finos/perspective/blob/v2.8.0/rust/perspective-viewer/src/ts/migrate.ts#L16