Skip to content

v3.12.0

Latest

Choose a tag to compare

@GiveMe-A-Name GiveMe-A-Name released this 19 Nov 08:05
09d2da3

What's Changed

New Features 🎉

  • feat(app-tools): simplify the default HTML meta tags to UTF-8 charset and width=device-width, initial-scale=1 viewport. Remove the default zoom restrictions, shrink-to-fit, viewport-fit, x-ua-compatible, renderer, layoutmode, imagemode, wap-font-scale, and format-detection settings. Existing applications using these defaults will receive the new tags after upgrading and rebuilding. Configure html.meta explicitly if the application needs any of the removed settings, such as viewport-fit=cover for edge-to-edge layouts or format-detection: telephone=no to disable phone number detection. by @zllkjc in #9170
  • feat: support a build-time ssgParams export alongside a conventional page's data loader to generate static paths from route parameters. Combine generated paths with explicit SSG route lists, giving explicit options precedence for duplicate URLs. Global SSG settings apply to every entry unless an entry map is provided. by @zllkjc in #9167
  • feat(server-core): set Cache-Control for static files served by the production server. Build assets with a content hash get public, max-age=31536000, immutable, other static files get no-cache. Static files also get an ETag computed from their content and answer If-None-Match with 304. Configure or disable it with server.staticCacheControl. by @ramazansancar in #9100

Bug Fixes 🐞

  • fix: upgrade @modern-js/polyfill-lib to remove diff from its production dependencies. by @zllkjc in #9184
  • fix(app-tools): treat a build command followed only by --help or -h (for example modern build --help or modern dev -h) as printing help, so it no longer empties the output directory or regenerates node_modules/.modern-js. The plugin lifecycle order is unchanged. by @byte-lyh in #9180
  • fix(app-tools, utils): centralize CLI plugin loading in compatibleRequire. Fall back to ESM imports only when require reports an incompatible ESM module, including modules with top-level await. Preserve other loading errors without retrying, avoiding misleading Windows URL scheme errors, and report the actual ESM execution error if the fallback fails. by @zllkjc in #9168
  • fix: normalize Windows paths in generated route component imports, including custom entry directories and paths containing non-ASCII characters. by @GiveMe-A-Name in #9198

Other Changes ✨

  • Use an explicit callable signature for the isFunction type guard when enabling TypeScript project discovery in the repository linter. by @GiveMe-A-Name in #9178
  • Remove an obsolete ambient type reference to the unavailable module-tools package. by @GiveMe-A-Name in #9179

更新内容

新特性 🎉

  • feat(app-tools):将默认 HTML meta 标签精简为 UTF-8 字符编码和 width=device-width, initial-scale=1 视口配置。移除默认缩放限制、shrink-to-fit、viewport-fit、x-ua-compatible、renderer、layoutmode、imagemode、wap-font-scale 和 format-detection 设置。使用默认配置的已有应用在升级并重新构建后也会采用这些新值。如需保留已移除的设置,请通过 html.meta 显式配置,例如使用 viewport-fit=cover 保持页面铺满屏幕,或使用 format-detection: telephone=no 关闭电话号码自动识别。 由 @zllkjc 实现, 详情可查看 #9170
  • feat: 支持在约定式路由的数据加载文件中导出构建期 ssgParams,由路由参数生成静态路径。合并生成路径与显式 SSG 路径列表,重复 URL 使用显式配置。未提供入口映射时,全局 SSG 配置适用于所有入口。 由 @zllkjc 实现, 详情可查看 #9167
  • feat(server-core):生产服务器为静态文件设置 Cache-Control。文件名包含内容哈希的构建产物使用 public, max-age=31536000, immutable,其他静态文件使用 no-cache。静态文件还会带上根据内容计算的 ETag,并对 If-None-Match 返回 304。可以通过 server.staticCacheControl 修改或关闭。 由 @ramazansancar 实现, 详情可查看 #9100

Bug 修复 🐞

  • fix: 升级 @modern-js/polyfill-lib,移除其生产依赖中的 diff。 由 @zllkjc 实现, 详情可查看 #9184
  • fix(app-tools):构建类命令后面只跟 --help 或 -h 时(例如 modern build --help、modern dev -h)视为打印帮助,不再清空产物目录,也不再重新生成 node_modules/.modern-js。插件生命周期顺序不变。 由 @byte-lyh 实现, 详情可查看 #9180
  • fix(app-tools, utils):统一使用 compatibleRequire 加载 CLI 插件,仅在 require 无法加载 ESM 模块时回退到 ESM 导入,支持包含顶层 await 的模块。其他加载错误直接抛出,避免被 Windows URL 协议错误覆盖。ESM 回退执行失败时,报告实际的 ESM 执行错误。 由 @zllkjc 实现, 详情可查看 #9168
  • fix: 修复生成的路由组件 import 未转换 Windows 路径的问题,支持自定义入口目录及包含非 ASCII 字符的路径。 由 @GiveMe-A-Name 实现, 详情可查看 #9198