Skip to content
Source
Sign inSign up
TanStack/react-charts

UNPKG script tag doesn't seem to work #228

Send to my agent
Closedzachdtaylor(GitHub profile, opens in a new tab) opened this issue 1 comment

The URL https://unpkg.com/react-charts/dist/react-charts.production.min.js redirects to https://unpkg.com/react-charts@2.0.0-beta.7/dist/react-charts.production.min.js, an old beta version of react-charts. When I put the following script tag in my HTML

<!-- React Scripts -->
...
<script src="https://unpkg.com/react-charts/dist/react-charts.production.min.js"></script>

I get an error in the console saying Uncaught ReferenceError: require is not defined.

I tried changing the script tag to specifically reference version 2.1.0,

<script src="https://unpkg.com/react-charts@2.1.0/dist/react-charts.cjs.production.min.js"></script>

but got another error saying Uncaught ReferenceError: exports is not defined.

This was all done in Chrome.

EDIT:

I just noticed there is an esm version on UNPKG, so I tried

<script src="https://unpkg.com/react-charts@2.1.0/dist/react-charts.esm.js"></script>

which gave the error Uncaught SyntaxError: Cannot use import statement outside a module. So I tried adding the type="module"

<script src="https://unpkg.com/react-charts@2.1.0/dist/react-charts.esm.js" type="module"></script>

which also did not work. I got an Uncaught TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".

  1. I think I'm going to remove the unpkg script for now :)

  2. tannerlinsley closed this

Sign in to join this conversation.