Skip to content

[FR]: upgrade and remove warn for Sass @import deprecated #3322

@tiltwind

Description

@tiltwind

NutUI 包名

@nutui/nutui-taro

这个功能解决了什么问题?

ModuleWarning: Module Warning (from ./node_modules/.pnpm/sass-loader@14.2.1_sass@1.89.2_webpack@5.99.9_@swc+core@1.3.96_/node_modules/sass-loader/dist/cjs.js):
Deprecation Warning on line 0, column 8 of file:///Users/uu/fe-taro-uu/src/components/FetchList/components/Horizontal.vue:0:8:
Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.

More info and automated migrator: https://sass-lang.com/d/import

0 | @import "@nutui/nutui-taro/dist/styles/variables.scss";
  1. sassLoaderOption.sassOptions.silenceDeprecations: ['legacy-js-api', 'import'] 顶层配置 —— 写入后构建仍输出 1952 条 warnings。Taro 4 webpack5-runner 源码看起来读这个字段并 recursiveMerge 给
    sass-loader,但实测不生效。可能是 webpack-merge 在 dev/prod 合并时把 Taro 的自定义顶层字段过滤掉了
  2. post-merge 强制注入 —— 同样无效。怀疑要么 sass-loader 14 的 legacy JS API 路径忽略了 silenceDeprecations,要么 Taro 内部有第三方 chain mutation 把 sassOptions 改回去了
  3. 降 sass 到 1.79.x(用户否决)
  4. 改用 sass-migrator 把项目 @import 全部迁到 @use —— 不彻底,因为 NutUI 4.3.x 自身的 variables.scss / mixins/index.scss 也用 @import,改不了源码

后续这个 warning 会自然消失的条件(任一)

  • NutUI 升级(预计 4.4 / 5.x)把内部 @import 全部迁到 @use
  • Taro 4 升级 webpack5-runner 切换 sass-loader 到 modern API,或加官方的 silence 配置入口
  • Dart Sass 3.0 发布前(还有几个月到 1 年),NutUI 一定会被迫迁移

你期望的组件设计是怎样的?

做相关升级, 去掉warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions