From 0f3ad285367bb9d36a9e9f5c46ab224f1cdda76f Mon Sep 17 00:00:00 2001 From: Luke Shiels <47612057+skve@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:04:20 +0100 Subject: [PATCH] Fix compile error on Next.js 12 (Directory import) We're using `react-rxjs` but have transitioned away to an SSR framework, however Node doesn't seem to support this syntax of importing from a directory without specifically writing `index.js`. Installing `react-rxjs` on a freshly setup Next.js project yields the following error when trying to import `bind` from `@react-rxjs/core`: ``` Error: Directory import '**/node_modules/use-sync-external-store/shim' is not supported resolving ES modules imported from **/node_modules/@react-rxjs/core/dist/core.es2019.mjs Did you mean to import use-sync-external-store/shim/index.js? ``` --- packages/core/src/internal/useObservable.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/internal/useObservable.ts b/packages/core/src/internal/useObservable.ts index 46afc46..e9a0794 100644 --- a/packages/core/src/internal/useObservable.ts +++ b/packages/core/src/internal/useObservable.ts @@ -1,5 +1,5 @@ import { Subscription } from "rxjs" -import { useSyncExternalStore } from "use-sync-external-store/shim" +import { useSyncExternalStore } from "use-sync-external-store/shim/index.js" import { useRef, useState } from "react" import { SUSPENSE, filterOutSuspense } from "../SUSPENSE" import { DefaultedStateObservable, StateObservable } from "@josepot/rxjs-state"