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

Implement Typescript and ESM, and add Parcel for builds #27

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ericfennis
Copy link

@ericfennis ericfennis commented Jan 4, 2024

Closes #15

What is changed

I've implemented a typescript for each package except yivi-console, yivi-dummy and yivi-css.
Typescript is implemented with the weakest setting strict: false in the tsconfig.json, meaning that there is almost no "type safety", but that can be improved later to keep this PR as minimal as possible.
Typescript with strict: false is almost the same as ESM.

To support different environments, like NodeJS and bundlers like Vite a bundler is needed to output script for each environment. I've added Parcel, which is a super simple bundler, that uses the package.json entry paths (module, main, browser, source, etc) to configure the bundle configuration.

In yivi-frontend I've replaced the package imports with relative paths since the bundler doesn't like "external" packages to be built in, It is possible but costs some effort to make that work. And since these packages are "DEV" only and bundled in using relative paths, they are bit easier. An alternative strategy is to make them "external", but then it is required to mark them as "dependencies" in package.json.

Future improvements

NPM workspaces

I would recommend switching this repo to NPM Workspaces, which is designed and made for frontend mono repo. For example, makes installing the package much easier, for example running npm install from the root.

Typescript typing

After this PR there are a lot of types of "any" which is not benefit from the power of typescript. Making things strictly typed will help prevent bugs in the future

Testing

I would recommend starting with writing some tests for these packages to make sure everything is working correctly in the future. You may not realizing that this library will grow in the coming years, since Yivi is getting some attention lately.

@ivard
Copy link
Member

ivard commented Jan 8, 2024

Currently, there are no developers on the Yivi project. Therefore, this code will not be reviewed anywhere soon. It is not clear yet how this will look like.

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.

ESM support for all Yivi packages
2 participants