Skip to content

dmblock/lse-typescript-template

Repository files navigation

LSE TypeScript Template

中文 | English


中文

📖 项目简介

LSE TypeScript 模板是一个用于创建 LeviLamina LSE 的现代化 TypeScript 开发模板。它提供了完整的开发工具链,支持最新的 TypeScript 语法和 ES 模块,让您能够快速开发高性能的 Minecraft 服务器插件。

GitHub 仓库: https://github.com/dmblpck/lse-typescript-template

✨ 特性

  • 🚀 现代化开发体验:使用 TypeScript 5.9+ 和 ES 模块
  • 快速构建:基于 Rolldown 的高性能构建工具
  • 🔧 完整类型支持:内置 @levimc-lse/types 类型定义
  • 📦 自动打包:将多个模块自动打包为单个文件
  • 🔄 热重载开发:支持开发模式下的文件监听和自动重建
  • 🎯 代码提示:完整的 IntelliSense 和自动补全支持
  • 📁 模块化结构:清晰的目录结构和模块分离

🚀 快速开始

前提条件

  • Node.js 18+ 或更高版本
  • pnpm 10.23.0+(推荐)或 npm / yarn
  • LeviLamina 服务器环境

安装

  1. 克隆仓库

    git clone https://github.com/dmblpck/lse-typescript-template.git
    cd lse-typescript-template
  2. 安装依赖

    pnpm install

    或使用 npm:

    npm install
  3. 开发模式

    pnpm dev

    这将启动开发服务器,监听文件变化并自动重建。

  4. 构建项目

    pnpm build

    构建产物将输出到 dist/bundle.js

📚 使用教程

项目结构

lse-typescript-template/
├── src/
│   ├── index.ts          # 主入口文件
│   └── config.ts         # 配置文件(可选)
├── dist/                 # 构建输出目录
├── rolldown.config.ts    # 构建配置
├── tsconfig.json         # TypeScript 配置
├── package.json          # 项目依赖和脚本
└── README.md             # 项目文档

编写代码

src/index.ts 中,您可以直接使用 mcll 等全局模块,完全支持 TypeScript 类型提示:

// 监听玩家加入事件
mc.listen('onJoin', (player) => {
    log(`${player.name} 加入了服务器!`)
    player.sendToast(`欢迎来到服务器,${player.name}!`, '玩得开心!')
})

导入其他模块

您可以使用 ES 模块语法导入其他文件:

import { config } from './config'

// 使用导入的配置
log(`服务器名称: ${config.serverName}`)

配置说明

  • TypeScript 配置 (tsconfig.json):已配置为支持 LeviLamina LSE 开发,目标为 ES2024,使用 CommonJS 模块
  • 构建配置 (rolldown.config.ts):使用 Rolldown 打包,输入为 src/index.ts,输出为 dist/bundle.js (CommonJS 格式)
  • 环境变量:支持 .env 文件(通过 dotenv 依赖)

开发工作流

  1. 开始开发:运行 pnpm dev 进入开发模式
  2. 编写代码:在 src/ 目录下创建新的 TypeScript 文件
  3. 测试代码:将构建后的 dist/bundle.js 复制到 LeviLamina 服务器的插件目录
  4. 调试:查看服务器日志以调试您的插件
  5. 构建发布:运行 pnpm build 生成最终版本

📦 可用脚本

  • pnpm dev - 启动开发模式,监听文件变化并自动重建
  • pnpm build - 构建生产版本到 dist/bundle.js
  • pnpm install - 安装项目依赖

🛠️ 开发指南

添加新依赖

pnpm add <package-name>

类型定义

项目已包含 @levimc-lse/types,提供了完整的 Minecraft 服务器 API 类型定义。您可以在代码中直接使用这些类型,获得完整的代码提示。

自定义构建配置

如果需要修改构建配置,可以编辑 rolldown.config.ts 文件:

import { defineConfig } from 'rolldown'

export default defineConfig({
  input: 'src/index.ts',
  output: {
    file: 'dist/bundle.js',
    format: 'cjs',
    sourcemap: true, // 启用源映射以方便调试
  },
  external: ['ll', 'mc'],
  platform: 'node',
  tsconfig: './tsconfig.json',
})

环境变量配置

创建 .env 文件来配置环境变量:

SERVER_NAME=My Minecraft Server
DEBUG_MODE=true

然后在代码中使用:

import 'dotenv/config'

console.log(process.env.SERVER_NAME)

🤝 贡献指南

我们欢迎任何形式的贡献!请遵循以下步骤:

  1. Fork 本仓库
  2. 创建功能分支 (git checkout -b feature/amazing-feature)
  3. 提交更改 (git commit -m 'Add some amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 开启一个 Pull Request

贡献规范

  • 遵循现有的代码风格
  • 添加适当的注释和文档
  • 确保代码通过 TypeScript 编译
  • 更新相关文档(包括本 README)

📄 许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。

📞 支持

  • 提交 Issue 报告问题或请求功能
  • 查看 讨论区 参与讨论
  • 通过 GitHub 仓库直接联系维护者

English

📖 Project Introduction

LSE TypeScript Template is a modern TypeScript development template for creating LeviLamina LSE (LiteLoaderBDS Extension). It provides a complete development toolchain, supporting the latest TypeScript syntax and ES modules, enabling you to quickly develop high-performance Minecraft server plugins.

GitHub Repository: https://github.com/dmblpck/lse-typescript-template

✨ Features

  • 🚀 Modern Development Experience: TypeScript 5.9+ and ES modules
  • Fast Building: High-performance build tool based on Rolldown
  • 🔧 Full Type Support: Built-in @levimc-lse/types type definitions
  • 📦 Auto Packaging: Automatically packages multiple modules into a single file
  • 🔄 Hot Reload Development: File watching and auto-rebuild in development mode
  • 🎯 Code Intelligence: Complete IntelliSense and auto-completion support
  • 📁 Modular Structure: Clear directory structure and module separation

🚀 Quick Start

Prerequisites

  • Node.js 18+ or higher
  • pnpm 10.23.0+ (recommended) or npm / yarn
  • LeviLamina server environment

Installation

  1. Clone the repository

    git clone https://github.com/dmblpck/lse-typescript-template.git
    cd lse-typescript-template
  2. Install dependencies

    pnpm install

    or using npm:

    npm install
  3. Development mode

    pnpm dev

    This will start the development server, watching for file changes and auto-rebuilding.

  4. Build the project

    pnpm build

    The build output will be in dist/bundle.js.

📚 Usage Tutorial

Project Structure

lse-typescript-template/
├── src/
│   ├── index.ts          # Main entry file
│   └── config.ts         # Configuration file (optional)
├── dist/                 # Build output directory
├── rolldown.config.ts    # Build configuration
├── tsconfig.json         # TypeScript configuration
├── package.json          # Project dependencies and scripts
└── README.md             # Project documentation

Writing Code

In src/index.ts, you can directly use global modules like mc, ll with full TypeScript type hints:

// Listen to player join event
mc.listen('onJoin', (player) => {
    log(`${player.name} has joined the server!`)
    player.sendToast(`Welcome to the server, ${player.name}!`, 'Enjoy playing!')
})

Importing Other Modules

You can use ES module syntax to import other files:

import { config } from './config'

// Use imported configuration
log(`Server name: ${config.serverName}`)

Configuration Details

  • TypeScript Configuration (tsconfig.json): Configured for LeviLamina LSE development, targeting ES2024, using CommonJS modules
  • Build Configuration (rolldown.config.ts): Uses Rolldown bundler, input is src/index.ts, output is dist/bundle.js (CommonJS format)
  • Environment Variables: Supports .env files (via dotenv dependency)

Development Workflow

  1. Start Development: Run pnpm dev to enter development mode
  2. Write Code: Create new TypeScript files in the src/ directory
  3. Test Code: Copy the built dist/bundle.js to your LeviLamina server's plugin directory
  4. Debugging: Check server logs to debug your plugin
  5. Build for Release: Run pnpm build to generate the final version

📦 Available Scripts

  • pnpm dev - Start development mode with file watching and auto-rebuild
  • pnpm build - Build production version to dist/bundle.js
  • pnpm install - Install project dependencies

🛠️ Development Guide

Adding New Dependencies

pnpm add <package-name>

Type Definitions

The project includes @levimc-lse/types, providing complete Minecraft server API type definitions. You can use these types directly in your code for full code intelligence.

Customizing Build Configuration

If you need to modify the build configuration, edit the rolldown.config.ts file:

import { defineConfig } from 'rolldown'

export default defineConfig({
  input: 'src/index.ts',
  output: {
    file: 'dist/bundle.js',
    format: 'cjs',
    sourcemap: true, // Enable source maps for easier debugging
  },
  external: ['ll', 'mc'],
  platform: 'node',
  tsconfig: './tsconfig.json',
})

Environment Variables Configuration

Create a .env file to configure environment variables:

SERVER_NAME=My Minecraft Server
DEBUG_MODE=true

Then use in your code:

import 'dotenv/config'

console.log(process.env.SERVER_NAME)

🤝 Contributing

We welcome contributions of all kinds! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Contribution Guidelines

  • Follow the existing code style
  • Add appropriate comments and documentation
  • Ensure code passes TypeScript compilation
  • Update relevant documentation (including this README)

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

📞 Support

  • Submit an Issue to report problems or request features
  • Check the Discussions to join conversations
  • Contact the maintainer directly via the GitHub repository

Happy Coding! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors