The Nym TypeScript SDK comes with two main examples:
- `plain-html`
- `react-webpack-with-theme-example`
As of time of testing on the latest `develop` branch over at
@nymtech/nym, `react-webpack-with-theme-example` was broken because the
example was expected to load some of its packages from its own
`package.json` and the rest from the repository's root `package.json`,
which caused the problems outlined here:
https://stackoverflow.com/q/72413194
While addressing this issue, I noticed that the examples were not truly
independent from the rest of the repo. While I know that this is a
monorepo with mulitple workspaces and understand how that's supposed to
work, I think that specifically in the case of example folders, we need
to ensure the ability for these folders to work fully independently from
the rest of the repository, because example folders are overwhelmingly
likely to be copied out of the repo to be expected by curious third
parties to work while fully self-contained. Furthermore, this makes
resolving the above-mentioned original issue easier.
Therefore, in this commit, I did the following for both `plain-html` and
`react-webpack-with-theme-example`:
- Ensure that their `package.json`s are fully self-sufficient and that
no packages would need to be loaded from the repository's root
`package.json`.
- Ensure that their `tsconfig.json` are equally self-sufficient and do
not reference the repository's root `tsconfig.json`.
- Ensure that the webpack configuration is present in each example,
instead of being snuck into a hidden `.webpack` folder in the
`sdk/typescript/examples` folder (this struck me as an ugly hack
anyhow).
- Ensure that `react-webpack-with-theme-example` has direct access to a
small SVG graphic of the Nym logo within its own folder.
I think these changes will both render the examples less likely to break
as the rest of the monorepo evolves. Freezing dependencies in time is
not appropriate for the monorepo, but it is totally appropriate for
examples since we don't really care about migrating them to the latest
best practices/security fixes for their dependencies as much.
Also, these changes will make the example folders more friendly for
third-party engineers, since they can just copy out the example folder
from the repo and have everything they need to understand how things
work within the example folder itself, instead of needing to hunt down
other files in the sprawling monorepo.