Match-id-ba152d3826b0421b83dcfbb4aeb8f0f464ed08db

This commit is contained in:
* 2023-09-27 10:29:08 +08:00
commit c225c0b3e3
3 changed files with 69 additions and 9 deletions

View File

@ -0,0 +1,52 @@
import fs from 'fs';
import path from 'path';
import dts from 'rollup-plugin-dts';
function deleteFolder(filePath) {
if (fs.existsSync(filePath)) {
if (fs.lstatSync(filePath).isDirectory()) {
const files = fs.readdirSync(filePath);
files.forEach(file => {
const nextFilePath = path.join(filePath, file);
const states = fs.lstatSync(nextFilePath);
if (states.isDirectory()) {
deleteFolder(nextFilePath);
} else {
fs.unlinkSync(nextFilePath);
}
});
fs.rmdirSync(filePath);
} else if (fs.lstatSync(filePath).isFile()) {
fs.unlinkSync(filePath);
}
}
}
/**
*
* @param folders {string[]}
* @returns {{buildEnd(): void, name: string}}
*/
export function cleanUp(folders) {
return {
name: 'clean-up',
buildEnd() {
folders.forEach(f => deleteFolder(f));
},
};
}
function buildTypeConfig() {
return {
input: './build/@types/index.d.ts',
output: {
file: './build/index.d.ts',
format: 'es',
},
plugins: [dts(), cleanUp(['./build/@types/example', './build/@types/src'])],
};
}
export default [buildTypeConfig()];

View File

@ -7,7 +7,8 @@
"types": "build/index.d.ts", "types": "build/index.d.ts",
"scripts": { "scripts": {
"demo-serve": "webpack serve --mode=development", "demo-serve": "webpack serve --mode=development",
"rollup-build": "rollup --config rollup.config.js", "rollup-build": "rollup --config rollup.config.js && npm run build-types ",
"build-types": "tsc -p tsconfig.json && rollup -c build-type.js",
"test": "jest --config jest.config.js", "test": "jest --config jest.config.js",
"test-c": "jest --coverage" "test-c": "jest --coverage"
}, },
@ -16,8 +17,7 @@
"url": "" "url": ""
}, },
"files": [ "files": [
"build", "build"
"example"
], ],
"keywords": [], "keywords": [],
"author": "", "author": "",
@ -50,6 +50,7 @@
"rollup-plugin-livereload": "^2.0.5", "rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-serve": "^1.1.0", "rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^5.3.0", "rollup-plugin-terser": "^5.3.0",
"rollup-plugin-dts": "^6.0.1",
"tslib": "^2.6.1", "tslib": "^2.6.1",
"ts-jest": "29.0.3", "ts-jest": "29.0.3",
"ts-node": "10.9.1", "ts-node": "10.9.1",
@ -57,7 +58,8 @@
"webpack": "^5.81.0", "webpack": "^5.81.0",
"webpack-cli": "^5.1.4", "webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.13.3", "webpack-dev-server": "^4.13.3",
"react": "18.2.0", "react": "18.2.0-h3",
"react-dom": "18.2.0" "react-dom": "18.2.0-h3",
"core-js": "3.31.0"
} }
} }

View File

@ -31,6 +31,8 @@
"declaration": true, "declaration": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"downlevelIteration": true, "downlevelIteration": true,
"emitDeclarationOnly": true,
"declarationDir": "./build/@types",
// 使@types/node // 使@types/node
"lib": [ "lib": [
"dom", "dom",
@ -53,19 +55,23 @@
} }
}, },
"include": [ "include": [
"./src/**/*", "./index.ts",
"./src/format/**/*.ts",
"./example/**/*"
], ],
"exclude": [ "exclude": [
"node_modules", "node_modules",
"lib", "lib",
"**/*.spec.ts", "**/*.spec.ts",
"dev" "dev",
"./example/**/*",
"./tsconfig.json"
], ],
"types": [ "types": [
"node", "node",
"jest", "jest",
"@testing-library/jest-dom" "@testing-library/jest-dom"
],
"files": [
"./index.ts"
] ]
} }