Open simoneb opened 10 months ago
Yeah likewise I encountered the same problem :thinking:
Hey @simoneb is there any work around you did about this to work?
I fiddled around with the installed package's package.json file but it wasn't by any means a robust solution. The fix should be fairly simple though, it's just a matter of getting the exports right in the package file.
same here
While this is not fixed, here is a temporary solution at least worked for me, btw i'm using yarn.
add this to your package.json file:
"resolutions": { "mathjs": "11.11.0" },
My less than ideal workaround to get it going before this is fixed is just loading via script tags <script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.2/lib/bundle.min.js" />
then you can use dfd
globally.
I've created a draft PR (https://github.com/javascriptdata/danfojs/pull/604) with an implementation that works locally, but I'm not too happy with.
I'm new to package exports, so it's all a little blurry, hence why I'm keeping this one as a draft, but hopefully that's a start to fix the issues and could do with some help to finish it off.
Both for a new vite app and a new CRA app, I've linked the package locally with npm link danfojs
, then used the following code in the root file:
import * as dfd from 'danfojs'
const s = new dfd.Series([1, 3, 5, undefined, 6, 8])
s.print()
Both apps run fine without runtime errors and display the series in the console.
However, types don't work, and I get the following error in CRA terminal output:
WARNING in ../danfojs/src/danfojs-browser/lib/bundle.esm.js 9:47-54
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARNING in ../danfojs/src/danfojs-browser/lib/bundle.esm.js 12:44-51
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Has anyone figured out how to fix this issue? I was really looking forward to using this library in our production pipeline, but I can't remove Vite unfortunately and local hacks/fixes are a no go either.
I managed to get it work in ViteJS. I found out that the main problem is that they pointed out "module": "lib/bundle-esm.js" when it should actually be "module": "lib/bundle.esm.js". (the path is incorrect).
To get it working:
This hack works for me, instead of
import * as dfd from "danfojs"
do
import * as dfd from "danfojs/dist/danfojs-browser/src"
Describe the bug
Danfojs cannot be loaded in a Vitejs project.
To Reproduce Steps to reproduce the behavior:
import * as dfd from 'danfojs'
Expected behavior
The import works and you can use danfojs in your Vitejs app
Repro
You can see a repro in CodeSandbox here. Creating a new Vitejs application locally leads to the same issue (meaning that it's not an issue with CodeSandbox), and the issue happens regardless of whether you use TypeScript or JavaScript.