Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tree-shake ipfs-unixfs-importer #31

Open
SgtPooki opened this issue Mar 25, 2024 · 2 comments
Open

feat: tree-shake ipfs-unixfs-importer #31

SgtPooki opened this issue Mar 25, 2024 · 2 comments

Comments

@SgtPooki
Copy link
Member

since we're not using any importing functionality in verified-fetch, we should make sure our resulting bundle does not include ipfs-unixfs-importer (or others.. which can be handled in separate issue)

running npm why ipfs-unixfs-importer in helia-service-worker-gateway shows the following:

ipfs-unixfs-importer@15.2.4
node_modules/ipfs-unixfs-importer
  ipfs-unixfs-importer@"^15.2.4" from @helia/unixfs@3.0.2
  node_modules/@helia/unixfs
    @helia/unixfs@"^3.0.1" from @helia/verified-fetch@1.3.0
    node_modules/@helia/verified-fetch
      @helia/verified-fetch@"^1.3.0" from the root project

Can we explicitly remove ipfs-unixfs-importer during esbuild, or do we need to modify @helia/unixfs to export a "getter only" version?

@SgtPooki
Copy link
Member Author

with regular build:

╰─ ✔ ❯ npm run build -- -b

> @helia/verified-fetch@1.3.1 build
> aegir build -b

[10:41:55] tsc [started]
[10:41:56] tsc [completed]
[10:41:56] esbuild [started]
[10:41:56] → Use https://esbuild.github.io/analyze/ to load "./dist/stats.json".
[10:41:56] → 124.57KB (▼-7.43KB / 132KB)
[10:41:56] esbuild [completed]
image

with ipfs-unixfs-importer marked as external

╰─ ✔ ❯ npm run build -- -b

> @helia/verified-fetch@1.3.1 build
> aegir build -b

[10:44:25] tsc [started]
[10:44:26] tsc [completed]
[10:44:26] esbuild [started]
[10:44:27] → Use https://esbuild.github.io/analyze/ to load "./dist/stats.json".
[10:44:27] → 116.04KB (▼-15.96KB / 132KB)
[10:44:27] esbuild [completed]

.aegir.js changes:

diff --git a/packages/verified-fetch/.aegir.js b/packages/verified-fetch/.aegir.js
index 89b5633..cbd9809 100644
--- a/packages/verified-fetch/.aegir.js
+++ b/packages/verified-fetch/.aegir.js
@@ -1,8 +1,13 @@
 /** @type {import('aegir').PartialOptions} */
 const options = {
   build: {
-    bundlesizeMax: '132KB'
-  }
+    bundlesizeMax: '132KB',
+    config: {
+      external: [
+        'ipfs-unixfs-importer'
+      ],
+    }
+  },
 }

 export default options

Note that tests still pass with ipfs-unixfs-importer marked as external

@SgtPooki
Copy link
Member Author

SgtPooki commented Apr 8, 2024

this will be resolved by #32 eventually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant