feat(module): Improve module exports and compatibility
- Add explicit ES Module and CommonJS exports in index.js - Update package.json to support both import and require - Ensure consistent function exports across module systems
This commit is contained in:
parent
8e018f34be
commit
22d3931665
39
index.js
39
index.js
@ -7,12 +7,15 @@
|
||||
* @Description: ddmt-index file
|
||||
* @FilePath: /index.js
|
||||
*/
|
||||
export {
|
||||
|
||||
// 导入所有函数
|
||||
import {
|
||||
animateStart,
|
||||
setClassVar,
|
||||
getStyleVar
|
||||
} from './Tool/animate.js';
|
||||
export {
|
||||
|
||||
import {
|
||||
randomNum,
|
||||
nextArray,
|
||||
ArrayDeHeavy,
|
||||
@ -23,4 +26,36 @@ export {
|
||||
objectToJSON
|
||||
} from './Tool/number.js';
|
||||
|
||||
// ES Module 导出
|
||||
export {
|
||||
animateStart,
|
||||
setClassVar,
|
||||
getStyleVar,
|
||||
randomNum,
|
||||
nextArray,
|
||||
ArrayDeHeavy,
|
||||
getRelativeTime,
|
||||
parseNginxLog,
|
||||
toCookiesArray,
|
||||
updateCookies,
|
||||
objectToJSON
|
||||
};
|
||||
|
||||
// CommonJS 导出
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = {
|
||||
animateStart,
|
||||
setClassVar,
|
||||
getStyleVar,
|
||||
randomNum,
|
||||
nextArray,
|
||||
ArrayDeHeavy,
|
||||
getRelativeTime,
|
||||
parseNginxLog,
|
||||
toCookiesArray,
|
||||
updateCookies,
|
||||
objectToJSON
|
||||
};
|
||||
}
|
||||
|
||||
console.log('ddmt-tool Loading successfully!! 😺');
|
@ -4,6 +4,12 @@
|
||||
"description": "A utility library that provides commonly used functions to simplify everyday development tasks. Whether it's string manipulation, array operations, or other frequent functionalities, `ddmt-tool` helps you work more efficiently.",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./index.js",
|
||||
"require": "./index.js"
|
||||
}
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"scripts": {
|
||||
"dev": "node index.js"
|
||||
|
Loading…
x
Reference in New Issue
Block a user