Opal Frontend Common Node Library Guidelines
Overview
Use these rules to keep work aligned with the library structure, build tooling, and public API.
Project Structure
src/contains TypeScript source organized by feature folders (app-insights/,csrf-token/,health/,helmet/,session/, etc.).src/interfaces/holds shared types;src/index.tsre-exports public modules.src/*.d.ts(for examplesrc/global.d.tsandsrc/session.d.ts) provide ambient typings and are copied todist/by the build.dist/is build output and should be generated viayarn build(do not hand-edit).
Build, Lint, and Audit Commands
yarn buildrunsclean, compiles TypeScript, and copies root ambient.d.tsfiles todist/.yarn pack:localrunsprepack(yarn build) and creates a fresh local.tgzartifact in repo root for consumer testing.yarn check:exportsvalidates everypackage.jsonexport target exists indist/.yarn check:exports:esmsmoke-tests ESM import of all public subpaths.yarn check:pack-shapevalidates packed tarball contents againstexports,types, andtypesVersions.npm pack --dry-runshows exact publish payload; run it whenever package surface changes.yarn cleanremovesdist/.yarn lintruns ESLint oversrc/and Prettier checks.yarn prettierchecks formatting;yarn prettier:fixformats in place.yarn audit:saveupdatesyarn-known-issues;yarn audit:checkcompares against current advisories (requiresjq).
Export Map and Public API
- This package is ESM (
"type": "module"). Keep imports/exports in ESM style. package.jsonexportsis the source of truth for published entry points.- Keep subpath exports explicit and intentional; do not rely on unpublished deep imports into
dist/. - Every exported subpath should have both runtime (
.js) and declaration (.d.ts) targets that exist after build and are included in the packed tarball. - When adding or removing a public module, update all of:
package.jsonexportssrc/index.ts(top-level re-exports)tsconfig.jsonpaths(local TS resolution)src/<module>/index.ts(module-local exports)typesVersions(if needed for legacy TS resolver compatibility)- any required ambient
.d.tsinsrc/so it is copied todist/
Packaging Gate (Required for Package-Surface Changes)
- Apply this gate when changing
exports,types,typesVersions,files, build output layout, or publish scripts. - Run:
yarn build. - Run:
yarn check:exports. - Run:
yarn check:exports:esm. - Run:
yarn check:pack-shape. - Run:
npm pack --dry-run. - Treat any failure as blocking until resolved.
Coding Style
- Follow
.editorconfigand.prettierrc: 2-space indent, single quotes in TS, 120 print width, semicolons. - Keep class members ordered per
@typescript-eslint/member-orderingineslint.config.js. - Prefer small, focused modules; avoid unnecessary side effects at import time.
Tooling and Environment
- Node.js v18+ and Yarn v4.x (Berry) (per
package.jsonandREADME.md). tsconfig.jsonuses strict mode; avoidanyand keep types explicit.
Publishing
- Bump the version in
package.json, create a GitHub release with that tag, and wait for the release workflow to publish (seeREADME.md). dist/is generated duringyarn buildand is not committed.- Publish from the repository root
package.json(single source of truth). - Do not generate or copy a second
package.jsonintodist/. - For local consumer testing, install from the generated
.tgz(yarn pack:local) rather than linking the raw repository folder.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.