waspc/data/Generator/libs/auth/README.md
This library exports code related to Wasp's auth which is used in the generated Wasp apps' code.
The has multiple entry points:
sdk - used in the Wasp SDK in any runtime (@wasp.sh/lib-auth/sdk)sdk/browser - used in the Wasp SDK in the browser runtime (@wasp.sh/lib-auth/sdk/browser)server - used in the server app (@wasp.sh/lib-auth/server)Read more about the naming convention for exports in the parent README.
Read more about versioning and why we pin the version to 0.0.0 in the parent README.
Install the dependencies:
npm install
Start unit tests in watch mode:
npm run dev
Develop code and write unit tests for it.
When you need to add a new entry point e.g. @wasp.sh/lib-auth/web-app:
Add a new entry in tsdown.config.ts with the name and entry path.
createNewEntry({
name: "web-app", // Name of the file in the dist directory i.e. web-app.js
entryPath: "./src/web-app/index.ts",
platform: "browser",
}),
Add the new entry to exports in package.json.
"exports": {
"./web-app": {
"types": "./dist/web-app.d.ts",
"import": "./dist/web-app.js"
}
}
We have a few tests that we run to ensure the library is in good shape. You can run them all at once with:
npm run test
To check the test coverage, run:
npm run test:coverage
To type check the code, run:
npm run test:types
This test uses arethetypeswrong under the hood which:
attempts to analyze npm package contents for issues with their TypeScript types, particularly ESM-related module resolution issues
We use the --profile esm-only when running the test because we only care about the ESM related tests since this library will be only imported using ESM.
To test the type exports are okay run:
npm run test:type-exports
You want to see 🟢 for all ESM related tests since this library will be only imported using ESM. This means the library's
types will resolve correctly when used in the SDK, the server and the web app.
To build the library, run:
npm run build
We are using tsdown to build the library which you can configure in tsdown.config.ts.