Publishing a New Version
Relevant source files
The following files were used as context for generating this wiki page:Publishing a new version of the sui-svelte-wallet-kit package involves a series of automated steps managed by pnpm scripts. These scripts handle version bumping, building the package from source, and publishing it to the npm registry. A pre-publish check script is also available to ensure the package is valid and complete before it is released.
The process is designed to be straightforward for developers, with dedicated commands for patch, minor, and major version updates. The build system uses svelte-package to compile the Svelte components and TypeScript code into a distributable format, which is placed in the dist directory.
Publishing Scripts
The package.json file defines several scripts to automate the publishing process. These scripts combine versioning, building, and publishing into single commands.
Sources: package.json:23-25
| Script | Command | Description |
|---|---|---|
publish:patch | pnpm version patch && pnpm build && pnpm publish | Bumps the patch version, builds the package, and publishes it. |
publish:minor | pnpm version minor && pnpm build && pnpm publish | Bumps the minor version, builds the package, and publishes it. |
publish:major | pnpm version major && pnpm build && pnpm publish | Bumps the major version, builds the package, and publishes it. |
This diagram illustrates the sequence of actions when a developer runs a publishing script, such as pnpm run publish:patch.
Sources: package.json:14-25
Build Process
The core of the build process is handled by the package and build scripts, which utilize SvelteKit's packaging and build tools.
package:svelte-kit sync && svelte-package. This command is responsible for creating the distributable package. It generates the necessary JavaScript and TypeScript declaration files in thedistdirectory.prepack:pnpm run package. This is a standard npm script that runs automatically before the package is packed for publishing. It ensures thepackagescript is executed.build:svelte-kit sync && vite build. This command is used for building the demo application, which is deployed to Netlify. The output is placed in thebuilddirectory.
Sources: package.json:16-18, netlify.toml:2-3
The following flowchart shows how the prepack script triggers the packaging process.
Sources: package.json:17-18
Package Configuration
The package.json file specifies which files are included in the final npm package and defines the entry points for consumers.
Included Files
Only the dist directory is included in the published package. Test and spec files within dist are explicitly excluded.
"files": [
"dist",
"!dist/**/*.test.*",
"!dist/**/*.spec.*"
],
Sources: package.json:27-31
Package Exports
The exports field defines the module entry points. This allows consumers to import specific components like ConnectButton or the main SuiModule. Each entry point maps to its corresponding JavaScript and TypeScript declaration files within the dist directory.
"exports": {
".": {
"types": "./dist/index.d.ts",
"svelte": "./dist/index.js"
},
"./ConnectButton": {
"types": "./dist/ConnectButton/index.d.ts",
"svelte": "./dist/ConnectButton/index.js"
},
"./ConnectModal": {
"types": "./dist/ConnectModal/index.d.ts",
"svelte": "./dist/ConnectModal/index.js"
},
"./SuiModule": {
"types": "./dist/SuiModule/index.d.ts",
"svelte": "./dist/SuiModule/index.js"
}
},
Sources: package.json:38-59, src/lib/index.d.ts, src/lib/SuiModule/index.js
Pre-Publish Sanity Check
A shell script, scripts/publish-check.sh, is provided to manually verify that the package is ready for publication. This script is not run automatically by the publish:* commands but can be executed by a developer for confidence.
Sources: README.md:330-331, scripts/publish-check.sh
The script performs the following checks:
- Verifies Required Files: Ensures
package.json,README.md,LICENSE, andsrc/lib/index.tsexist. - Verifies
package.jsonFields: Checks for the presence ofname,version, anddescription. - Builds the Package: Runs
pnpm run prepackto build the distributable files. - Verifies Build Output: Confirms that the
distfolder and the main entry files (dist/index.js,dist/index.d.ts) were created successfully.
This flowchart details the logic of the publish-check.sh script.
Sources: scripts/publish-check.sh:5-44
If all checks pass, the script prints instructions for publishing to npm.
🎉 Package is ready for publication!
To publish:
1. Make sure you're logged in to npm: npm login
2. Run: npm publish
Or for a dry run: npm publish --dry-run
Sources: scripts/publish-check.sh:46-53
Summary
The publishing process for sui-svelte-wallet-kit is a streamlined workflow centered around pnpm scripts. These scripts automate versioning, building, and publishing, while a separate check script provides a manual safeguard to ensure package integrity. The package.json file acts as the central configuration, defining the package structure, its entry points, and the scripts that manage its lifecycle.