ES Modules + Prettier + FossilRecord class + node http-server + webpack dev source map #157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request brings a few quality of life changes to the codebase while modernizing a few things.
The biggest change is that all source files now use the modern ES Module
import
andexport
system. This replaces the oldrequire()
of commonjs modules.I have also added prettier for consistent code formatting and applied it to all files. A good IDE such as vscode should automatically apply prettier styling when you save a file. The configuration is in
.prettierrc
. If there are disagreements about what the specific code style should be, then it can be changed in there.Originally I was going to add tests but decided against it. In the course of testing however I saw that the
FossilRecord
was not easily independently testable because it was a global object. There are many such global singleton objects in the project and in the future they should probably be turned into true classes and passed around or even just left as a singleton instance globally. In this PRFossilRecord
is turned into a class and it is no longer global.The setup instructions in the README suggest using python for hosting the local webserver. This is fine, but it is easier to just use the
http-webserver
package in node. I have added it to dev dependencies and added the scriptserve
to thepackage.json
. People don't have to install python for the local webserver anymore. Once they've rannpm install
they can just runnpm run serve
to start the webserver.Final thing, the old
webpack.config
didn't actually make it easier to debug when you run it in--mode=development
. Now when you build in development mode it uses the source map devtool to give you complete access to the source in your browser's devtools. I also rewrote the webpack config in typescript to check its correctness (and to be able to use ES Module imports). In the future adding types to the whole project would be a worthy endeavor. Going through the code I found a few instances where variables were assigned to the incorrect type. These would've been caught if it was type checked.