fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.58k stars 692 forks source link

Toasts works locally, but not in my private npm package #931

Open ampratt opened 1 year ago

ampratt commented 1 year ago

I have just updated from react-toastify v7.0.x to the current 9.1.1, as well as migrated my CRA react app to Vite

I have a set of shared components that get published in a private npm repo and one is a notifications component like this

export function useNotifications() {

  const showSuccess = useCallback((title: string = "Successfully processed request", content?: any, options?: ToastOptions) => {
    toast.success(<NotificationContent title={title} content={content} />, {
      toastId: uid(),
      ...defaultToastOptions,
      ...options
    });
  }, []);
...

  return { showSuccess, showInfo, showWarning, showError };
}

Now that I have updated and am using Vite, this component still works when I import it locally, but it does not work when I import from my shared component.

I do get this warning, but it comes regardless of where I take the import from and it still works locally

15.31.26 [vite] warning:
/node_modules/.vite/deps/chunk-RAKPKEOZ.js
27 |  });
28 |  import { default as default2 } from "/node_modules/react-toastify/dist/ReactToastify.min.css";
29 |  import * as ReactToastify_min_star from "/node_modules/react-toastify/dist/ReactToastify.min.css";
   |                                           ^
30 |  var init_ReactToastify_min = __esm({
31 |    "vite:dep-pre-bundle:external-conversion:/node_modules/react-toastify/dist/ReactToastify.min.css"() {
Default and named imports from CSS files are deprecated. Use the ?inline query instead. For example: import * as ReactToastify_min_star from "/node_modules/react-toastify/dist/ReactToastify.min.css?inline"
fkhadra commented 1 year ago

Hey @ampratt do you have a repo to share ?

ampratt commented 1 year ago

No i don't. It is in a private repo that cannot be shared unfortunately

ampratt commented 1 year ago

when reverting back to version 7.0.4 it works again

ulitol97 commented 1 year ago

Same issue here. For the moment I solved it by downgrading from version 9 to 8.

fkhadra commented 1 year ago

Are you using the latest vite ?

ulitol97 commented 1 year ago

No, just create-react-app with TS