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

refactor: drop assert syntax to support old and new nodejs versions #3036

Merged
merged 6 commits into from
Oct 9, 2024

Conversation

enesozturk
Copy link
Contributor

@enesozturk enesozturk commented Oct 8, 2024

Description

We are using the assert syntatic sugar to import JSON files. This has some issues:

  • In newer Node.js environments, assert has been replaced with with and it's not being supported.
  • In older Node.js environments, with is not supported.

So using these keywords are problematic and not using them too. So here we need to find another solution to make it work in both browser or server side environments (Next.js or similar frameworks)

This PR introduces changes to how we are getting the latest version while we generating the sdkVersion value in packages/appkit exports.

We can use prebuild and run a script on build time, and set the version from package.json to a file and use it anywhere. This will be processed only AppKit's build time. The consumer apps will be using the generated constant to create sdkVersion value on runtime.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-1204
For GH issues: closes #...

Showcase (Optional)

If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

changeset-bot bot commented Oct 8, 2024

🦋 Changeset detected

Latest commit: 154363a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@reown/appkit Patch
@apps/demo Patch
@apps/gallery Patch
@apps/laboratory Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-polkadot Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-utils Patch
@reown/appkit-cdn Patch
@reown/appkit-common Patch
@reown/appkit-core Patch
@reown/appkit-experimental Patch
@reown/appkit-polyfills Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-ui Patch
@reown/appkit-wallet Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
appkit-laboratory ✅ Ready (Inspect) Visit Preview Oct 9, 2024 6:31am
web3modal-gallery ✅ Ready (Inspect) Visit Preview Oct 9, 2024 6:31am

Copy link
Contributor

github-actions bot commented Oct 8, 2024

Coverage Report for Coverage

Status Category Percentage Covered / Total
🔵 Lines 321.83000000000004% 4410 / 19225
🔵 Statements 321.83000000000004% 4410 / 19225
🔵 Functions 343.16% 346 / 1030
🔵 Branches 379.87% 636 / 1327
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/appkit/exports/constants.ts 0% 0% 0% 0% 1
packages/appkit/exports/index.ts 0% 0% 0% 0% 1-2, 4, 7, 10, 17-22
packages/appkit/exports/react.ts 0% 0% 0% 0% 1, 3-5, 8, 11, 14, 19, 23-34, 36-37, 43
packages/appkit/exports/vue.ts 0% 0% 0% 0% 1, 3-5, 8, 11, 14, 19, 23-30, 32-33, 39
Generated in workflow #6687 for commit 154363a by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Oct 8, 2024

♻️ Vite-Size ♻️

Size Difference

Size (kb) Gzip (kb)
Total Diff. 0 0

Current Size

Name Size (kb) Gzip (kb)
assets/index--b-PVnFr.js 1890.843 539.617
assets/index.js 9.642 3.149
assets/index2.js 11.588 3.21
assets/w3m-modal.js 7.504 2.654
assets/noble-curves.js 31.941 12.778
assets/2.21.4_bufferutil.js 2.789 1.329
assets/index3.js 102.251 29.116
assets/index4.js 304.393 87.285
assets/hooks.module.js 74.286 25.525
index.html 0.329 0.234
Total Size 2435.566 704.897

Base Size

Name Size (kb) Gzip (kb)
assets/index--b-PVnFr.js 1890.843 539.617
assets/index.js 9.642 3.149
assets/index2.js 11.588 3.21
assets/w3m-modal.js 7.504 2.654
assets/noble-curves.js 31.941 12.778
assets/2.21.4_bufferutil.js 2.789 1.329
assets/index3.js 102.251 29.116
assets/index4.js 304.393 87.285
assets/hooks.module.js 74.286 25.525
index.html 0.329 0.234
Total Size 2435.566 704.897

@enesozturk enesozturk force-pushed the refactor/remove-assert-syntax-to-import-json branch from f05c514 to ff245fa Compare October 8, 2024 14:55
Copy link
Contributor

github-actions bot commented Oct 8, 2024

Warnings
⚠️ Changes were made to one or more package.json(s), but not to pnpm-lock.yaml

Generated by 🚫 dangerJS against 154363a

@enesozturk enesozturk merged commit 23a7613 into main Oct 9, 2024
15 checks passed
@enesozturk enesozturk deleted the refactor/remove-assert-syntax-to-import-json branch October 9, 2024 06:46
@github-actions github-actions bot mentioned this pull request Oct 9, 2024
Copy link

linear bot commented Oct 9, 2024

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 this pull request may close these issues.

2 participants