Skip to content

Commit d9addf0

Browse files
Fix Sass legacy JS API deprecation in webpack build
Warning fixed: - "The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0." repeated during yarn build. Approach: - Upgrade sass-loader from v10 to v13 (Node 16 compatible) and configure sass-loader with api: "modern". - Add Sass load paths for node_modules so package imports resolve under the modern API. - Update design-system-react @forward path to its explicit distributed SCSS entrypoint for reliable modern resolution. Why this approach: - Removes dependence on the deprecated Sass legacy API instead of suppressing the warning. - Keeps compatibility with current CI Node runtime while modernizing Sass integration. Alternatives considered: - Stay on sass-loader v10 and suppress the legacy API warning: rejected because this leaves deprecated behavior in place. - Jump to sass-loader v14+: rejected because those versions require newer Node than current CI. Co-authored-by: Chris Zetter <zetter-rpf@users.noreply.github.com>
1 parent e582c50 commit d9addf0

4 files changed

Lines changed: 15 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"resolve": "1.18.1",
177177
"resolve-url-loader": "^3.1.2",
178178
"sass": "^1.51.0",
179-
"sass-loader": "^10.0.0",
179+
"sass-loader": "^13.3.3",
180180
"semver": "7.3.2",
181181
"style-it": "^2.1.4",
182182
"style-loader": "1.3.0",

src/assets/stylesheets/ExternalStyles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@forward "@raspberrypifoundation/design-system-react/scss/design-system-core";
1+
@forward "../../../node_modules/@raspberrypifoundation/design-system-react/dist/scss/design-system-core.scss";
22
@use "../../../node_modules/react-tabs/style/react-tabs.css";
33
@use "../../../node_modules/react-toggle/style.css";
44
@use "../../../node_modules/prismjs/plugins/line-numbers/prism-line-numbers.css";

webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ module.exports = {
5050
{
5151
loader: "sass-loader",
5252
options: {
53+
api: "modern",
54+
sassOptions: {
55+
loadPaths: [path.resolve(__dirname, "node_modules")],
56+
},
5357
sourceMap: true,
5458
},
5559
},

yarn.lock

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,7 +3994,7 @@ __metadata:
39943994
resolve: "npm:1.18.1"
39953995
resolve-url-loader: "npm:^3.1.2"
39963996
sass: "npm:^1.51.0"
3997-
sass-loader: "npm:^10.0.0"
3997+
sass-loader: "npm:^13.3.3"
39983998
semver: "npm:7.3.2"
39993999
skulpt: "npm:^1.2.0"
40004000
stream-browserify: "npm:^3.0.0"
@@ -21851,28 +21851,27 @@ __metadata:
2185121851
languageName: node
2185221852
linkType: hard
2185321853

21854-
"sass-loader@npm:^10.0.0":
21855-
version: 10.5.2
21856-
resolution: "sass-loader@npm:10.5.2"
21854+
"sass-loader@npm:^13.3.3":
21855+
version: 13.3.3
21856+
resolution: "sass-loader@npm:13.3.3"
2185721857
dependencies:
21858-
klona: "npm:^2.0.4"
21859-
loader-utils: "npm:^2.0.0"
2186021858
neo-async: "npm:^2.6.2"
21861-
schema-utils: "npm:^3.0.0"
21862-
semver: "npm:^7.3.2"
2186321859
peerDependencies:
2186421860
fibers: ">= 3.1.0"
2186521861
node-sass: ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0
2186621862
sass: ^1.3.0
21867-
webpack: ^4.36.0 || ^5.0.0
21863+
sass-embedded: "*"
21864+
webpack: ^5.0.0
2186821865
peerDependenciesMeta:
2186921866
fibers:
2187021867
optional: true
2187121868
node-sass:
2187221869
optional: true
2187321870
sass:
2187421871
optional: true
21875-
checksum: 10/27b85f852d270a5c84b95f8ba3fbc84e7cbb77a3481f3ff2b74d4ea87f2ad4cefcba70ba41412b80e62ba433c75994d4d12d323d39a24de5087b60b571a1a3c9
21872+
sass-embedded:
21873+
optional: true
21874+
checksum: 10/a8a8519add9f0bb2d3d1b834dbf30b1b67e22833425755a56640cc20845107850adfc6f243cdab07a5cb26ec964513b950a02dca7b1d5b3cf3659c89bf1988eb
2187621875
languageName: node
2187721876
linkType: hard
2187821877

0 commit comments

Comments
 (0)