fix: CJS 产物改 .cjs 扩展名并提升 default 导出 — 修复 require() 兼容性

- 包声明 type:module 时 .js 产物被 Node 按 ESM 解析:Node 16/18 下 require 报 ERR_REQUIRE_ESM,Node 20+ 拿到 namespace 对象(success/version 等属性 undefined)
- dist/metona-toast.cjs.js → .cjs,dist/react.cjs.js → .cjs
- 主包 CJS footer 将 default 提升为 module.exports:require() 直接返回 MeToast(兼容 .default / .MeToast / .Met / .Toast / .VERSION 所有用法)
- 版本 0.5.1(0.5.0 已发布带问题产物)
- 真实消费者验证:CJS/ESM/React 子包四路加载全部正常
This commit is contained in:
tianhao
2026-08-08 15:25:47 +08:00
parent dd061025e0
commit 95f5652e9c
36 changed files with 116 additions and 113 deletions
+14 -14
View File
@@ -3,7 +3,7 @@ import { useRef, useEffect, useMemo } from 'react';
/**
* MetonaToast Utils — 工具函数
* @module utils
* @version 0.5.0
* @version 0.5.1
*/
/**
* 生成唯一ID
@@ -40,7 +40,7 @@ const prefersDark = () => {
/**
* MetonaToast Icons — 图标SVG定义
* @module icons
* @version 0.5.0
* @version 0.5.1
* @description 107 个内置 SVG 图标
*/
const ICONS = {
@@ -537,7 +537,7 @@ const ICONS = {
/**
* MetonaToast Locales — 国际化翻译数据
* @module locales
* @version 0.5.0
* @version 0.5.1
* @description 内置 zh-CN / en-US 完整翻译
*/
const LOCALES = {
@@ -1024,12 +1024,12 @@ const LOCALES = {
/**
* MetonaToast Constants — 常量定义
* @module constants
* @version 0.5.0
* @version 0.5.1
*/
/**
* 版本号 — 唯一来源,发布时只需修改此处
*/
const VERSION = '0.5.0';
const VERSION = '0.5.1';
/**
* 默认配置
*/
@@ -1296,7 +1296,7 @@ const ANIMATION_TYPES = ['slide', 'fade', 'scale', 'bounce', 'flip', 'rotate', '
/**
* MetonaToast Styles — 样式管理
* @module styles
* @version 0.5.0
* @version 0.5.1
*/
// 样式缓存
let styleElement = null;
@@ -1785,7 +1785,7 @@ const injectStyles = () => {
/**
* MetonaToast Themes — 主题管理
* @module themes
* @version 0.5.0
* @version 0.5.1
*/
// 当前主题状态
let currentTheme = 'auto';
@@ -2129,7 +2129,7 @@ const themeUtils = {
/**
* MetonaToast i18n — 国际化管理
* @module i18n
* @version 0.5.0
* @version 0.5.1
*/
// 当前语言状态
let currentLocale = 'zh-CN';
@@ -2804,7 +2804,7 @@ const animationUtils = {
/**
* MetonaToast Toast — Toast 类
* @module toast
* @version 0.5.0
* @version 0.5.1
*/
/**
* Toast 类 — 核心通知组件
@@ -3443,7 +3443,7 @@ const _containerCache = new Map();
/**
* MetonaToast Templates — HTML 模板辅助函数
* @module templates
* @version 0.5.0
* @version 0.5.1
* @description confirm / prompt / progress / action 的 DOM 模板
*/
/**
@@ -3515,7 +3515,7 @@ const actionHTML = (actions) => {
/**
* MetonaToast Plugins — 插件系统
* @module plugins
* @version 0.5.0
* @version 0.5.1
*/
/**
* 插件管理器
@@ -3775,7 +3775,7 @@ const defaultPluginManager = new PluginManager();
/**
* MetonaToast API — meToast 核心 API 对象
* @module api
* @version 0.5.0
* @version 0.5.1
*/
/**
* 参数标准化工具
@@ -4461,7 +4461,7 @@ Toast$1.setCallbacks({
/**
* MetonaToast — 轻量级Toast通知库
* @module metona-toast
* @version 0.5.0
* @version 0.5.1
* @author thzxx
* @license MIT
*/
@@ -4527,7 +4527,7 @@ if (typeof window !== 'undefined') {
/**
* MetonaToast React — React 适配器
* @module react
* @version 0.5.0
* @version 0.5.1
* @description useToast hook + 声明式 <Toast /> 组件。主包保持零依赖,React 为 optional peerDependency
*/
const SHOW_METHODS = ['success', 'error', 'warning', 'info', 'show'];