cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.08k stars 399 forks source link

UMD builds not working on import #1567

Open shing-fp opened 3 years ago

shing-fp commented 3 years ago

Expected behavior: I'm trying to implement react-jss via CDN. Importing the UMD build via <script> tag should work out of the box.

Describe the bug: The module does not load and the console generates the error as follows:

Uncaught ReferenceError: module is not defined
    at react-jss.min.js:6
    at react-jss.min.js:1
    at react-jss.min.js:1

Reproduction:

CodeSandbox - loading react, react-dom, and react-jss

Versions:

kof commented 3 years ago

here is an unminified version

https://codesandbox.io/s/eloquent-euclid-1l7yf

It seems that object-assign package is cjs and we need to add it to rollup.config.js to the commonjsOptions.include whitelist

cc @TrySound please correct me if I am wrong

kof commented 3 years ago

I think object-assign landed in our umd bundle automatically by rollup, we don't have it explicitly as a dependency, that's why we also didn't add it to the whitelist

TrySound commented 3 years ago

Rollup does not polyfill anything. Plugins could but you don't use such plugins.

TrySound commented 3 years ago

React packages use object-assign

GeorgeNagel commented 2 years ago

This is still an issue as of 10.9.1-alpha.2. Still getting an issue as a result of object-assign.

<script src="https://unpkg.com/react-jss@10.9.1-alpha.2/dist/react-jss.js" crossorigin></script>

I believe this is the package that is generating the error https://github.com/sindresorhus/object-assign

khanakia commented 1 year ago

I am having the same issue <script src="https://unpkg.com/react-jss@10.10.0/dist/react-jss.js"></script>

any update ?