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:
2025-02-21 10:50:04 +08:00
parent 8e018f34be
commit 22d3931665
2 changed files with 43 additions and 2 deletions

View File

@@ -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!! 😺');