• 欢迎加入MineBBS QQ讨论群:点击查看所有的官方讨论群
  • 我们将于近期对服务器进行迁移,服务可能中断至多2日。请各位安排好自己的访问计划,造成不便敬请谅解!
  • MineBBS入站考试已经上线!想要成为【正式会员】解锁更多功能吗?快来参与吧!【点我去看】
资源图标

原创 加载器 LSE-TypescriptTemplate - LSE的Typescript开发模板 v0.0.1

请登录后获取
[MD] ### 📖 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: [[URL]https://github.com/dmblpck/lse-typescript-template](https://github.com/dmblpck/lse-typescript-template)[/URL] ### ✨ 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** ```bash git clone [URL]https://github.com/dmblpck/lse-typescript-template.git[/URL] cd lse-typescript-template ``` 2. **Install dependencies** ```bash pnpm install ``` or using npm: ```bash npm install ``` 3. **Development mode** ```bash pnpm dev ``` This will start the development server, watching for file changes and auto-rebuilding. 4. **Build the project** ```bash 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: ```typescript // 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: ```typescript 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 ```bash 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: ```typescript 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: ```env SERVER_NAME=My Minecraft Server DEBUG_MODE=true ``` Then use in your code: ```typescript import 'dotenv/config' [/MD]


console.log(process.env.SERVER_NAME)

```
后退
顶部 底部