Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,65 @@ A shared package for create-rspack, create-rsbuild, create-rspress and create-rs
npm add create-rstack -D
```

## Features

### NPM Template Support

`create-rstack` supports using npm packages as templates, allowing users to create projects from custom templates published to npm.

#### Usage

```bash
# Using npm package name
npm create rsbuild@latest my-project -- --template my-template-package

# Using scoped package
npm create rsbuild@latest my-project -- --template @scope/template-package

# Using explicit npm: prefix
npm create rsbuild@latest my-project -- --template npm:my-template-package

# With specific version
npm create rsbuild@latest my-project -- --template my-template-package --template-version 1.2.3
```

#### Template Package Structure

Your npm template package should have one of the following structures:

```
my-template-package/
├── template/ # Preferred
│ ├── package.json
│ └── src/
├── templates/
│ └── app/ # Alternative
└── (root) # Fallback
├── package.json
└── src/
```

#### Caching Strategy

- Templates with `latest` version are always re-installed to ensure the latest version
- Specific versions are cached in `.temp-templates/` for faster reuse

#### API

```typescript
import {
isNpmTemplate,
resolveCustomTemplate,
resolveNpmTemplate,
} from 'create-rstack';

// Check if template input is an npm package
if (isNpmTemplate(templateInput)) {
// Resolve npm template to local path
const templatePath = resolveCustomTemplate(templateInput, version);
}
```

## Examples

| Project | Link |
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@rslib/core": "0.20.1",
"@rslint/core": "^0.3.3",
"@rstest/core": "0.9.5",
"@types/cross-spawn": "^6.0.6",
"@types/fs-extra": "^11.0.4",
"@types/minimist": "^1.2.5",
"@types/node": "24.12.0",
Expand All @@ -65,5 +66,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"cross-spawn": "^7.0.6"
}
}
58 changes: 58 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading