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: add create react app example #714

Merged
merged 5 commits into from
Jun 14, 2024
Merged

Conversation

twhy
Copy link
Contributor

@twhy twhy commented Jun 14, 2024

Description

This PR

  1. Removed webpack configs in next.config.mjs in nextjs example
  2. Add a create-react-app example that use Lumos in browsers without extra configs.

Why there's no Vite example ?
I tried to create a vite example in lumos/examples but it/vite/rollup didn't convert commonjs modules to es6.
So when I import and use Lumos there's a exports is not defined error, and I didn't find any solution yet.
There's no such errors when use vite with standalone projects (not in monorepo)

We can publish a preivew version of this branch, e.g 0.30.0.preview and create standalone projects (vite, nextjs, create-react-app) to install the preview version and test the browser compatibility related changes.

Type of change

Please delete options that are not relevant.

  • Example

How Has This Been Tested?

Unit Tests

Copy link

vercel bot commented Jun 14, 2024

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

Name Status Preview Updated (UTC)
lumos-website ✅ Ready (Inspect) Visit Preview Jun 14, 2024 4:55am

@twhy twhy requested a review from homura June 14, 2024 03:27
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.11%. Comparing base (fec185f) to head (e812595).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           browser     #714      +/-   ##
===========================================
+ Coverage    84.76%   87.11%   +2.34%     
===========================================
  Files          132      132              
  Lines        25249    25249              
  Branches      2594     2736     +142     
===========================================
+ Hits         21403    21996     +593     
+ Misses        3810     3212     -598     
- Partials        36       41       +5     
Files Coverage Δ
packages/crypto/src/index.ts 100.00% <100.00%> (ø)

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fec185f...e812595. Read the comment docs.

@homura
Copy link
Collaborator

homura commented Jun 14, 2024

I couldn't find a use case related to Lumos in this example. Could you please import Lumos to the window.lumos to demonstrate its compatibility with CRA without additional configurations?

@twhy
Copy link
Contributor Author

twhy commented Jun 14, 2024

I couldn't find a use case related to Lumos in this example. Could you please import Lumos to the window.lumos to demonstrate its compatibility with CRA without additional configurations?

Yes. I already did it in examples/create-react-app/src/index.js

@twhy twhy requested a review from homura June 14, 2024 04:47
@homura
Copy link
Collaborator

homura commented Jun 14, 2024

There's no such errors when use vite with standalone projects (not in monorepo)

The Lumos without node modules have not been published yet. How can you confirm that Lumos works fine with standalone projects created by Vite?

@twhy
Copy link
Contributor Author

twhy commented Jun 14, 2024

There's no such errors when use vite with standalone projects (not in monorepo)

The Lumos without node modules have not been published yet. How can you confirm that Lumos works fine with standalone projects created by Vite?

  1. I created a standalone vite project and install @ckb-lumos/bi (commonjs) and run console.log(BI.from(1).add(99).toString()) and it works.
  2. nextjs and create-react-app examples show that our latest changes works.

So to simulate a developer's behavior, we probably need to publish a preview/dev version, and setup 3 (vite, nextjs, create-react-app) standalone proejcts, install Lumos and test it to make sure everything works.

@twhy twhy requested a review from homura June 14, 2024 05:43
@homura
Copy link
Collaborator

homura commented Jun 14, 2024

I created a standalone vite project and install @ckb-lumos/bi

I think @ckb-lumos/bi is too simple to be used as an example. Could you please validate it with Verdaccio in your local environment?

@twhy
Copy link
Contributor Author

twhy commented Jun 14, 2024

I created a standalone vite project and install @ckb-lumos/bi

I think @ckb-lumos/bi is too simple to be used as an example. Could you please validate it with Verdaccio in your local environment?

I try Verdaccio but can't add user.

So I published all packages with a different name

[email protected]
[email protected]
...
[email protected]

and created 3 standalone projects

ckt-lumos-cra
ckt-lumos-vite
ckt-lumos-next

installed [email protected] and exposed a lumos object to window.

They all work well.

@homura
Copy link
Collaborator

homura commented Jun 14, 2024

Verified with Vite by installing ckt-lumos-lumos, it works well

@homura homura merged commit e8a2b53 into browser Jun 14, 2024
9 checks passed
@twhy twhy deleted the example-create-react-app branch June 14, 2024 09:31
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