timqian / chart.xkcd

xkcd styled chart lib
https://timqian.com/chart.xkcd/
MIT License
7.64k stars 198 forks source link

`Field 'browser' doesn't contain a valid alias configuration` using Webpack #62

Open erdostom opened 4 years ago

erdostom commented 4 years ago

I'm trying to use the latest version (HEAD, not released) using Webpack and I get this error. Using the latest official npm release doesn't have this problem.

image

timqian commented 4 years ago

Looks the module is not successfully imported. But I haven't tried doing this use webpack How do you import chart.xkcd?

erdostom commented 4 years ago

I import using import charts from 'chart.xkcd'

Something is wrong with the way the modules are exported. If I use the latest npm version the above import works fine, but master from this repo fails.

Can be replicated with

  1. create-react-app test (yarn global add create-react-app if you don't have it)
  2. yarn add https://github.com/timqian/chart.xkcd
  3. import charts from 'chart.xkcd' in src/App.js
  4. get error below

image

golopot commented 4 years ago

The build script is not executed when people install this package by yarn add https://github.com/timqian/chart.xkcd, so there is no dist in the installed package. One way to solve this is to change prepublishOnly in package.json to prepublish or prepare, that way the build step will be executed.