diff --git a/package.json b/package.json index 0fbe16d..ab30ca4 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "test": "vitest", "build": "lerna run build" }, + "type": "module", "devDependencies": { "@types/lodash-es": "^4.17.12", "@types/node": "^20.12.12", diff --git a/packages/browser/package.json b/packages/browser/package.json index 29db60a..1a73960 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -3,6 +3,7 @@ "version": "0.0.14", "description": "我的工具库-Web端", "author": "linzb93", + "private":true, "homepage": "https://github.com/linzb93/utils#readme", "license": "ISC", "main": "dist/index.js", diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts index 980d953..b41c6dd 100644 --- a/packages/core/index.d.ts +++ b/packages/core/index.d.ts @@ -133,6 +133,14 @@ export declare const isEmptyObject: (obj: any) => boolean; */ export declare const isNumberHasMoreThan2Decimal: (value: number) => boolean; +/** + * 判断两个时间段是否重叠,如有重叠,返回true。 + * @param timeList: [{startTime, endTime}], + * @param time: 形如'22:00'的 + * @return {boolean} 是否存在重叠 + */ +export declare function isTimeOverlay(timeList: TimeRange[]): boolean; + declare interface IValidate { [key: string]: (str: string) => boolean; } @@ -169,8 +177,6 @@ declare class TimeCtor { isInRange(startTime: string, endTime: string): boolean; } -export declare function timeIsSmaller(time0: string, time1: string): boolean; - export declare function timejs(time: string): TimeCtor; declare interface TimeRange { diff --git a/packages/node/package.json b/packages/node/package.json index 4a0114c..328010e 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -3,6 +3,7 @@ "version": "0.0.14", "description": "我的工具库-Node端", "author": "linzb93", + "private":true, "homepage": "https://github.com/linzb93/utils#readme", "license": "ISC", "main": "dist/index.js", diff --git a/packages/node/vite.config.ts b/packages/node/vite.config.ts index 0c8f76c..1c2f737 100644 --- a/packages/node/vite.config.ts +++ b/packages/node/vite.config.ts @@ -1,9 +1,34 @@ import { defineConfig } from "vitest/config"; import dts from 'vite-plugin-dts'; +import pkg from './package.json'; +import monoPkg from '../../package.json'; + +const externalPkgs = (() => { + const output:string[] = []; + if ('dependencies' in pkg) { + output.push(...Object.keys(pkg.dependencies as object)); + } + if ('dependencies' in monoPkg) { + output.push(...Object.keys(monoPkg.dependencies as object)); + } + return output; +})() export default defineConfig({ build: { - target: "modules", + target: 'node18', + minify: false, + rollupOptions: { + input: 'lib/index.ts', + output: { + dir: 'dist', + entryFileNames: 'index.js' + }, + external: [ + ...externalPkgs, + /^node:.*/ + ] + }, lib: { entry: "lib/index.ts", fileName: "index", diff --git a/scripts/checkNodeVersion.js b/scripts/checkNodeVersion.js index 37619e0..76ad6a4 100644 --- a/scripts/checkNodeVersion.js +++ b/scripts/checkNodeVersion.js @@ -1,5 +1,6 @@ -const semver = require("semver"); -const chalk = require("chalk"); +import semver from 'semver'; +import chalk from 'chalk'; + if (semver.lt(process.version, "18.0.0")) { console.log(chalk.red("NodeJS版本太低,请切换至v18+")); process.exit(1); diff --git a/scripts/gitCommitFormat.js b/scripts/gitCommitFormat.js index 7135bc0..08ca3f6 100644 --- a/scripts/gitCommitFormat.js +++ b/scripts/gitCommitFormat.js @@ -1,5 +1,5 @@ -const fs = require("fs"); -const chalk = require("chalk"); +import chalk from 'chalk'; +import fs from 'node:fs'; const commitMap = [ { diff --git a/tsconfig.json b/tsconfig.json index 1f35750..c4b1dad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "declarationDir": "./types", "experimentalDecorators": true, "esModuleInterop": true, + "resolveJsonModule": true, "moduleResolution": "Bundler", "isolatedModules": true, "lib": ["ESNext", "dom"],