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

Bug: Failed to resolve entry for package "danfojs" #545

Open
devMagno opened this issue Jan 5, 2023 · 7 comments
Open

Bug: Failed to resolve entry for package "danfojs" #545

devMagno opened this issue Jan 5, 2023 · 7 comments

Comments

@devMagno
Copy link

devMagno commented Jan 5, 2023

Describe the bug
I've installed danfojs@^1.1.2 in my React project using Vite and I'm getting the following error:

[plugin:vite:import-analysis] Failed to resolve entry for package "danfojs". The package may have incorrect main/module/exports specified in its package.json.

I really don't know what to do, I tried googling the error and found nothing.
At first I thought it was a bug involving Vite, but then I tried using CRA and the bug still happens.

Screenshots
image

@steveoni
Copy link
Member

steveoni commented Jan 6, 2023

@devMagno you can check how it’s use for CRA here /~https://github.com/javascriptdata/Data-aRT

@devMagno
Copy link
Author

devMagno commented Jan 6, 2023

Thanks! It worked for me, but I would really like to use Danfo for Vite :(

@ttarabbia
Copy link

ttarabbia commented Jan 10, 2023

Same here - rolled back to 1.1.1 - unfortunately that means I can't use parsing options in readExcel....
Haven't found a way to fix - tried the absolute path, tried changing entry point, like #516

Unfortunately still breaks in Vite.

@ttarabbia
Copy link

Similar to issue #527

@ttarabbia
Copy link

Also take a look at #514

@S-L-Moore
Copy link

Found a workaround on this thread:
Discussions 525

@fahminlb33
Copy link

fahminlb33 commented Apr 28, 2023

Aside from the workaround on the #525, I tried the #447 PR locally and it worked on Vite + React.

Repro steps:

  1. Clone the danfo repo
  2. yarn and yarn build
  3. You'll see two different build in the src/danfojs-browser/lib, the esbuild version (bundle.esm.js) and webpack version (bundle-esm.js)
  4. If you're using Vite, the esbuild is the one you want.

How I used the esbuild bundle version in my app:

import { Button, Text } from '@mantine/core';

import * as dfd from '../../../danfo2/bundle.esm.js'; // place the file somewhere, in this case in my src dir

export default function Create() {
  async function load_process_data() {
    let df = await dfd.readCSV('/titanic.csv');
    console.log(df.head().print());
    console.log(df.ctypes.print());

    const title = df['Name'].apply((x: string) => { return x.split(".")[0] }).values

    df.addColumn("Name", title, {inplace: true});
    console.log(df.head().print());
  }

  return (
    <div>
      <Text>Create</Text>
      <Button onClick={load_process_data}>Load Data</Button>
    </div>
  );
}

So based on these findings, we have to options.

  1. The webpack version, if you want to include danfo from <script> tag
  2. The esbuild version, if you want to import danfo from Vite

Based on my node_modules the bundle installed using npm install danfojs is the webpack version and the esbuild version are not even included in the package. Also, the module field in the package.json in the npm package is pointing to a wrong file, it should be lib/bundle.js not lib/bundle-esm.js

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