This commit is contained in:
2024-11-04 21:59:20 +08:00
parent c8a5430594
commit f383d89b70
11 changed files with 135 additions and 0 deletions

13
packages/messages/.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
# Local
.DS_Store
*.local
*.log*
# Dist
node_modules
dist/
# IDE
.vscode/*
!.vscode/extensions.json
.idea

View File

@ -0,0 +1,4 @@
# Lock files
package-lock.json
pnpm-lock.yaml
yarn.lock

View File

@ -0,0 +1,3 @@
{
"singleQuote": true
}

View File

@ -0,0 +1,23 @@
# Rslib Project
## Setup
Install the dependencies:
```bash
pnpm install
```
## Get Started
Build the library:
```bash
pnpm build
```
Build the library in watch mode:
```bash
pnpm dev
```

View File

@ -0,0 +1,10 @@
import js from '@eslint/js';
import globals from 'globals';
import ts from 'typescript-eslint';
export default [
{ languageOptions: { globals: globals.browser } },
js.configs.recommended,
...ts.configs.recommended,
{ ignores: ['dist/'] },
];

View File

@ -0,0 +1,37 @@
{
"name": "messages",
"version": "1.0.0",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "rslib build",
"dev": "rslib build --watch",
"format": "prettier --write .",
"lint": "eslint .",
"test": "vitest run"
},
"devDependencies": {
"@eslint/js": "^9.12.0",
"@rslib/core": "^0.0.16",
"@types/node": "^22.8.1",
"eslint": "^9.12.0",
"globals": "^15.11.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3",
"typescript-eslint": "^8.8.1",
"vitest": "^2.1.4"
},
"private": true
}

View File

@ -0,0 +1,16 @@
import { defineConfig } from '@rslib/core';
export default defineConfig({
lib: [
{
format: 'esm',
syntax: 'es2021',
dts: true,
},
{
format: 'cjs',
syntax: 'es2021',
},
],
output: { target: 'node' },
});

View File

@ -0,0 +1 @@
export const squared = (n: number): number => n * n;

View File

@ -0,0 +1,7 @@
import { expect, test } from 'vitest';
import { squared } from '../src/index';
test('squared', () => {
expect(squared(2)).toBe(4);
expect(squared(12)).toBe(144);
});

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"lib": ["ES2021"],
"module": "ESNext",
"noEmit": true,
"strict": true,
"skipLibCheck": true,
"isolatedModules": true,
"resolveJsonModule": true,
"moduleResolution": "bundler",
"useDefineForClassFields": true,
"allowImportingTsExtensions": true
},
"include": ["src"]
}

View File

@ -0,0 +1,6 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
// Configure Vitest (https://vitest.dev/config/)
test: {},
});