@nfdi4plants/swate-components
v2.0.4
Published
Customizable React components for ontology annotation, based on Swate and the ARC.
Readme
Components
Local Dev
Tests
- Once:
npm test - Watch:
npm run test:watch
Playground
npm start
Run Storybook
npm run storybook
Build Storybook
npm run build:storybook
Build Npm Package
npm run build
Test Npm Package
npm pack can be used to locally test the npm package before publishing it. It creates a .tgz file in the ./src folder. MUST run npm run build first to transpile the f# code and bundle the js code.
Can be references like this in a react test repo after moving the .tgz file to the test repo:
"dependencies": {
"@nfdi4plants/swate-components": "file:./nfdi4plants-swate-components-2.0.2.tgz",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},Build .NET Package
npm run build:net
Release
.NET
- Update version in
./src/Components.fsproj npm run build:net(creates tailwind style css and packs nuget package)- Upload nuget package from
./src/bin/Releases
NPM
- Release normally and copy
<new_version>from console output. npm version <new_version> --no-git-tag-versionnpm run build(transpiles with fable, creates tsc types, and bundles with rollup)- (Due to #701) replace
@layer basewith@layer swt-baseindist/swate-components.css npm publish --access public [--tag next](Use--tag nextfor prerelease)
Background info:
- Library MUST include swate styling via .css file.
- Library MUST be readable code (not minified) for easier debugging.
- Library MUST be tree-shakeable.
- Library MUST include proper TypeScript types.
- Library MUST preserve individual files to support dynamic imports in larger components (keyword preserveModules).
Question: Why transpile to
src/dist, instead of using the fable transpiled files next to the f# files?Answer: Because otherwise the vite tsc compiler cannot find the f# code from Swate.Components.Shared. By giving fable a specific output dir
src/dist, all code, including the f# code from Swate.Components.Shared, is in one place and tsc can find it.
Question: Why use a bundler, instead of uploading raw files.
Answer: some F# fable libraries use native .js files. These are difficult to copy to the correct locations using
tscor other "bundle" mechanisms without actually bundling the files. Rollup (used by vite) is a bundler that can handle this and also supports tree-shaking and other optimizations.
