Open faheemfactor opened 1 year ago
a temp fix for next.js
const reactAbac = dynamic(() => import('react-abac'), { ssr: false })
reactAbac.create
@faheemfactor, thanks for your bug report, I hope to look at this issue ASAP I will keep you informed.
Any update? Temp fix is not working using import { useAbac } hook
while waiting for official fix - you can always patch dependency (either natively by package manager like PNPM https://pnpm.io/cli/patch or Yarn) or with 3rd party tools like https://www.npmjs.com/package/patch-package for NPM
And fix/patch itself is quite simple - you just have to rename file extension from .js
to .cjs
as suggested in error and update path for it in package.json
. Here is full patch
diff --git a/dist/index.js b/dist/index.cjs
similarity index 100%
rename from dist/index.js
rename to dist/index.cjs
diff --git a/package.json b/package.json
index 2b58fe260d4d8e16d606036780afc2326f65e866..228dc0d62a68fd30a1489d8715ad922dae7dd3be 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
},
"license": "ISC",
"author": "Rik Hoffbauer",
- "main": "dist/index.js",
+ "main": "dist/index.cjs",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"type": "module",
React or Next.js build gives error for custom implementation
To Reproduce Steps to reproduce the behavior:
Go to create a next.js project with typescript
implement custom implementation package.json :
"react-abac": "^0.1.13",
run next build.
See error Attempted import error: 'create' is not exported from 'react-abac' (imported as 'create').