Skip to content

Conversation

JacobLinCool
Copy link
Contributor

@JacobLinCool JacobLinCool commented Jan 12, 2022

I assume that most of this project are inherited from lxieyang/chrome-extension-boilerplate-react.
And there are many things that we don't need.

Replace Webpack with esbuild + script

I think it is not necessary to use fat webpack as the bundler. And the webpack.config.js is hard to read.
I replaced it with esbuild, which is faster, and a short and readable build script that does the same thing as webpack.

Code Standards and Refactoring

I noticed that some sources use import * as React from "react" and the others use import React from "react".
I replaced them all with the latter.

For type declarations, I moved all of them into types.ts, and import them in other files when using.
I believe it is more easier to manage them and people working on other projects like vite and slidev are doing the same thing.

I also use import type to replace import when importing types and interfaces.

The order of import statements:

  1. import type from package
  2. import type from local
  3. import from package
  4. import from local

I also update the prettier rules:

  • tabWidth: 2 -> 4
  • singleQuote: true -> false
  • printWidth: 90 -> 120

My reason is: The screen should wide enough although in the portrait mode and double quote make strings string.

Make Eslint Work

I notice that the eslint did not work properly so I add typescript plugin and prettier plugin.
I also add a lint npm script in package.json.

Retry on Fetch Failed

Add Feature: #4

If the fetch response is not ok (2XX), then it will be rejected and trigger retry handler. (up to 3 times, can be modified)

Tested. Works when I turned off my network, it behaves as expected. (Failed three times)

GitHub Action That Generate Release Asset

Add Feature: #3

Not Tested. It should be triggered when the tag exists.

Some of the changes are just "my opinion" so feel free to discuss.

@uier
Copy link
Owner

uier commented Jan 19, 2022

Hi @JacobLinCool, Greak work!
Very much appreciate your suggestions and contributions.

As you said, the inherited boilerplate didn't being updated yet.
So thanks for your improvement for the build system and code style :)

Only one thing, it would be great to create a new branch when working on feature/bugfix in your forked repo.
e.g. JacobLinCool:feat/refactoring-and-features -> Uier:main

What do you think?

Other changes look great to me, and I'll merge it after the branching issue.

@JacobLinCool
Copy link
Contributor Author

@uier

Thanks for your reply.

I opened another PR (#6) with same commit history, but from different branch feat/refactoring-and-features.

Closing the old one now.

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.

Retry when fetch failed Add GitHub Actions to build extension as Assets when Release
2 participants