@sjcrh/proteinpaint-shared
v2.189.0
Published
ProteinPaint code that is shared between server and client-side workspaces
Readme
@sjcrh/proteinpaint-shared
Background
This workspace was separate from the deprecated server/shared dir.
The code here are meant to be consumed at runtime by either client or server
code. Do NOT put utility/helper code here that are specific to only one
workspace, those files should be saved in that workspace.
IMPORTANT:
- code must work in browser and nodejs: do not import libs, deps, or globals that
are specific to
nodejsorbrowserenvironments, likefsorDOMelements
Develop
It is much simpler to import runtime code directly from @sjcrh/proteinpaint-shared,
or static code from @sjcrh/proteinpaint-shared/devTs, instead of specifying a code
filename.
For server dev, the tsx library will accept imports with or without file extension.
Server (consumer) code should use @sjcrh/proteinpaint-shared, or if for some reason
a shared file must be specific, it MUST use the .js file extension (e.g.,
#shared/someFile.js).
For client dev, the esbuild config will bundle the #shared imports correctly, even
when .js extension is used to import what is actually a .ts file, by using
custom plugins like dirname.
When importing types that are defined in shared/utils to shared/types dev,
always use @sjcrh/proteinpaint-shared/devTs (or an alias such as #shared/devTs).
Build
This package will be bundled as part of the client dependencies.
For server builds, run npm run build to generate src/*.js from src/*.ts files.
This is also automatically done as part of the prepack package script.
NOTE: For now, only code in .js files.
If using .ts files:
- commit the generated
.jsfiles - add the js file to package.json prettier command
keep doing this until a dev script or another approach can take care of the
.jsfile requirement.
Test
# run all tests
npm test
# run one script
node test/mds3tk.unit.spec.js