Skip to content

Commit 0f781a6

Browse files
devjiwonchoiNetail
andauthored
[Breaking] Bump sass-loader to v16 (#84387)
This PR bumps sass-loader to v16 as Sass is deprecating the legacy JS API, and updating sass-loader ensures compatibility with future Sass versions. x-ref: #67931 This removes the silencing of the deprecation warning added at #72632. Supersedes #83091 --------- Co-authored-by: Maikel <[email protected]>
1 parent 0a02fd8 commit 0f781a6

File tree

7 files changed

+20
-41
lines changed

7 files changed

+20
-41
lines changed

crates/next-core/src/next_shared/webpack_rules/sass.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,10 @@ pub async fn get_sass_loader_rules(
7171
}
7272

7373
let sass_options = next_config.sass_config().await?;
74-
let Some(mut sass_options) = sass_options.as_object().cloned() else {
74+
let Some(sass_options) = sass_options.as_object() else {
7575
bail!("sass_options must be an object");
7676
};
7777

78-
// TODO: Remove this once we upgrade to sass-loader 16
79-
let silence_deprecations = if let Some(v) = sass_options.get("silenceDeprecations") {
80-
v.clone()
81-
} else {
82-
serde_json::json!(["legacy-js-api"])
83-
};
84-
85-
sass_options.insert("silenceDeprecations".into(), silence_deprecations);
86-
8778
// additionalData is a loader option but Next.js has it under `sassOptions` in
8879
// `next.config.js`
8980
let additional_data = sass_options

packages/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
"recast": "0.23.11",
311311
"regenerator-runtime": "0.13.4",
312312
"safe-stable-stringify": "2.5.0",
313-
"sass-loader": "15.0.0",
313+
"sass-loader": "16.0.5",
314314
"schema-utils2": "npm:[email protected]",
315315
"schema-utils3": "npm:[email protected]",
316316
"semver": "7.3.2",

packages/next/src/build/webpack/config/blocks/css/index.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,7 @@ export const css = curry(async function css(
174174
// Source maps are required so that `resolve-url-loader` can locate
175175
// files original to their source directory.
176176
sourceMap: true,
177-
sassOptions: {
178-
// The "fibers" option is not needed for Node.js 16+, but it's causing
179-
// problems for Node.js <= 14 users as you'll have to manually install
180-
// the `fibers` package:
181-
// https://github.com/webpack-contrib/sass-loader#:~:text=We%20automatically%20inject%20the%20fibers%20package
182-
// https://github.com/vercel/next.js/issues/45052
183-
// Since it's optional and not required, we'll disable it by default
184-
// to avoid the confusion.
185-
fibers: false,
186-
// TODO: Remove this once we upgrade to sass-loader 16
187-
silenceDeprecations: ['legacy-js-api'],
188-
...sassOptions,
189-
},
177+
sassOptions,
190178
additionalData: sassPrependData || sassAdditionalData,
191179
},
192180
},

packages/next/src/compiled/sass-loader/cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/next/taskfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,7 @@ export async function ncc_sass_loader(task, opts) {
18571857
await fs.writeFile(
18581858
utilsPath,
18591859
originalContent.replace(
1860-
/require\.resolve\(["'](sass|node-sass)["']\)/g,
1860+
/require\.resolve\(["'](sass|node-sass|sass-embedded)["']\)/g,
18611861
'eval("require").resolve("$1")'
18621862
)
18631863
)

pnpm-lock.yaml

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/app-dir/scss/basic-module-include-paths/basic-module-include-paths.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { nextTestSetup } from 'e2e-utils'
33
import { colorToRgb } from 'next-test-utils'
44

55
const sassOptions = {
6-
includePaths: ['./styles'],
6+
loadPaths: ['./styles'],
77
}
88

99
describe.each([

0 commit comments

Comments
 (0)