@algorandfoundation/algokit-utils 5.1.3-beta.1 → 5.1.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,30 @@ npm install @algorandfoundation/algokit-utils
|
|
|
20
20
|
|
|
21
21
|
This library follows the [Guiding Principles of AlgoKit](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/algokit.md#guiding-principles).
|
|
22
22
|
|
|
23
|
+
## NextJS compatibility
|
|
24
|
+
|
|
25
|
+
`algokit-utils-ts` has a set of `node` specific utilities used for simplifying aggregation of artifacts for [AlgoKit VSCode Debugger Extension](https://github.com/algorandfoundation/algokit-avm-vscode-debugger). Which causes Next.js based projects to fail on `fs` module not found. To fix this issue, you can add the following to your `next.config.js` file:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
webpack: (config, { isServer }) => {
|
|
29
|
+
// Fix for Module not found: Can't resolve 'fs'
|
|
30
|
+
if (!isServer) {
|
|
31
|
+
config.resolve.fallback.fs = false;
|
|
32
|
+
}
|
|
33
|
+
return config;
|
|
34
|
+
},
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The root cause is due to the fact that, unlike many frameworks, Next.js allows you to import server-only (Node.js APIs that don't work in a browser) code into your page files. When Next.js builds your project, it removes server only code from your client-side bundle by checking which code exists inside one any of the following built-in methods (code splitting):
|
|
38
|
+
|
|
39
|
+
- getServerSideProps
|
|
40
|
+
- getStaticProps
|
|
41
|
+
- getStaticPaths
|
|
42
|
+
|
|
43
|
+
The Module not found: can't resolve 'xyz' error happens when you try to use server only code outside of these methods. Despite `algokit-utils` lazy loading the node specific code dynamically, Next.js does not seem to correctly identify whether a dynamic import is specific to server or client side. Hence the above fix disables the fallback for `fs` module so it ignores polyfilling it on client side.
|
|
44
|
+
|
|
45
|
+
Future iterations of `algokit-utils` will remove the node specific code by integrating with `rollup` to create more optimized browser compatible bundles.
|
|
46
|
+
|
|
23
47
|
## Contributing
|
|
24
48
|
|
|
25
49
|
This is an open source project managed by the Algorand Foundation. See the [AlgoKit contributing page](https://github.com/algorandfoundation/algokit-cli/blob/main/CONTRIBUTING.md) to learn about making improvements.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"main": "./cjs/index.js",
|
|
3
3
|
"types": "./types/index.d.ts",
|
|
4
4
|
"name": "@algorandfoundation/algokit-utils",
|
|
5
|
-
"version": "5.1.
|
|
5
|
+
"version": "5.1.4-beta.1",
|
|
6
6
|
"private": false,
|
|
7
7
|
"description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
|
|
8
8
|
"author": "Algorand Foundation",
|