From e42aa966014ae1c9cf337dd9d735d5cc790adbe2 Mon Sep 17 00:00:00 2001 From: xion Date: Sat, 2 Nov 2024 21:47:17 +0800 Subject: [PATCH] feat: init page from page.js --- package.json | 23 +++++++++++++++------ rollup.config.js | 47 ++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 1 + page.js => src/page.js | 0 tsconfig.json | 23 +++++++++++++++++++++ 5 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 rollup.config.js create mode 100644 src/index.ts rename page.js => src/page.js (100%) create mode 100644 tsconfig.json diff --git a/package.json b/package.json index 67252c6..60dd044 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,27 @@ { "name": "@kevisual/page", - "version": "1.0.0", + "version": "0.0.1", "description": "", "main": "page.js", "type": "module", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "rollup -c", + "build:app": "npm run build && rsync dist/* ../deploy/dist" }, "keywords": [], "author": "", "license": "ISC", - "dependencies": { - "page.js": "^4.13.3" - } -} + "devDependencies": { + "@rollup/plugin-commonjs": "^28.0.1", + "@rollup/plugin-node-resolve": "^15.3.0", + "@rollup/plugin-typescript": "^12.1.1", + "@types/crypto-js": "^4.2.2", + "@types/react": "^18.3.12", + "rimraf": "^6.0.1", + "rollup": "^4.24.3", + "rollup-plugin-copy": "^3.5.0", + "rollup-plugin-dts": "^6.1.1", + "typescript": "^5.6.3" + }, + "dependencies": {} +} \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..6b28f67 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,47 @@ +// rollup.config.js + +import typescript from '@rollup/plugin-typescript'; +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import copy from 'rollup-plugin-copy'; +import { dts } from 'rollup-plugin-dts'; + +/** + * @type {import('rollup').RollupOptions} + */ +const config1 = { + input: 'src/index.ts', // TypeScript 入口文件 + output: { + file: 'dist/page.js', // 输出文件 + format: 'es', // 输出格式设置为 ES 模块 + }, + plugins: [ + resolve({ + browser: true, // 若为浏览器环境,设为 true;若为 Node.js 环境,设为 false + // preferBuiltins: false, // 优先使用内置模块 + }), // 使用 @rollup/plugin-node-resolve 解析 node_modules 中的模块 + commonjs(), // + + typescript({ + allowImportingTsExtensions: true, + noEmit: true, + declaration: false, + }), // 使用 @rollup/plugin-typescript 处理 TypeScript 文件 + ], + include: ['node_modules/**'], + external: [], +}; +const config1Dts = { + input: 'src/index.ts', // TypeScript 入口文件 + output: { + file: 'dist/page.d.ts', // 输出文件 + format: 'es', // 输出格式设置为 ES 模块 + }, + plugins: [ + dts(), // 生成 .d.ts 类型声明文件 + ], + external: [], + include: ['node_modules/**'], +}; + +export default [config1, config1Dts]; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..cce29b7 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export * from './page.js'; diff --git a/page.js b/src/page.js similarity index 100% rename from page.js rename to src/page.js diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..92fb8ba --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "ESNext", + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], + "noEmit": false, + "outDir": "dist", + "strict": false, + "baseUrl": ".", + "rootDir": "src", + "noUnusedLocals": false, + "noUnusedParameters": false, + "moduleResolution": "node", + "declaration": true + }, + "include": [ + "src/**/*.ts" + ] +} \ No newline at end of file