From 3b6a73337b79ff71959cadd18ffb0a4a08aae558 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Thu, 7 Nov 2024 03:51:14 +0900 Subject: [PATCH 01/19] wip --- .../src/next_shared/webpack_rules/sass.rs | 12 ++++- packages/next/package.json | 1 + .../build/webpack/config/blocks/css/index.ts | 7 ++- packages/next/src/server/config-schema.ts | 5 ++ packages/next/src/server/config-shared.ts | 3 ++ packages/next/taskfile.js | 32 +++++++++++++ pnpm-lock.yaml | 31 ++++++++++++ .../use-upgraded-loader/basic-module.test.ts | 48 +++++++++++++++++++ .../scss/use-upgraded-loader/pages/index.js | 9 ++++ .../pages/index.module.scss | 4 ++ 10 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts create mode 100644 test/e2e/app-dir/scss/use-upgraded-loader/pages/index.js create mode 100644 test/e2e/app-dir/scss/use-upgraded-loader/pages/index.module.scss diff --git a/crates/next-core/src/next_shared/webpack_rules/sass.rs b/crates/next-core/src/next_shared/webpack_rules/sass.rs index 296142d0f49ba..4ed32e30e92c9 100644 --- a/crates/next-core/src/next_shared/webpack_rules/sass.rs +++ b/crates/next-core/src/next_shared/webpack_rules/sass.rs @@ -36,9 +36,19 @@ pub async fn maybe_add_sass_loader( let additional_data = sass_options .get("prependData") .or(sass_options.get("additionalData")); + // TODO: Remove sass-loader-16 once we upgrade sass-loader to 16 + let use_upgraded_loader = sass_options + .get("experimental") + .and_then(|e| e.get("useUpgradedLoader")) + .and_then(|v| v.as_bool()) + .unwrap_or(false); let rule = rules.get_mut(pattern); let sass_loader = WebpackLoaderItem { - loader: "next/dist/compiled/sass-loader".into(), + loader: if use_upgraded_loader { + "next/dist/compiled/sass-loader-16".into() + } else { + "next/dist/compiled/sass-loader".into() + }, options: take( serde_json::json!({ "implementation": sass_options.get("implementation"), diff --git a/packages/next/package.json b/packages/next/package.json index c665357155ee5..d9c8d237c5908 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -294,6 +294,7 @@ "react-refresh": "0.12.0", "regenerator-runtime": "0.13.4", "sass-loader": "15.0.0", + "sass-loader-16": "npm:sass-loader@16.0.3", "schema-utils2": "npm:schema-utils@2.7.1", "schema-utils3": "npm:schema-utils@3.0.0", "semver": "7.3.2", diff --git a/packages/next/src/build/webpack/config/blocks/css/index.ts b/packages/next/src/build/webpack/config/blocks/css/index.ts index 99d3f0117e8d2..f694d10dbb91a 100644 --- a/packages/next/src/build/webpack/config/blocks/css/index.ts +++ b/packages/next/src/build/webpack/config/blocks/css/index.ts @@ -151,6 +151,7 @@ export const css = curry(async function css( prependData: sassPrependData, additionalData: sassAdditionalData, implementation: sassImplementation, + experimental: { useUpgradedLoader: sassUseUpgradedLoader } = {}, ...sassOptions } = ctx.sassOptions @@ -166,7 +167,11 @@ export const css = curry(async function css( // First, process files with `sass-loader`: this inlines content, and // compiles away the proprietary syntax. { - loader: require.resolve('next/dist/compiled/sass-loader'), + loader: require.resolve( + sassUseUpgradedLoader + ? 'next/dist/compiled/sass-loader-16' + : 'next/dist/compiled/sass-loader' + ), options: { implementation: sassImplementation, // Source maps are required so that `resolve-url-loader` can locate diff --git a/packages/next/src/server/config-schema.ts b/packages/next/src/server/config-schema.ts index ace53d76eb274..f1596dbfd1121 100644 --- a/packages/next/src/server/config-schema.ts +++ b/packages/next/src/server/config-schema.ts @@ -614,6 +614,11 @@ export const configSchema: zod.ZodType = z.lazy(() => // sassOptions properties are unknown besides implementation, use z.any() here sassOptions: z .object({ + experimental: z + .object({ + useUpgradedLoader: z.boolean().optional(), + }) + .optional(), implementation: z.string().optional(), }) .catchall(z.any()) diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index 76217dc7d2a71..54e03a93c9d7f 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -797,6 +797,9 @@ export interface NextConfig extends Record { /** @see [Customizing sass options](https://nextjs.org/docs/app/api-reference/next-config-js/sassOptions) */ sassOptions?: { + experimental?: { + useUpgradedLoader?: boolean + } implementation?: string [key: string]: any } diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index be1b7e9178b34..b17730fb5141b 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1882,6 +1882,7 @@ externals['sass-loader'] = 'next/dist/compiled/sass-loader' // eslint-disable-next-line camelcase export async function ncc_sass_loader(task, opts) { const sassLoaderPath = require.resolve('sass-loader') + console.log({ sassLoaderPath }) const utilsPath = join(dirname(sassLoaderPath), 'utils.js') const originalContent = await fs.readFile(utilsPath, 'utf8') @@ -1906,6 +1907,36 @@ export async function ncc_sass_loader(task, opts) { }) .target('src/compiled/sass-loader') } +// TODO: Remove sass-loader-16 once we upgrade sass-loader to 16 +externals['sass-loader-16'] = 'next/dist/compiled/sass-loader-16' +// eslint-disable-next-line camelcase +export async function ncc_sass_loader_16(task, opts) { + const sassLoader16Path = require.resolve('sass-loader-16') + console.log({ sassLoader16Path }) + const utilsPath = join(dirname(sassLoader16Path), 'utils.js') + const originalContent = await fs.readFile(utilsPath, 'utf8') + + await fs.writeFile( + utilsPath, + originalContent.replace( + /require\.resolve\(["'](sass|node-sass)["']\)/g, + 'eval("require").resolve("$1")' + ) + ) + + await task + .source(relative(__dirname, sassLoader16Path)) + .ncc({ + packageName: 'sass-loader-16', + externals: { + ...externals, + 'schema-utils': externals['schema-utils3'], + 'loader-utils': externals['loader-utils2'], + }, + target: 'es5', + }) + .target('src/compiled/sass-loader-16') +} // eslint-disable-next-line camelcase externals['schema-utils'] = 'MISSING_VERSION schema-utils version not specified' externals['schema-utils2'] = 'next/dist/compiled/schema-utils2' @@ -2426,6 +2457,7 @@ export async function ncc(task, opts) { 'copy_constants_browserify', 'copy_vendor_react', 'ncc_sass_loader', + 'ncc_sass_loader_16', 'ncc_jest_worker', 'ncc_edge_runtime_cookies', 'ncc_edge_runtime_primitives', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75c9e8b384b4e..54eb917816a24 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1385,6 +1385,9 @@ importers: sass-loader: specifier: 15.0.0 version: 15.0.0(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))) + sass-loader-16: + specifier: npm:sass-loader@16.0.3 + version: sass-loader@16.0.3(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))) schema-utils2: specifier: npm:schema-utils@2.7.1 version: schema-utils@2.7.1 @@ -13532,6 +13535,27 @@ packages: webpack: optional: true + sass-loader@16.0.3: + resolution: {integrity: sha512-gosNorT1RCkuCMyihv6FBRR7BMV06oKRAs+l4UMp1mlcVg9rWN6KMmUj3igjQwmYys4mDP3etEYJgiHRbgHCHA==} + engines: {node: '>= 18.12.0'} + peerDependencies: + '@rspack/core': 0.x || 1.x + node-sass: ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 + sass: ^1.3.0 + sass-embedded: '*' + webpack: 5.96.1 + peerDependenciesMeta: + '@rspack/core': + optional: true + node-sass: + optional: true + sass: + optional: true + sass-embedded: + optional: true + webpack: + optional: true + sass@1.54.0: resolution: {integrity: sha512-C4zp79GCXZfK0yoHZg+GxF818/aclhp9F48XBu/+bm9vXEVAYov9iU3FBVRMq3Hx3OA4jfKL+p2K9180mEh0xQ==} engines: {node: '>=12.0.0'} @@ -30382,6 +30406,13 @@ snapshots: sass: 1.77.8 webpack: 5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13)) + sass-loader@16.0.3(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))): + dependencies: + neo-async: 2.6.2 + optionalDependencies: + sass: 1.77.8 + webpack: 5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13)) + sass@1.54.0: dependencies: chokidar: 3.5.3 diff --git a/test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts b/test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts new file mode 100644 index 0000000000000..1c7774cb4beaf --- /dev/null +++ b/test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts @@ -0,0 +1,48 @@ +import { nextTestSetup } from 'e2e-utils' +import { colorToRgb } from 'next-test-utils' + +describe('Legacy sass-loader', () => { + const { next: nextWithLegacyLoader } = nextTestSetup({ + files: __dirname, + dependencies: { sass: '1.54.0' }, + nextConfig: undefined, + }) + + it('should render the module for the legacy sass-loader', async () => { + const browser = await nextWithLegacyLoader.browser('/') + expect( + await browser.elementByCss('#verify-red').getComputedCss('color') + ).toBe(colorToRgb('red')) + }) + + it('should show deprecation warning', async () => { + expect(nextWithLegacyLoader.cliOutput).toContain( + 'Deprecation: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0' + ) + }) +}) + +describe('Upgraded sass-loader', () => { + const { next: nextWithUpgradedLoader } = nextTestSetup({ + files: __dirname, + dependencies: { sass: '1.54.0' }, + nextConfig: { + experimental: { + useUpgradedLoader: true, + }, + }, + }) + + it('should render the module for the upgraded sass-loader', async () => { + const browser = await nextWithUpgradedLoader.browser('/') + expect( + await browser.elementByCss('#verify-red').getComputedCss('color') + ).toBe(colorToRgb('red')) + }) + + it('should not show deprecation warning', async () => { + expect(nextWithUpgradedLoader.cliOutput).not.toContain( + 'Deprecation: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0' + ) + }) +}) diff --git a/test/e2e/app-dir/scss/use-upgraded-loader/pages/index.js b/test/e2e/app-dir/scss/use-upgraded-loader/pages/index.js new file mode 100644 index 0000000000000..7b42859a67e32 --- /dev/null +++ b/test/e2e/app-dir/scss/use-upgraded-loader/pages/index.js @@ -0,0 +1,9 @@ +import { redText } from './index.module.scss' + +export default function Home() { + return ( +
+ This text should be red. +
+ ) +} diff --git a/test/e2e/app-dir/scss/use-upgraded-loader/pages/index.module.scss b/test/e2e/app-dir/scss/use-upgraded-loader/pages/index.module.scss new file mode 100644 index 0000000000000..eb8bb05c73aca --- /dev/null +++ b/test/e2e/app-dir/scss/use-upgraded-loader/pages/index.module.scss @@ -0,0 +1,4 @@ +$var: red; +.redText { + color: $var; +} From e46e33adaca3ab87770617fd938f543d40d7f5dd Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Thu, 14 Nov 2024 17:24:15 +0900 Subject: [PATCH 02/19] remove console --- packages/next/taskfile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index b17730fb5141b..d65f5630d6a13 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1882,7 +1882,6 @@ externals['sass-loader'] = 'next/dist/compiled/sass-loader' // eslint-disable-next-line camelcase export async function ncc_sass_loader(task, opts) { const sassLoaderPath = require.resolve('sass-loader') - console.log({ sassLoaderPath }) const utilsPath = join(dirname(sassLoaderPath), 'utils.js') const originalContent = await fs.readFile(utilsPath, 'utf8') From 53611d0a2561b5321249afead6319c8d596cd866 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Thu, 14 Nov 2024 17:24:29 +0900 Subject: [PATCH 03/19] add compiled sass-loader-16 --- .../next/src/compiled/sass-loader-16/LICENSE | 20 +++++++++++++++++++ .../next/src/compiled/sass-loader-16/cjs.js | 1 + .../src/compiled/sass-loader-16/package.json | 1 + 3 files changed, 22 insertions(+) create mode 100644 packages/next/src/compiled/sass-loader-16/LICENSE create mode 100644 packages/next/src/compiled/sass-loader-16/cjs.js create mode 100644 packages/next/src/compiled/sass-loader-16/package.json diff --git a/packages/next/src/compiled/sass-loader-16/LICENSE b/packages/next/src/compiled/sass-loader-16/LICENSE new file mode 100644 index 0000000000000..3d5fa7325883a --- /dev/null +++ b/packages/next/src/compiled/sass-loader-16/LICENSE @@ -0,0 +1,20 @@ +Copyright JS Foundation and other contributors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/packages/next/src/compiled/sass-loader-16/cjs.js b/packages/next/src/compiled/sass-loader-16/cjs.js new file mode 100644 index 0000000000000..cc2ee2f0989ed --- /dev/null +++ b/packages/next/src/compiled/sass-loader-16/cjs.js @@ -0,0 +1 @@ +(function(){"use strict";var __webpack_modules__={591:function(e,t,s){const n=s(949);e.exports=n.default},949:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(s(310));var o=_interopRequireDefault(s(17));var r=_interopRequireDefault(s(645));var a=s(773);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}async function loader(e){const t=this.getOptions(r.default);const s=this.async();let i;try{i=(0,a.getSassImplementation)(this,t.implementation)}catch(e){s(e);return}const c=typeof t.sourceMap==="boolean"?t.sourceMap:this.sourceMap;const l=typeof i.compileStringAsync==="undefined"?"legacy":typeof t.api==="undefined"?"modern":t.api;const p=await(0,a.getSassOptions)(this,t,e,i,c,l);const u=typeof t.webpackImporter==="boolean"?t.webpackImporter:true;if(u){const e=l==="modern"||l==="modern-compiler";if(!e){const{includePaths:e}=p;p.importer.push((0,a.getWebpackImporter)(this,i,e))}else{p.importers.push((0,a.getModernWebpackImporter)(this,i,[]))}}let d;try{d=(0,a.getCompileFn)(this,i,l)}catch(e){s(e);return}let f;try{f=await d(p)}catch(e){if(e.span&&typeof e.span.url!=="undefined"){this.addDependency(n.default.fileURLToPath(e.span.url))}else if(typeof e.file!=="undefined"){this.addDependency(o.default.normalize(e.file))}s((0,a.errorFactory)(e));return}let m=f.sourceMap?f.sourceMap:f.map?JSON.parse(f.map):null;if(m&&c){m=(0,a.normalizeSourceMap)(m,this.rootContext)}if(typeof f.loadedUrls!=="undefined"){f.loadedUrls.filter((e=>e.protocol==="file:")).forEach((e=>{const t=n.default.fileURLToPath(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}else if(typeof f.stats!=="undefined"&&typeof f.stats.includedFiles!=="undefined"){f.stats.includedFiles.forEach((e=>{const t=o.default.normalize(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}s(null,f.css.toString(),m)}var i=t["default"]=loader},773:function(__unused_webpack_module,exports,__nccwpck_require__){Object.defineProperty(exports,"__esModule",{value:true});exports.errorFactory=errorFactory;exports.getCompileFn=getCompileFn;exports.getModernWebpackImporter=getModernWebpackImporter;exports.getSassImplementation=getSassImplementation;exports.getSassOptions=getSassOptions;exports.getWebpackImporter=getWebpackImporter;exports.getWebpackResolver=getWebpackResolver;exports.normalizeSourceMap=normalizeSourceMap;var _url=_interopRequireDefault(__nccwpck_require__(310));var _path=_interopRequireDefault(__nccwpck_require__(17));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function getDefaultSassImplementation(){let sassImplPkg="sass";try{require.resolve("sass-embedded");sassImplPkg="sass-embedded"}catch(ignoreError){try{eval("require").resolve("sass")}catch(_ignoreError){try{eval("require").resolve("node-sass");sassImplPkg="node-sass"}catch(e){sassImplPkg="sass"}}}return __nccwpck_require__(438)}function getSassImplementation(e,t){let s=t;if(!s){s=getDefaultSassImplementation()}if(typeof s==="string"){s=require(s)}const{info:n}=s;if(!n){throw new Error("Unknown Sass implementation.")}const o=n.split("\t");if(o.length<2){throw new Error(`Unknown Sass implementation "${n}".`)}const[r]=o;if(r==="dart-sass"){return s}else if(r==="node-sass"){return s}else if(r==="sass-embedded"){return s}throw new Error(`Unknown Sass implementation "${r}".`)}function isProductionLikeMode(e){return e.mode==="production"||!e.mode}function proxyCustomImporters(e,t){return[].concat(e).map((e=>function proxyImporter(...s){const n={...this,webpackLoaderContext:t};return e.apply(n,s)}))}async function getSassOptions(e,t,s,n,o,r){const a=t.sassOptions?typeof t.sassOptions==="function"?t.sassOptions(e)||{}:t.sassOptions:{};const i={...a,data:t.additionalData?typeof t.additionalData==="function"?await t.additionalData(s,e):`${t.additionalData}\n${s}`:s};if(!i.logger){const s=t.warnRuleAsWarning!==false;const n=e.getLogger("sass-loader");const formatSpan=e=>`Warning on line ${e.start.line}, column ${e.start.column} of ${e.url||"-"}:${e.start.line}:${e.start.column}:\n`;const formatDebugSpan=e=>`[debug:${e.start.line}:${e.start.column}] `;i.logger={debug(e,t){let s="";if(t.span){s=formatDebugSpan(t.span)}s+=e;n.debug(s)},warn(t,o){let r="";if(o.deprecation){r+="Deprecation "}if(o.span){r+=formatSpan(o.span)}r+=t;if(o.span&&o.span.context){r+=`\n\n${o.span.start.line} | ${o.span.context}`}if(o.stack&&o.stack!=="null"){r+=`\n\n${o.stack}`}if(s){const t=new Error(r);t.name="SassWarning";t.stack=null;e.emitWarning(t)}else{n.warn(r)}}}}const c=r==="modern"||r==="modern-compiler";const{resourcePath:l}=e;if(c){i.url=_url.default.pathToFileURL(l);if(!i.style&&isProductionLikeMode(e)){i.style="compressed"}if(o){i.sourceMap=true}if(typeof i.syntax==="undefined"){const e=_path.default.extname(l);if(e&&e.toLowerCase()===".scss"){i.syntax="scss"}else if(e&&e.toLowerCase()===".sass"){i.syntax="indented"}else if(e&&e.toLowerCase()===".css"){i.syntax="css"}}i.loadPaths=[].concat((i.loadPaths?i.loadPaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);i.importers=i.importers?Array.isArray(i.importers)?i.importers.slice():[i.importers]:[]}else{i.file=l;if(!i.outputStyle&&isProductionLikeMode(e)){i.outputStyle="compressed"}if(o){i.sourceMap=true;i.outFile=_path.default.join(e.rootContext,"style.css.map");i.sourceMapContents=true;i.omitSourceMapUrl=true;i.sourceMapEmbed=false}const s=_path.default.extname(l);if(s&&s.toLowerCase()===".sass"&&typeof i.indentedSyntax==="undefined"){i.indentedSyntax=true}else{i.indentedSyntax=Boolean(i.indentedSyntax)}i.importer=i.importer?proxyCustomImporters(Array.isArray(i.importer)?i.importer.slice():[i.importer],e):[];if(t.webpackImporter===false&&i.importer.length===0){i.importer=undefined}i.includePaths=[].concat(process.cwd()).concat((i.includePaths?i.includePaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);if(typeof i.charset==="undefined"){i.charset=true}}return i}const MODULE_REQUEST_REGEX=/^[^?]*~/;const IS_MODULE_IMPORT=/^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;const IS_PKG_SCHEME=/^pkg:/i;function getPossibleRequests(e,t=false,s=false){let n=e;if(t){if(MODULE_REQUEST_REGEX.test(e)){n=n.replace(MODULE_REQUEST_REGEX,"")}if(IS_PKG_SCHEME.test(e)){n=`${n.slice(4)}`;return[...new Set([n,e])]}if(IS_MODULE_IMPORT.test(e)||IS_PKG_SCHEME.test(e)){n=n[n.length-1]==="/"?n:`${n}/`;return[...new Set([n,e])]}}const o=_path.default.extname(n).toLowerCase();if(o===".css"){return[]}const r=_path.default.dirname(n);const a=r==="."?"":`${r}/`;const i=_path.default.basename(n);const c=_path.default.basename(n,o);return[...new Set([].concat(s?[`${a}_${c}.import${o}`,`${a}${c}.import${o}`]:[]).concat([`${a}_${i}`,`${a}${i}`]).concat(t?[e]:[]))]}function promiseResolve(e){return(t,s)=>new Promise(((n,o)=>{e(t,s,((e,t)=>{if(e){o(e)}else{n(t)}}))}))}async function startResolving(e){if(e.length===0){return Promise.reject()}const[{possibleRequests:t}]=e;if(t.length===0){return Promise.reject()}const[{resolve:s,context:n}]=e;try{return await s(n,t[0])}catch(s){const[,...n]=t;if(n.length===0){const[,...t]=e;return startResolving(t)}e[0].possibleRequests=n;return startResolving(e)}}const IS_SPECIAL_MODULE_IMPORT=/^~[^/]+$/;const IS_NATIVE_WIN32_PATH=/^[a-z]:[/\\]|^\\\\/i;function getWebpackResolver(e,t,s=[]){const n=t&&typeof t.compileStringAsync!=="undefined";const o=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const r=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index.import","_index","index.import","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const a=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const i=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index.import","_index","index.import","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));return(e,t,c)=>{if(!n&&!_path.default.isAbsolute(e)){return Promise.reject()}const l=t;const p=l.slice(0,5).toLowerCase()==="file:";if(p){try{t=_url.default.fileURLToPath(l)}catch(e){t=t.slice(7)}}let u=[];const d=!IS_SPECIAL_MODULE_IMPORT.test(t)&&!IS_PKG_SCHEME.test(t)&&!p&&!l.startsWith("/")&&!IS_NATIVE_WIN32_PATH.test(l);if(s.length>0&&d){const a=getPossibleRequests(t,false,c);if(!n){u=u.concat({resolve:c?r:o,context:_path.default.dirname(e),possibleRequests:a})}u=u.concat(s.map((e=>({resolve:c?r:o,context:e,possibleRequests:a}))))}const f=getPossibleRequests(t,true,c);u=u.concat({resolve:c?i:a,context:_path.default.dirname(e),possibleRequests:f});return startResolving(u)}}const MATCH_CSS=/\.css$/i;function getModernWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return{async canonicalize(t,s){const{fromImport:o}=s;const r=s.containingUrl?_url.default.fileURLToPath(s.containingUrl.toString()):e.resourcePath;let a;try{a=await n(r,t,o)}catch(e){return null}e.addDependency(_path.default.normalize(a));return _url.default.pathToFileURL(a)},async load(t){const s=_path.default.extname(t.pathname);let n;if(s&&s.toLowerCase()===".scss"){n="scss"}else if(s&&s.toLowerCase()===".sass"){n="indented"}else if(s&&s.toLowerCase()===".css"){n="css"}else{n="scss"}try{const s=await new Promise(((s,n)=>{const o=_url.default.fileURLToPath(t);e.fs.readFile(o,"utf8",((e,t)=>{if(e){n(e);return}s(t)}))}));return{contents:s,syntax:n,sourceMapUrl:t}}catch(e){return null}}}}function getWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return function importer(t,s,o){const{fromImport:r}=this;n(s,t,r).then((t=>{e.addDependency(_path.default.normalize(t));o({file:t.replace(MATCH_CSS,"")})})).catch((()=>{o({file:t})}))}}let nodeSassJobQueue=null;const sassModernCompilers=new WeakMap;function getCompileFn(e,t,s){if(typeof t.compileStringAsync!=="undefined"){if(s==="modern"){return e=>{const{data:s,...n}=e;return t.compileStringAsync(s,n)}}if(s==="modern-compiler"){return async s=>{const n=e._compiler;const{data:o,...r}=s;if(n){if(!sassModernCompilers.has(n)){const e=await t.initAsyncCompiler();if(!sassModernCompilers.has(n)){sassModernCompilers.set(n,e);n.hooks.shutdown.tap("sass-loader",(()=>{e.dispose()}))}else{e.dispose()}}return sassModernCompilers.get(n).compileStringAsync(o,r)}return t.compileStringAsync(o,r)}}return e=>new Promise(((s,n)=>{t.render(e,((e,t)=>{if(e){n(e);return}s(t)}))}))}if(s==="modern"||s==="modern-compiler"){throw new Error("Modern API is not supported for 'node-sass'")}if(nodeSassJobQueue===null){const e=Number(process.env.UV_THREADPOOL_SIZE||4);const s=__nccwpck_require__(175);nodeSassJobQueue=s.queue(t.render.bind(t),e-1)}return e=>new Promise(((t,s)=>{nodeSassJobQueue.push.bind(nodeSassJobQueue)(e,((e,n)=>{if(e){s(e);return}t(n)}))}))}const ABSOLUTE_SCHEME=/^[A-Za-z0-9+\-.]+:/;function getURLType(e){if(e[0]==="/"){if(e[1]==="/"){return"scheme-relative"}return"path-absolute"}if(IS_NATIVE_WIN32_PATH.test(e)){return"path-absolute"}return ABSOLUTE_SCHEME.test(e)?"absolute":"path-relative"}function normalizeSourceMap(e,t){const s=e;if(typeof s.file!=="undefined"){delete s.file}s.sourceRoot="";s.sources=s.sources.map((e=>{const s=getURLType(e);if(s==="absolute"&&/^file:/i.test(e)){return _url.default.fileURLToPath(e)}else if(s==="path-relative"){return _path.default.resolve(t,_path.default.normalize(e))}return e}));return s}function errorFactory(e){let t;if(e.formatted){t=e.formatted.replace(/^(.+)?Error: /,"")}else{t=(e.message||e.toString()).replace(/^(.+)?Error: /,"")}const s=new Error(t,{cause:e});s.name=e.name;s.stack=null;return s}},175:function(e){e.exports=require("next/dist/compiled/neo-async")},17:function(e){e.exports=require("path")},438:function(e){e.exports=require("sass")},310:function(e){e.exports=require("url")},645:function(e){e.exports=JSON.parse('{"title":"Sass Loader options","type":"object","properties":{"implementation":{"description":"The implementation of the sass to be used.","link":"https://github.com/webpack-contrib/sass-loader#implementation","anyOf":[{"type":"string"},{"type":"object"}]},"api":{"description":"Switch between old and modern API for `sass` (`Dart Sass`) and `Sass Embedded` implementations.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","enum":["legacy","modern","modern-compiler"]},"sassOptions":{"description":"Options for `node-sass` or `sass` (`Dart Sass`) implementation.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","anyOf":[{"type":"object","additionalProperties":true},{"instanceof":"Function"}]},"additionalData":{"description":"Prepends/Appends `Sass`/`SCSS` code before the actual entry file.","link":"https://github.com/webpack-contrib/sass-loader#additionaldata","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/sass-loader#sourcemap","type":"boolean"},"webpackImporter":{"description":"Enables/Disables default `webpack` importer.","link":"https://github.com/webpack-contrib/sass-loader#webpackimporter","type":"boolean"},"warnRuleAsWarning":{"description":"Treats the \'@warn\' rule as a webpack warning.","link":"https://github.com/webpack-contrib/sass-loader#warnruleaswarning","type":"boolean"}},"additionalProperties":false}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(591);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/packages/next/src/compiled/sass-loader-16/package.json b/packages/next/src/compiled/sass-loader-16/package.json new file mode 100644 index 0000000000000..91526a6dccf9b --- /dev/null +++ b/packages/next/src/compiled/sass-loader-16/package.json @@ -0,0 +1 @@ +{"name":"sass-loader","main":"cjs.js","author":"J. Tangelder","license":"MIT"} From 9976917ad2ed2fa4e600d49f7d73c263b153f422 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 03:38:59 +0900 Subject: [PATCH 04/19] remove experimental option --- .../next-core/src/next_shared/webpack_rules/sass.rs | 12 +----------- packages/next/src/server/config-schema.ts | 5 ----- packages/next/src/server/config-shared.ts | 3 --- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/crates/next-core/src/next_shared/webpack_rules/sass.rs b/crates/next-core/src/next_shared/webpack_rules/sass.rs index 4ed32e30e92c9..296142d0f49ba 100644 --- a/crates/next-core/src/next_shared/webpack_rules/sass.rs +++ b/crates/next-core/src/next_shared/webpack_rules/sass.rs @@ -36,19 +36,9 @@ pub async fn maybe_add_sass_loader( let additional_data = sass_options .get("prependData") .or(sass_options.get("additionalData")); - // TODO: Remove sass-loader-16 once we upgrade sass-loader to 16 - let use_upgraded_loader = sass_options - .get("experimental") - .and_then(|e| e.get("useUpgradedLoader")) - .and_then(|v| v.as_bool()) - .unwrap_or(false); let rule = rules.get_mut(pattern); let sass_loader = WebpackLoaderItem { - loader: if use_upgraded_loader { - "next/dist/compiled/sass-loader-16".into() - } else { - "next/dist/compiled/sass-loader".into() - }, + loader: "next/dist/compiled/sass-loader".into(), options: take( serde_json::json!({ "implementation": sass_options.get("implementation"), diff --git a/packages/next/src/server/config-schema.ts b/packages/next/src/server/config-schema.ts index f1596dbfd1121..ace53d76eb274 100644 --- a/packages/next/src/server/config-schema.ts +++ b/packages/next/src/server/config-schema.ts @@ -614,11 +614,6 @@ export const configSchema: zod.ZodType = z.lazy(() => // sassOptions properties are unknown besides implementation, use z.any() here sassOptions: z .object({ - experimental: z - .object({ - useUpgradedLoader: z.boolean().optional(), - }) - .optional(), implementation: z.string().optional(), }) .catchall(z.any()) diff --git a/packages/next/src/server/config-shared.ts b/packages/next/src/server/config-shared.ts index 54e03a93c9d7f..76217dc7d2a71 100644 --- a/packages/next/src/server/config-shared.ts +++ b/packages/next/src/server/config-shared.ts @@ -797,9 +797,6 @@ export interface NextConfig extends Record { /** @see [Customizing sass options](https://nextjs.org/docs/app/api-reference/next-config-js/sassOptions) */ sassOptions?: { - experimental?: { - useUpgradedLoader?: boolean - } implementation?: string [key: string]: any } From c6cad8f7f88cad9adec445894698d3cb5b790360 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 03:42:03 +0900 Subject: [PATCH 05/19] revert taskfile --- packages/next/taskfile.js | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index d65f5630d6a13..be1b7e9178b34 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1906,36 +1906,6 @@ export async function ncc_sass_loader(task, opts) { }) .target('src/compiled/sass-loader') } -// TODO: Remove sass-loader-16 once we upgrade sass-loader to 16 -externals['sass-loader-16'] = 'next/dist/compiled/sass-loader-16' -// eslint-disable-next-line camelcase -export async function ncc_sass_loader_16(task, opts) { - const sassLoader16Path = require.resolve('sass-loader-16') - console.log({ sassLoader16Path }) - const utilsPath = join(dirname(sassLoader16Path), 'utils.js') - const originalContent = await fs.readFile(utilsPath, 'utf8') - - await fs.writeFile( - utilsPath, - originalContent.replace( - /require\.resolve\(["'](sass|node-sass)["']\)/g, - 'eval("require").resolve("$1")' - ) - ) - - await task - .source(relative(__dirname, sassLoader16Path)) - .ncc({ - packageName: 'sass-loader-16', - externals: { - ...externals, - 'schema-utils': externals['schema-utils3'], - 'loader-utils': externals['loader-utils2'], - }, - target: 'es5', - }) - .target('src/compiled/sass-loader-16') -} // eslint-disable-next-line camelcase externals['schema-utils'] = 'MISSING_VERSION schema-utils version not specified' externals['schema-utils2'] = 'next/dist/compiled/schema-utils2' @@ -2456,7 +2426,6 @@ export async function ncc(task, opts) { 'copy_constants_browserify', 'copy_vendor_react', 'ncc_sass_loader', - 'ncc_sass_loader_16', 'ncc_jest_worker', 'ncc_edge_runtime_cookies', 'ncc_edge_runtime_primitives', From c7f56be331c865015ddab6a7bc65d1804f4aec28 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 03:42:19 +0900 Subject: [PATCH 06/19] bump sass-loader to v16 --- packages/next/package.json | 3 +-- pnpm-lock.yaml | 41 +++++--------------------------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/packages/next/package.json b/packages/next/package.json index d9c8d237c5908..22d41fc39639a 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -293,8 +293,7 @@ "raw-body": "2.4.1", "react-refresh": "0.12.0", "regenerator-runtime": "0.13.4", - "sass-loader": "15.0.0", - "sass-loader-16": "npm:sass-loader@16.0.3", + "sass-loader": "16.0.0", "schema-utils2": "npm:schema-utils@2.7.1", "schema-utils3": "npm:schema-utils@3.0.0", "semver": "7.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 54eb917816a24..f240a9ca0733e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1383,11 +1383,8 @@ importers: specifier: 0.13.4 version: 0.13.4 sass-loader: - specifier: 15.0.0 - version: 15.0.0(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))) - sass-loader-16: - specifier: npm:sass-loader@16.0.3 - version: sass-loader@16.0.3(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))) + specifier: 16.0.0 + version: 16.0.0(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))) schema-utils2: specifier: npm:schema-utils@2.7.1 version: schema-utils@2.7.1 @@ -13514,29 +13511,8 @@ packages: safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} - sass-loader@15.0.0: - resolution: {integrity: sha512-mbXAL7sI/fgt3skXR6xHxtKkaGyxRrGf7zrU4hLLWxBDJEcAe0QsoNy92qKttCb3zfMniTkU2kD9yakUKtW7vQ==} - engines: {node: '>= 18.12.0'} - peerDependencies: - '@rspack/core': 0.x || 1.x - node-sass: ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 - sass: ^1.3.0 - sass-embedded: '*' - webpack: 5.96.1 - peerDependenciesMeta: - '@rspack/core': - optional: true - node-sass: - optional: true - sass: - optional: true - sass-embedded: - optional: true - webpack: - optional: true - - sass-loader@16.0.3: - resolution: {integrity: sha512-gosNorT1RCkuCMyihv6FBRR7BMV06oKRAs+l4UMp1mlcVg9rWN6KMmUj3igjQwmYys4mDP3etEYJgiHRbgHCHA==} + sass-loader@16.0.0: + resolution: {integrity: sha512-n13Z+3rU9A177dk4888czcVFiC8CL9dii4qpXWUg3YIIgZEvi9TCFKjOQcbK0kJM7DJu9VucrZFddvNfYCPwtw==} engines: {node: '>= 18.12.0'} peerDependencies: '@rspack/core': 0.x || 1.x @@ -30399,14 +30375,7 @@ snapshots: safer-buffer@2.1.2: {} - sass-loader@15.0.0(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))): - dependencies: - neo-async: 2.6.2 - optionalDependencies: - sass: 1.77.8 - webpack: 5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13)) - - sass-loader@16.0.3(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))): + sass-loader@16.0.0(sass@1.77.8)(webpack@5.96.1(@swc/core@1.7.0-nightly-20240714.1(@swc/helpers@0.5.13))): dependencies: neo-async: 2.6.2 optionalDependencies: From e70382401e34e2bcf23f8a4e3522cbb0abcc67bb Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 03:44:09 +0900 Subject: [PATCH 07/19] add jiwon to vscode workspace for usage in comment --- .vscode/settings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 06425d362dd17..845c6e3d7dd9d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -58,16 +58,16 @@ "RUST_BACKTRACE": "0" }, "cSpell.words": [ - "codemod", - "codemods", - "Destructuring", "buildtime", "callsites", "codemod", + "codemods", "datastream", "deduped", + "Destructuring", "draftmode", "Entrypoints", + "jiwon", "jscodeshift", "napi", "navigations", From ac19b5253fc7250aa0dc07d0075f716a8f0aa024 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 03:46:35 +0900 Subject: [PATCH 08/19] remove sass-loader-16 --- .../next/src/compiled/sass-loader-16/LICENSE | 20 ------------------- .../next/src/compiled/sass-loader-16/cjs.js | 1 - .../src/compiled/sass-loader-16/package.json | 1 - 3 files changed, 22 deletions(-) delete mode 100644 packages/next/src/compiled/sass-loader-16/LICENSE delete mode 100644 packages/next/src/compiled/sass-loader-16/cjs.js delete mode 100644 packages/next/src/compiled/sass-loader-16/package.json diff --git a/packages/next/src/compiled/sass-loader-16/LICENSE b/packages/next/src/compiled/sass-loader-16/LICENSE deleted file mode 100644 index 3d5fa7325883a..0000000000000 --- a/packages/next/src/compiled/sass-loader-16/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright JS Foundation and other contributors - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/packages/next/src/compiled/sass-loader-16/cjs.js b/packages/next/src/compiled/sass-loader-16/cjs.js deleted file mode 100644 index cc2ee2f0989ed..0000000000000 --- a/packages/next/src/compiled/sass-loader-16/cjs.js +++ /dev/null @@ -1 +0,0 @@ -(function(){"use strict";var __webpack_modules__={591:function(e,t,s){const n=s(949);e.exports=n.default},949:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(s(310));var o=_interopRequireDefault(s(17));var r=_interopRequireDefault(s(645));var a=s(773);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}async function loader(e){const t=this.getOptions(r.default);const s=this.async();let i;try{i=(0,a.getSassImplementation)(this,t.implementation)}catch(e){s(e);return}const c=typeof t.sourceMap==="boolean"?t.sourceMap:this.sourceMap;const l=typeof i.compileStringAsync==="undefined"?"legacy":typeof t.api==="undefined"?"modern":t.api;const p=await(0,a.getSassOptions)(this,t,e,i,c,l);const u=typeof t.webpackImporter==="boolean"?t.webpackImporter:true;if(u){const e=l==="modern"||l==="modern-compiler";if(!e){const{includePaths:e}=p;p.importer.push((0,a.getWebpackImporter)(this,i,e))}else{p.importers.push((0,a.getModernWebpackImporter)(this,i,[]))}}let d;try{d=(0,a.getCompileFn)(this,i,l)}catch(e){s(e);return}let f;try{f=await d(p)}catch(e){if(e.span&&typeof e.span.url!=="undefined"){this.addDependency(n.default.fileURLToPath(e.span.url))}else if(typeof e.file!=="undefined"){this.addDependency(o.default.normalize(e.file))}s((0,a.errorFactory)(e));return}let m=f.sourceMap?f.sourceMap:f.map?JSON.parse(f.map):null;if(m&&c){m=(0,a.normalizeSourceMap)(m,this.rootContext)}if(typeof f.loadedUrls!=="undefined"){f.loadedUrls.filter((e=>e.protocol==="file:")).forEach((e=>{const t=n.default.fileURLToPath(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}else if(typeof f.stats!=="undefined"&&typeof f.stats.includedFiles!=="undefined"){f.stats.includedFiles.forEach((e=>{const t=o.default.normalize(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}s(null,f.css.toString(),m)}var i=t["default"]=loader},773:function(__unused_webpack_module,exports,__nccwpck_require__){Object.defineProperty(exports,"__esModule",{value:true});exports.errorFactory=errorFactory;exports.getCompileFn=getCompileFn;exports.getModernWebpackImporter=getModernWebpackImporter;exports.getSassImplementation=getSassImplementation;exports.getSassOptions=getSassOptions;exports.getWebpackImporter=getWebpackImporter;exports.getWebpackResolver=getWebpackResolver;exports.normalizeSourceMap=normalizeSourceMap;var _url=_interopRequireDefault(__nccwpck_require__(310));var _path=_interopRequireDefault(__nccwpck_require__(17));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function getDefaultSassImplementation(){let sassImplPkg="sass";try{require.resolve("sass-embedded");sassImplPkg="sass-embedded"}catch(ignoreError){try{eval("require").resolve("sass")}catch(_ignoreError){try{eval("require").resolve("node-sass");sassImplPkg="node-sass"}catch(e){sassImplPkg="sass"}}}return __nccwpck_require__(438)}function getSassImplementation(e,t){let s=t;if(!s){s=getDefaultSassImplementation()}if(typeof s==="string"){s=require(s)}const{info:n}=s;if(!n){throw new Error("Unknown Sass implementation.")}const o=n.split("\t");if(o.length<2){throw new Error(`Unknown Sass implementation "${n}".`)}const[r]=o;if(r==="dart-sass"){return s}else if(r==="node-sass"){return s}else if(r==="sass-embedded"){return s}throw new Error(`Unknown Sass implementation "${r}".`)}function isProductionLikeMode(e){return e.mode==="production"||!e.mode}function proxyCustomImporters(e,t){return[].concat(e).map((e=>function proxyImporter(...s){const n={...this,webpackLoaderContext:t};return e.apply(n,s)}))}async function getSassOptions(e,t,s,n,o,r){const a=t.sassOptions?typeof t.sassOptions==="function"?t.sassOptions(e)||{}:t.sassOptions:{};const i={...a,data:t.additionalData?typeof t.additionalData==="function"?await t.additionalData(s,e):`${t.additionalData}\n${s}`:s};if(!i.logger){const s=t.warnRuleAsWarning!==false;const n=e.getLogger("sass-loader");const formatSpan=e=>`Warning on line ${e.start.line}, column ${e.start.column} of ${e.url||"-"}:${e.start.line}:${e.start.column}:\n`;const formatDebugSpan=e=>`[debug:${e.start.line}:${e.start.column}] `;i.logger={debug(e,t){let s="";if(t.span){s=formatDebugSpan(t.span)}s+=e;n.debug(s)},warn(t,o){let r="";if(o.deprecation){r+="Deprecation "}if(o.span){r+=formatSpan(o.span)}r+=t;if(o.span&&o.span.context){r+=`\n\n${o.span.start.line} | ${o.span.context}`}if(o.stack&&o.stack!=="null"){r+=`\n\n${o.stack}`}if(s){const t=new Error(r);t.name="SassWarning";t.stack=null;e.emitWarning(t)}else{n.warn(r)}}}}const c=r==="modern"||r==="modern-compiler";const{resourcePath:l}=e;if(c){i.url=_url.default.pathToFileURL(l);if(!i.style&&isProductionLikeMode(e)){i.style="compressed"}if(o){i.sourceMap=true}if(typeof i.syntax==="undefined"){const e=_path.default.extname(l);if(e&&e.toLowerCase()===".scss"){i.syntax="scss"}else if(e&&e.toLowerCase()===".sass"){i.syntax="indented"}else if(e&&e.toLowerCase()===".css"){i.syntax="css"}}i.loadPaths=[].concat((i.loadPaths?i.loadPaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);i.importers=i.importers?Array.isArray(i.importers)?i.importers.slice():[i.importers]:[]}else{i.file=l;if(!i.outputStyle&&isProductionLikeMode(e)){i.outputStyle="compressed"}if(o){i.sourceMap=true;i.outFile=_path.default.join(e.rootContext,"style.css.map");i.sourceMapContents=true;i.omitSourceMapUrl=true;i.sourceMapEmbed=false}const s=_path.default.extname(l);if(s&&s.toLowerCase()===".sass"&&typeof i.indentedSyntax==="undefined"){i.indentedSyntax=true}else{i.indentedSyntax=Boolean(i.indentedSyntax)}i.importer=i.importer?proxyCustomImporters(Array.isArray(i.importer)?i.importer.slice():[i.importer],e):[];if(t.webpackImporter===false&&i.importer.length===0){i.importer=undefined}i.includePaths=[].concat(process.cwd()).concat((i.includePaths?i.includePaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);if(typeof i.charset==="undefined"){i.charset=true}}return i}const MODULE_REQUEST_REGEX=/^[^?]*~/;const IS_MODULE_IMPORT=/^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;const IS_PKG_SCHEME=/^pkg:/i;function getPossibleRequests(e,t=false,s=false){let n=e;if(t){if(MODULE_REQUEST_REGEX.test(e)){n=n.replace(MODULE_REQUEST_REGEX,"")}if(IS_PKG_SCHEME.test(e)){n=`${n.slice(4)}`;return[...new Set([n,e])]}if(IS_MODULE_IMPORT.test(e)||IS_PKG_SCHEME.test(e)){n=n[n.length-1]==="/"?n:`${n}/`;return[...new Set([n,e])]}}const o=_path.default.extname(n).toLowerCase();if(o===".css"){return[]}const r=_path.default.dirname(n);const a=r==="."?"":`${r}/`;const i=_path.default.basename(n);const c=_path.default.basename(n,o);return[...new Set([].concat(s?[`${a}_${c}.import${o}`,`${a}${c}.import${o}`]:[]).concat([`${a}_${i}`,`${a}${i}`]).concat(t?[e]:[]))]}function promiseResolve(e){return(t,s)=>new Promise(((n,o)=>{e(t,s,((e,t)=>{if(e){o(e)}else{n(t)}}))}))}async function startResolving(e){if(e.length===0){return Promise.reject()}const[{possibleRequests:t}]=e;if(t.length===0){return Promise.reject()}const[{resolve:s,context:n}]=e;try{return await s(n,t[0])}catch(s){const[,...n]=t;if(n.length===0){const[,...t]=e;return startResolving(t)}e[0].possibleRequests=n;return startResolving(e)}}const IS_SPECIAL_MODULE_IMPORT=/^~[^/]+$/;const IS_NATIVE_WIN32_PATH=/^[a-z]:[/\\]|^\\\\/i;function getWebpackResolver(e,t,s=[]){const n=t&&typeof t.compileStringAsync!=="undefined";const o=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const r=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index.import","_index","index.import","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const a=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const i=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index.import","_index","index.import","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));return(e,t,c)=>{if(!n&&!_path.default.isAbsolute(e)){return Promise.reject()}const l=t;const p=l.slice(0,5).toLowerCase()==="file:";if(p){try{t=_url.default.fileURLToPath(l)}catch(e){t=t.slice(7)}}let u=[];const d=!IS_SPECIAL_MODULE_IMPORT.test(t)&&!IS_PKG_SCHEME.test(t)&&!p&&!l.startsWith("/")&&!IS_NATIVE_WIN32_PATH.test(l);if(s.length>0&&d){const a=getPossibleRequests(t,false,c);if(!n){u=u.concat({resolve:c?r:o,context:_path.default.dirname(e),possibleRequests:a})}u=u.concat(s.map((e=>({resolve:c?r:o,context:e,possibleRequests:a}))))}const f=getPossibleRequests(t,true,c);u=u.concat({resolve:c?i:a,context:_path.default.dirname(e),possibleRequests:f});return startResolving(u)}}const MATCH_CSS=/\.css$/i;function getModernWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return{async canonicalize(t,s){const{fromImport:o}=s;const r=s.containingUrl?_url.default.fileURLToPath(s.containingUrl.toString()):e.resourcePath;let a;try{a=await n(r,t,o)}catch(e){return null}e.addDependency(_path.default.normalize(a));return _url.default.pathToFileURL(a)},async load(t){const s=_path.default.extname(t.pathname);let n;if(s&&s.toLowerCase()===".scss"){n="scss"}else if(s&&s.toLowerCase()===".sass"){n="indented"}else if(s&&s.toLowerCase()===".css"){n="css"}else{n="scss"}try{const s=await new Promise(((s,n)=>{const o=_url.default.fileURLToPath(t);e.fs.readFile(o,"utf8",((e,t)=>{if(e){n(e);return}s(t)}))}));return{contents:s,syntax:n,sourceMapUrl:t}}catch(e){return null}}}}function getWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return function importer(t,s,o){const{fromImport:r}=this;n(s,t,r).then((t=>{e.addDependency(_path.default.normalize(t));o({file:t.replace(MATCH_CSS,"")})})).catch((()=>{o({file:t})}))}}let nodeSassJobQueue=null;const sassModernCompilers=new WeakMap;function getCompileFn(e,t,s){if(typeof t.compileStringAsync!=="undefined"){if(s==="modern"){return e=>{const{data:s,...n}=e;return t.compileStringAsync(s,n)}}if(s==="modern-compiler"){return async s=>{const n=e._compiler;const{data:o,...r}=s;if(n){if(!sassModernCompilers.has(n)){const e=await t.initAsyncCompiler();if(!sassModernCompilers.has(n)){sassModernCompilers.set(n,e);n.hooks.shutdown.tap("sass-loader",(()=>{e.dispose()}))}else{e.dispose()}}return sassModernCompilers.get(n).compileStringAsync(o,r)}return t.compileStringAsync(o,r)}}return e=>new Promise(((s,n)=>{t.render(e,((e,t)=>{if(e){n(e);return}s(t)}))}))}if(s==="modern"||s==="modern-compiler"){throw new Error("Modern API is not supported for 'node-sass'")}if(nodeSassJobQueue===null){const e=Number(process.env.UV_THREADPOOL_SIZE||4);const s=__nccwpck_require__(175);nodeSassJobQueue=s.queue(t.render.bind(t),e-1)}return e=>new Promise(((t,s)=>{nodeSassJobQueue.push.bind(nodeSassJobQueue)(e,((e,n)=>{if(e){s(e);return}t(n)}))}))}const ABSOLUTE_SCHEME=/^[A-Za-z0-9+\-.]+:/;function getURLType(e){if(e[0]==="/"){if(e[1]==="/"){return"scheme-relative"}return"path-absolute"}if(IS_NATIVE_WIN32_PATH.test(e)){return"path-absolute"}return ABSOLUTE_SCHEME.test(e)?"absolute":"path-relative"}function normalizeSourceMap(e,t){const s=e;if(typeof s.file!=="undefined"){delete s.file}s.sourceRoot="";s.sources=s.sources.map((e=>{const s=getURLType(e);if(s==="absolute"&&/^file:/i.test(e)){return _url.default.fileURLToPath(e)}else if(s==="path-relative"){return _path.default.resolve(t,_path.default.normalize(e))}return e}));return s}function errorFactory(e){let t;if(e.formatted){t=e.formatted.replace(/^(.+)?Error: /,"")}else{t=(e.message||e.toString()).replace(/^(.+)?Error: /,"")}const s=new Error(t,{cause:e});s.name=e.name;s.stack=null;return s}},175:function(e){e.exports=require("next/dist/compiled/neo-async")},17:function(e){e.exports=require("path")},438:function(e){e.exports=require("sass")},310:function(e){e.exports=require("url")},645:function(e){e.exports=JSON.parse('{"title":"Sass Loader options","type":"object","properties":{"implementation":{"description":"The implementation of the sass to be used.","link":"https://github.com/webpack-contrib/sass-loader#implementation","anyOf":[{"type":"string"},{"type":"object"}]},"api":{"description":"Switch between old and modern API for `sass` (`Dart Sass`) and `Sass Embedded` implementations.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","enum":["legacy","modern","modern-compiler"]},"sassOptions":{"description":"Options for `node-sass` or `sass` (`Dart Sass`) implementation.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","anyOf":[{"type":"object","additionalProperties":true},{"instanceof":"Function"}]},"additionalData":{"description":"Prepends/Appends `Sass`/`SCSS` code before the actual entry file.","link":"https://github.com/webpack-contrib/sass-loader#additionaldata","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/sass-loader#sourcemap","type":"boolean"},"webpackImporter":{"description":"Enables/Disables default `webpack` importer.","link":"https://github.com/webpack-contrib/sass-loader#webpackimporter","type":"boolean"},"warnRuleAsWarning":{"description":"Treats the \'@warn\' rule as a webpack warning.","link":"https://github.com/webpack-contrib/sass-loader#warnruleaswarning","type":"boolean"}},"additionalProperties":false}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(591);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/packages/next/src/compiled/sass-loader-16/package.json b/packages/next/src/compiled/sass-loader-16/package.json deleted file mode 100644 index 91526a6dccf9b..0000000000000 --- a/packages/next/src/compiled/sass-loader-16/package.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"sass-loader","main":"cjs.js","author":"J. Tangelder","license":"MIT"} From 38a5252bfab3424a7d769e101eda6afc37cb905a Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 03:46:58 +0900 Subject: [PATCH 09/19] ncc-compiled sass-loader to 16 --- packages/next/src/compiled/sass-loader/cjs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/compiled/sass-loader/cjs.js b/packages/next/src/compiled/sass-loader/cjs.js index bb8534eecba35..bbbc5c01d76f7 100644 --- a/packages/next/src/compiled/sass-loader/cjs.js +++ b/packages/next/src/compiled/sass-loader/cjs.js @@ -1 +1 @@ -(function(){"use strict";var __webpack_modules__={966:function(e,t,s){const n=s(248);e.exports=n.default},248:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(s(310));var o=_interopRequireDefault(s(17));var r=_interopRequireDefault(s(713));var a=s(816);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}async function loader(e){const t=this.getOptions(r.default);const s=this.async();let i;try{i=(0,a.getSassImplementation)(this,t.implementation)}catch(e){s(e);return}const c=typeof t.sourceMap==="boolean"?t.sourceMap:this.sourceMap;const l=await(0,a.getSassOptions)(this,t,e,i,c);const p=typeof t.webpackImporter==="boolean"?t.webpackImporter:true;if(p){const e=t.api==="modern"||t.api==="modern-compiler";if(!e){const{includePaths:e}=l;l.importer.push((0,a.getWebpackImporter)(this,i,e))}else{l.importers.push((0,a.getModernWebpackImporter)(this,i,[]))}}let u;try{u=(0,a.getCompileFn)(this,i,t)}catch(e){s(e);return}let d;try{d=await u(l)}catch(e){if(e.span&&typeof e.span.url!=="undefined"){this.addDependency(n.default.fileURLToPath(e.span.url))}else if(typeof e.file!=="undefined"){this.addDependency(o.default.normalize(e.file))}s((0,a.errorFactory)(e));return}let f=d.sourceMap?d.sourceMap:d.map?JSON.parse(d.map):null;if(f&&c){f=(0,a.normalizeSourceMap)(f,this.rootContext)}if(typeof d.loadedUrls!=="undefined"){d.loadedUrls.filter((e=>e.protocol==="file:")).forEach((e=>{const t=n.default.fileURLToPath(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}else if(typeof d.stats!=="undefined"&&typeof d.stats.includedFiles!=="undefined"){d.stats.includedFiles.forEach((e=>{const t=o.default.normalize(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}s(null,d.css.toString(),f)}var i=t["default"]=loader},816:function(__unused_webpack_module,exports,__nccwpck_require__){Object.defineProperty(exports,"__esModule",{value:true});exports.errorFactory=errorFactory;exports.getCompileFn=getCompileFn;exports.getModernWebpackImporter=getModernWebpackImporter;exports.getSassImplementation=getSassImplementation;exports.getSassOptions=getSassOptions;exports.getWebpackImporter=getWebpackImporter;exports.getWebpackResolver=getWebpackResolver;exports.normalizeSourceMap=normalizeSourceMap;var _url=_interopRequireDefault(__nccwpck_require__(310));var _path=_interopRequireDefault(__nccwpck_require__(17));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function getDefaultSassImplementation(){let sassImplPkg="sass";try{require.resolve("sass-embedded");sassImplPkg="sass-embedded"}catch(ignoreError){try{eval("require").resolve("sass")}catch(_ignoreError){try{eval("require").resolve("node-sass");sassImplPkg="node-sass"}catch(e){sassImplPkg="sass"}}}return __nccwpck_require__(438)}function getSassImplementation(e,t){let s=t;if(!s){s=getDefaultSassImplementation()}if(typeof s==="string"){s=require(s)}const{info:n}=s;if(!n){throw new Error("Unknown Sass implementation.")}const o=n.split("\t");if(o.length<2){throw new Error(`Unknown Sass implementation "${n}".`)}const[r]=o;if(r==="dart-sass"){return s}else if(r==="node-sass"){return s}else if(r==="sass-embedded"){return s}throw new Error(`Unknown Sass implementation "${r}".`)}function isProductionLikeMode(e){return e.mode==="production"||!e.mode}function proxyCustomImporters(e,t){return[].concat(e).map((e=>function proxyImporter(...s){const n={...this,webpackLoaderContext:t};return e.apply(n,s)}))}async function getSassOptions(e,t,s,n,o){const r=t.sassOptions?typeof t.sassOptions==="function"?t.sassOptions(e)||{}:t.sassOptions:{};const a={...r,data:t.additionalData?typeof t.additionalData==="function"?await t.additionalData(s,e):`${t.additionalData}\n${s}`:s};if(!a.logger){const s=t.warnRuleAsWarning!==false;const n=e.getLogger("sass-loader");const formatSpan=e=>`Warning on line ${e.start.line}, column ${e.start.column} of ${e.url||"-"}:${e.start.line}:${e.start.column}:\n`;const formatDebugSpan=e=>`[debug:${e.start.line}:${e.start.column}] `;a.logger={debug(e,t){let s="";if(t.span){s=formatDebugSpan(t.span)}s+=e;n.debug(s)},warn(t,o){let r="";if(o.deprecation){r+="Deprecation "}if(o.span){r+=formatSpan(o.span)}r+=t;if(o.span&&o.span.context){r+=`\n\n${o.span.start.line} | ${o.span.context}`}if(o.stack&&o.stack!=="null"){r+=`\n\n${o.stack}`}if(s){const t=new Error(r);t.name="SassWarning";t.stack=null;e.emitWarning(t)}else{n.warn(r)}}}}const i=t.api==="modern"||t.api==="modern-compiler";const{resourcePath:c}=e;if(i){a.url=_url.default.pathToFileURL(c);if(!a.style&&isProductionLikeMode(e)){a.style="compressed"}if(o){a.sourceMap=true}if(typeof a.syntax==="undefined"){const e=_path.default.extname(c);if(e&&e.toLowerCase()===".scss"){a.syntax="scss"}else if(e&&e.toLowerCase()===".sass"){a.syntax="indented"}else if(e&&e.toLowerCase()===".css"){a.syntax="css"}}a.loadPaths=[].concat((a.loadPaths?a.loadPaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);a.importers=a.importers?Array.isArray(a.importers)?a.importers.slice():[a.importers]:[]}else{a.file=c;if(!a.outputStyle&&isProductionLikeMode(e)){a.outputStyle="compressed"}if(o){a.sourceMap=true;a.outFile=_path.default.join(e.rootContext,"style.css.map");a.sourceMapContents=true;a.omitSourceMapUrl=true;a.sourceMapEmbed=false}const s=_path.default.extname(c);if(s&&s.toLowerCase()===".sass"&&typeof a.indentedSyntax==="undefined"){a.indentedSyntax=true}else{a.indentedSyntax=Boolean(a.indentedSyntax)}a.importer=a.importer?proxyCustomImporters(Array.isArray(a.importer)?a.importer.slice():[a.importer],e):[];if(t.webpackImporter===false&&a.importer.length===0){a.importer=undefined}a.includePaths=[].concat(process.cwd()).concat((a.includePaths?a.includePaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);if(typeof a.charset==="undefined"){a.charset=true}}return a}const MODULE_REQUEST_REGEX=/^[^?]*~/;const IS_MODULE_IMPORT=/^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;const IS_PKG_SCHEME=/^pkg:/i;function getPossibleRequests(e,t=false,s=false){let n=e;if(t){if(MODULE_REQUEST_REGEX.test(e)){n=n.replace(MODULE_REQUEST_REGEX,"")}if(IS_PKG_SCHEME.test(e)){n=`${n.slice(4)}`;return[...new Set([n,e])]}if(IS_MODULE_IMPORT.test(e)||IS_PKG_SCHEME.test(e)){n=n[n.length-1]==="/"?n:`${n}/`;return[...new Set([n,e])]}}const o=_path.default.extname(n).toLowerCase();if(o===".css"){return[]}const r=_path.default.dirname(n);const a=r==="."?"":`${r}/`;const i=_path.default.basename(n);const c=_path.default.basename(n,o);return[...new Set([].concat(s?[`${a}_${c}.import${o}`,`${a}${c}.import${o}`]:[]).concat([`${a}_${i}`,`${a}${i}`]).concat(t?[e]:[]))]}function promiseResolve(e){return(t,s)=>new Promise(((n,o)=>{e(t,s,((e,t)=>{if(e){o(e)}else{n(t)}}))}))}async function startResolving(e){if(e.length===0){return Promise.reject()}const[{possibleRequests:t}]=e;if(t.length===0){return Promise.reject()}const[{resolve:s,context:n}]=e;try{return await s(n,t[0])}catch(s){const[,...n]=t;if(n.length===0){const[,...t]=e;return startResolving(t)}e[0].possibleRequests=n;return startResolving(e)}}const IS_SPECIAL_MODULE_IMPORT=/^~[^/]+$/;const IS_NATIVE_WIN32_PATH=/^[a-z]:[/\\]|^\\\\/i;function getWebpackResolver(e,t,s=[]){const n=t&&(t.info.includes("dart-sass")||t.info.includes("sass-embedded"));const o=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const r=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index.import","_index","index.import","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const a=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const i=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index.import","_index","index.import","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));return(e,t,c)=>{if(!n&&!_path.default.isAbsolute(e)){return Promise.reject()}const l=t;const p=l.slice(0,5).toLowerCase()==="file:";if(p){try{t=_url.default.fileURLToPath(l)}catch(e){t=t.slice(7)}}let u=[];const d=!IS_SPECIAL_MODULE_IMPORT.test(t)&&!IS_PKG_SCHEME.test(t)&&!p&&!l.startsWith("/")&&!IS_NATIVE_WIN32_PATH.test(l);if(s.length>0&&d){const a=getPossibleRequests(t,false,c);if(!n){u=u.concat({resolve:c?r:o,context:_path.default.dirname(e),possibleRequests:a})}u=u.concat(s.map((e=>({resolve:c?r:o,context:e,possibleRequests:a}))))}const f=getPossibleRequests(t,true,c);u=u.concat({resolve:c?i:a,context:_path.default.dirname(e),possibleRequests:f});return startResolving(u)}}const MATCH_CSS=/\.css$/i;function getModernWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return{async canonicalize(t,s){const{fromImport:o}=s;const r=s.containingUrl?_url.default.fileURLToPath(s.containingUrl.toString()):e.resourcePath;let a;try{a=await n(r,t,o)}catch(e){return null}e.addDependency(_path.default.normalize(a));return _url.default.pathToFileURL(a)},async load(t){const s=_path.default.extname(t.pathname);let n;if(s&&s.toLowerCase()===".scss"){n="scss"}else if(s&&s.toLowerCase()===".sass"){n="indented"}else if(s&&s.toLowerCase()===".css"){n="css"}else{n="scss"}try{const s=await new Promise(((s,n)=>{const o=_url.default.fileURLToPath(t);e.fs.readFile(o,"utf8",((e,t)=>{if(e){n(e);return}s(t)}))}));return{contents:s,syntax:n}}catch(e){return null}}}}function getWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return function importer(t,s,o){const{fromImport:r}=this;n(s,t,r).then((t=>{e.addDependency(_path.default.normalize(t));o({file:t.replace(MATCH_CSS,"")})})).catch((()=>{o({file:t})}))}}let nodeSassJobQueue=null;const sassModernCompilers=new WeakMap;function getCompileFn(e,t,s){const n=t.info.includes("dart-sass")||t.info.includes("sass-embedded");if(n){if(s.api==="modern"){return e=>{const{data:s,...n}=e;return t.compileStringAsync(s,n)}}if(s.api==="modern-compiler"){return async s=>{const n=e._compiler;const{data:o,...r}=s;if(n){if(!sassModernCompilers.has(n)){const e=await t.initAsyncCompiler();if(!sassModernCompilers.has(n)){sassModernCompilers.set(n,e);n.hooks.shutdown.tap("sass-loader",(()=>{e.dispose()}))}}return sassModernCompilers.get(n).compileStringAsync(o,r)}return t.compileStringAsync(o,r)}}return e=>new Promise(((s,n)=>{t.render(e,((e,t)=>{if(e){n(e);return}s(t)}))}))}if(s.api==="modern"||s.api==="modern-compiler"){throw new Error("Modern API is not supported for 'node-sass'")}if(nodeSassJobQueue===null){const e=Number(process.env.UV_THREADPOOL_SIZE||4);const s=__nccwpck_require__(175);nodeSassJobQueue=s.queue(t.render.bind(t),e-1)}return e=>new Promise(((t,s)=>{nodeSassJobQueue.push.bind(nodeSassJobQueue)(e,((e,n)=>{if(e){s(e);return}t(n)}))}))}const ABSOLUTE_SCHEME=/^[A-Za-z0-9+\-.]+:/;function getURLType(e){if(e[0]==="/"){if(e[1]==="/"){return"scheme-relative"}return"path-absolute"}if(IS_NATIVE_WIN32_PATH.test(e)){return"path-absolute"}return ABSOLUTE_SCHEME.test(e)?"absolute":"path-relative"}function normalizeSourceMap(e,t){const s=e;if(typeof s.file!=="undefined"){delete s.file}s.sourceRoot="";s.sources=s.sources.map((e=>{const s=getURLType(e);if(s==="absolute"&&/^file:/i.test(e)){return _url.default.fileURLToPath(e)}else if(s==="path-relative"){return _path.default.resolve(t,_path.default.normalize(e))}return e}));return s}function errorFactory(e){let t;if(e.formatted){t=e.formatted.replace(/^Error: /,"")}else{({message:t}=e)}const s=new Error(t,{cause:e});s.stack=null;return s}},175:function(e){e.exports=require("next/dist/compiled/neo-async")},17:function(e){e.exports=require("path")},438:function(e){e.exports=require("sass")},310:function(e){e.exports=require("url")},713:function(e){e.exports=JSON.parse('{"title":"Sass Loader options","type":"object","properties":{"implementation":{"description":"The implementation of the sass to be used.","link":"https://github.com/webpack-contrib/sass-loader#implementation","anyOf":[{"type":"string"},{"type":"object"}]},"api":{"description":"Switch between old and modern API for `sass` (`Dart Sass`) and `Sass Embedded` implementations.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","enum":["legacy","modern","modern-compiler"]},"sassOptions":{"description":"Options for `node-sass` or `sass` (`Dart Sass`) implementation.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","anyOf":[{"type":"object","additionalProperties":true},{"instanceof":"Function"}]},"additionalData":{"description":"Prepends/Appends `Sass`/`SCSS` code before the actual entry file.","link":"https://github.com/webpack-contrib/sass-loader#additionaldata","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/sass-loader#sourcemap","type":"boolean"},"webpackImporter":{"description":"Enables/Disables default `webpack` importer.","link":"https://github.com/webpack-contrib/sass-loader#webpackimporter","type":"boolean"},"warnRuleAsWarning":{"description":"Treats the \'@warn\' rule as a webpack warning.","link":"https://github.com/webpack-contrib/sass-loader#warnruleaswarning","type":"boolean"}},"additionalProperties":false}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(966);module.exports=__webpack_exports__})(); \ No newline at end of file +(function(){"use strict";var __webpack_modules__={555:function(e,t,s){const n=s(769);e.exports=n.default},769:function(e,t,s){Object.defineProperty(t,"__esModule",{value:true});t["default"]=void 0;var n=_interopRequireDefault(s(310));var o=_interopRequireDefault(s(17));var r=_interopRequireDefault(s(569));var a=s(135);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}async function loader(e){const t=this.getOptions(r.default);const s=this.async();let i;try{i=(0,a.getSassImplementation)(this,t.implementation)}catch(e){s(e);return}const c=typeof t.sourceMap==="boolean"?t.sourceMap:this.sourceMap;const l=typeof i.compileStringAsync==="undefined"?"legacy":typeof t.api==="undefined"?"modern":t.api;const p=await(0,a.getSassOptions)(this,t,e,i,c,l);const u=typeof t.webpackImporter==="boolean"?t.webpackImporter:true;if(u){const e=l==="modern"||l==="modern-compiler";if(!e){const{includePaths:e}=p;p.importer.push((0,a.getWebpackImporter)(this,i,e))}else{p.importers.push((0,a.getModernWebpackImporter)(this,i,[]))}}let d;try{d=(0,a.getCompileFn)(this,i,l)}catch(e){s(e);return}let f;try{f=await d(p)}catch(e){if(e.span&&typeof e.span.url!=="undefined"){this.addDependency(n.default.fileURLToPath(e.span.url))}else if(typeof e.file!=="undefined"){this.addDependency(o.default.normalize(e.file))}s((0,a.errorFactory)(e));return}let m=f.sourceMap?f.sourceMap:f.map?JSON.parse(f.map):null;if(m&&c){m=(0,a.normalizeSourceMap)(m,this.rootContext)}if(typeof f.loadedUrls!=="undefined"){f.loadedUrls.filter((e=>e.protocol==="file:")).forEach((e=>{const t=n.default.fileURLToPath(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}else if(typeof f.stats!=="undefined"&&typeof f.stats.includedFiles!=="undefined"){f.stats.includedFiles.forEach((e=>{const t=o.default.normalize(e);if(o.default.isAbsolute(t)){this.addDependency(t)}}))}s(null,f.css.toString(),m)}var i=t["default"]=loader},135:function(__unused_webpack_module,exports,__nccwpck_require__){Object.defineProperty(exports,"__esModule",{value:true});exports.errorFactory=errorFactory;exports.getCompileFn=getCompileFn;exports.getModernWebpackImporter=getModernWebpackImporter;exports.getSassImplementation=getSassImplementation;exports.getSassOptions=getSassOptions;exports.getWebpackImporter=getWebpackImporter;exports.getWebpackResolver=getWebpackResolver;exports.normalizeSourceMap=normalizeSourceMap;var _url=_interopRequireDefault(__nccwpck_require__(310));var _path=_interopRequireDefault(__nccwpck_require__(17));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function getDefaultSassImplementation(){let sassImplPkg="sass";try{require.resolve("sass-embedded");sassImplPkg="sass-embedded"}catch(ignoreError){try{eval("require").resolve("sass")}catch(_ignoreError){try{eval("require").resolve("node-sass");sassImplPkg="node-sass"}catch(e){sassImplPkg="sass"}}}return __nccwpck_require__(438)}function getSassImplementation(e,t){let s=t;if(!s){s=getDefaultSassImplementation()}if(typeof s==="string"){s=require(s)}const{info:n}=s;if(!n){throw new Error("Unknown Sass implementation.")}const o=n.split("\t");if(o.length<2){throw new Error(`Unknown Sass implementation "${n}".`)}const[r]=o;if(r==="dart-sass"){return s}else if(r==="node-sass"){return s}else if(r==="sass-embedded"){return s}throw new Error(`Unknown Sass implementation "${r}".`)}function isProductionLikeMode(e){return e.mode==="production"||!e.mode}function proxyCustomImporters(e,t){return[].concat(e).map((e=>function proxyImporter(...s){const n={...this,webpackLoaderContext:t};return e.apply(n,s)}))}async function getSassOptions(e,t,s,n,o,r){const a=t.sassOptions?typeof t.sassOptions==="function"?t.sassOptions(e)||{}:t.sassOptions:{};const i={...a,data:t.additionalData?typeof t.additionalData==="function"?await t.additionalData(s,e):`${t.additionalData}\n${s}`:s};if(!i.logger){const s=t.warnRuleAsWarning!==false;const n=e.getLogger("sass-loader");const formatSpan=e=>`Warning on line ${e.start.line}, column ${e.start.column} of ${e.url||"-"}:${e.start.line}:${e.start.column}:\n`;const formatDebugSpan=e=>`[debug:${e.start.line}:${e.start.column}] `;i.logger={debug(e,t){let s="";if(t.span){s=formatDebugSpan(t.span)}s+=e;n.debug(s)},warn(t,o){let r="";if(o.deprecation){r+="Deprecation "}if(o.span){r+=formatSpan(o.span)}r+=t;if(o.span&&o.span.context){r+=`\n\n${o.span.start.line} | ${o.span.context}`}if(o.stack&&o.stack!=="null"){r+=`\n\n${o.stack}`}if(s){const t=new Error(r);t.name="SassWarning";t.stack=null;e.emitWarning(t)}else{n.warn(r)}}}}const c=r==="modern"||r==="modern-compiler";const{resourcePath:l}=e;if(c){i.url=_url.default.pathToFileURL(l);if(!i.style&&isProductionLikeMode(e)){i.style="compressed"}if(o){i.sourceMap=true}if(typeof i.syntax==="undefined"){const e=_path.default.extname(l);if(e&&e.toLowerCase()===".scss"){i.syntax="scss"}else if(e&&e.toLowerCase()===".sass"){i.syntax="indented"}else if(e&&e.toLowerCase()===".css"){i.syntax="css"}}i.loadPaths=[].concat((i.loadPaths?i.loadPaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);i.importers=i.importers?Array.isArray(i.importers)?i.importers.slice():[i.importers]:[]}else{i.file=l;if(!i.outputStyle&&isProductionLikeMode(e)){i.outputStyle="compressed"}if(o){i.sourceMap=true;i.outFile=_path.default.join(e.rootContext,"style.css.map");i.sourceMapContents=true;i.omitSourceMapUrl=true;i.sourceMapEmbed=false}const s=_path.default.extname(l);if(s&&s.toLowerCase()===".sass"&&typeof i.indentedSyntax==="undefined"){i.indentedSyntax=true}else{i.indentedSyntax=Boolean(i.indentedSyntax)}i.importer=i.importer?proxyCustomImporters(Array.isArray(i.importer)?i.importer.slice():[i.importer],e):[];if(t.webpackImporter===false&&i.importer.length===0){i.importer=undefined}i.includePaths=[].concat(process.cwd()).concat((i.includePaths?i.includePaths.slice():[]).map((e=>_path.default.isAbsolute(e)?e:_path.default.join(process.cwd(),e)))).concat(process.env.SASS_PATH?process.env.SASS_PATH.split(process.platform==="win32"?";":":"):[]);if(typeof i.charset==="undefined"){i.charset=true}}return i}const MODULE_REQUEST_REGEX=/^[^?]*~/;const IS_MODULE_IMPORT=/^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;const IS_PKG_SCHEME=/^pkg:/i;function getPossibleRequests(e,t=false,s=false){let n=e;if(t){if(MODULE_REQUEST_REGEX.test(e)){n=n.replace(MODULE_REQUEST_REGEX,"")}if(IS_PKG_SCHEME.test(e)){n=`${n.slice(4)}`;return[...new Set([n,e])]}if(IS_MODULE_IMPORT.test(e)||IS_PKG_SCHEME.test(e)){n=n[n.length-1]==="/"?n:`${n}/`;return[...new Set([n,e])]}}const o=_path.default.extname(n).toLowerCase();if(o===".css"){return[]}const r=_path.default.dirname(n);const a=r==="."?"":`${r}/`;const i=_path.default.basename(n);const c=_path.default.basename(n,o);return[...new Set([].concat(s?[`${a}_${c}.import${o}`,`${a}${c}.import${o}`]:[]).concat([`${a}_${i}`,`${a}${i}`]).concat(t?[e]:[]))]}function promiseResolve(e){return(t,s)=>new Promise(((n,o)=>{e(t,s,((e,t)=>{if(e){o(e)}else{n(t)}}))}))}async function startResolving(e){if(e.length===0){return Promise.reject()}const[{possibleRequests:t}]=e;if(t.length===0){return Promise.reject()}const[{resolve:s,context:n}]=e;try{return await s(n,t[0])}catch(s){const[,...n]=t;if(n.length===0){const[,...t]=e;return startResolving(t)}e[0].possibleRequests=n;return startResolving(e)}}const IS_SPECIAL_MODULE_IMPORT=/^~[^/]+$/;const IS_NATIVE_WIN32_PATH=/^[a-z]:[/\\]|^\\\\/i;function getWebpackResolver(e,t,s=[]){const n=t&&typeof t.compileStringAsync!=="undefined";const o=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const r=promiseResolve(e({alias:[],aliasFields:[],conditionNames:[],descriptionFiles:[],extensions:[".sass",".scss",".css"],exportsFields:[],mainFields:[],mainFiles:["_index.import","_index","index.import","index"],modules:[],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const a=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));const i=promiseResolve(e({dependencyType:"sass",conditionNames:["sass","style","..."],mainFields:["sass","style","main","..."],mainFiles:["_index.import","_index","index.import","index","..."],extensions:[".sass",".scss",".css"],restrictions:[/\.((sa|sc|c)ss)$/i],preferRelative:true}));return(e,t,c)=>{if(!n&&!_path.default.isAbsolute(e)){return Promise.reject()}const l=t;const p=l.slice(0,5).toLowerCase()==="file:";if(p){try{t=_url.default.fileURLToPath(l)}catch(e){t=t.slice(7)}}let u=[];const d=!IS_SPECIAL_MODULE_IMPORT.test(t)&&!IS_PKG_SCHEME.test(t)&&!p&&!l.startsWith("/")&&!IS_NATIVE_WIN32_PATH.test(l);if(s.length>0&&d){const a=getPossibleRequests(t,false,c);if(!n){u=u.concat({resolve:c?r:o,context:_path.default.dirname(e),possibleRequests:a})}u=u.concat(s.map((e=>({resolve:c?r:o,context:e,possibleRequests:a}))))}const f=getPossibleRequests(t,true,c);u=u.concat({resolve:c?i:a,context:_path.default.dirname(e),possibleRequests:f});return startResolving(u)}}const MATCH_CSS=/\.css$/i;function getModernWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return{async canonicalize(t,s){const{fromImport:o}=s;const r=s.containingUrl?_url.default.fileURLToPath(s.containingUrl.toString()):e.resourcePath;let a;try{a=await n(r,t,o)}catch(e){return null}e.addDependency(_path.default.normalize(a));return _url.default.pathToFileURL(a)},async load(t){const s=_path.default.extname(t.pathname);let n;if(s&&s.toLowerCase()===".scss"){n="scss"}else if(s&&s.toLowerCase()===".sass"){n="indented"}else if(s&&s.toLowerCase()===".css"){n="css"}else{n="scss"}try{const s=await new Promise(((s,n)=>{const o=_url.default.fileURLToPath(t);e.fs.readFile(o,"utf8",((e,t)=>{if(e){n(e);return}s(t)}))}));return{contents:s,syntax:n}}catch(e){return null}}}}function getWebpackImporter(e,t,s){const n=getWebpackResolver(e.getResolve,t,s);return function importer(t,s,o){const{fromImport:r}=this;n(s,t,r).then((t=>{e.addDependency(_path.default.normalize(t));o({file:t.replace(MATCH_CSS,"")})})).catch((()=>{o({file:t})}))}}let nodeSassJobQueue=null;const sassModernCompilers=new WeakMap;function getCompileFn(e,t,s){if(typeof t.compileStringAsync!=="undefined"){if(s==="modern"){return e=>{const{data:s,...n}=e;return t.compileStringAsync(s,n)}}if(s==="modern-compiler"){return async s=>{const n=e._compiler;const{data:o,...r}=s;if(n){if(!sassModernCompilers.has(n)){const e=await t.initAsyncCompiler();if(!sassModernCompilers.has(n)){sassModernCompilers.set(n,e);n.hooks.shutdown.tap("sass-loader",(()=>{e.dispose()}))}}return sassModernCompilers.get(n).compileStringAsync(o,r)}return t.compileStringAsync(o,r)}}return e=>new Promise(((s,n)=>{t.render(e,((e,t)=>{if(e){n(e);return}s(t)}))}))}if(s==="modern"||s==="modern-compiler"){throw new Error("Modern API is not supported for 'node-sass'")}if(nodeSassJobQueue===null){const e=Number(process.env.UV_THREADPOOL_SIZE||4);const s=__nccwpck_require__(175);nodeSassJobQueue=s.queue(t.render.bind(t),e-1)}return e=>new Promise(((t,s)=>{nodeSassJobQueue.push.bind(nodeSassJobQueue)(e,((e,n)=>{if(e){s(e);return}t(n)}))}))}const ABSOLUTE_SCHEME=/^[A-Za-z0-9+\-.]+:/;function getURLType(e){if(e[0]==="/"){if(e[1]==="/"){return"scheme-relative"}return"path-absolute"}if(IS_NATIVE_WIN32_PATH.test(e)){return"path-absolute"}return ABSOLUTE_SCHEME.test(e)?"absolute":"path-relative"}function normalizeSourceMap(e,t){const s=e;if(typeof s.file!=="undefined"){delete s.file}s.sourceRoot="";s.sources=s.sources.map((e=>{const s=getURLType(e);if(s==="absolute"&&/^file:/i.test(e)){return _url.default.fileURLToPath(e)}else if(s==="path-relative"){return _path.default.resolve(t,_path.default.normalize(e))}return e}));return s}function errorFactory(e){let t;if(e.formatted){t=e.formatted.replace(/^Error: /,"")}else{({message:t}=e)}const s=new Error(t,{cause:e});s.stack=null;return s}},175:function(e){e.exports=require("next/dist/compiled/neo-async")},17:function(e){e.exports=require("path")},438:function(e){e.exports=require("sass")},310:function(e){e.exports=require("url")},569:function(e){e.exports=JSON.parse('{"title":"Sass Loader options","type":"object","properties":{"implementation":{"description":"The implementation of the sass to be used.","link":"https://github.com/webpack-contrib/sass-loader#implementation","anyOf":[{"type":"string"},{"type":"object"}]},"api":{"description":"Switch between old and modern API for `sass` (`Dart Sass`) and `Sass Embedded` implementations.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","enum":["legacy","modern","modern-compiler"]},"sassOptions":{"description":"Options for `node-sass` or `sass` (`Dart Sass`) implementation.","link":"https://github.com/webpack-contrib/sass-loader#sassoptions","anyOf":[{"type":"object","additionalProperties":true},{"instanceof":"Function"}]},"additionalData":{"description":"Prepends/Appends `Sass`/`SCSS` code before the actual entry file.","link":"https://github.com/webpack-contrib/sass-loader#additionaldata","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"sourceMap":{"description":"Enables/Disables generation of source maps.","link":"https://github.com/webpack-contrib/sass-loader#sourcemap","type":"boolean"},"webpackImporter":{"description":"Enables/Disables default `webpack` importer.","link":"https://github.com/webpack-contrib/sass-loader#webpackimporter","type":"boolean"},"warnRuleAsWarning":{"description":"Treats the \'@warn\' rule as a webpack warning.","link":"https://github.com/webpack-contrib/sass-loader#warnruleaswarning","type":"boolean"}},"additionalProperties":false}')}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var s=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e](s,s.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(555);module.exports=__webpack_exports__})(); \ No newline at end of file From 907cecdee8fcb396ca343236fd8a24ccb32aa19e Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 03:47:42 +0900 Subject: [PATCH 10/19] webpack impl --- .../build/webpack/config/blocks/css/index.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/next/src/build/webpack/config/blocks/css/index.ts b/packages/next/src/build/webpack/config/blocks/css/index.ts index f694d10dbb91a..bb6a3cec10ec9 100644 --- a/packages/next/src/build/webpack/config/blocks/css/index.ts +++ b/packages/next/src/build/webpack/config/blocks/css/index.ts @@ -1,5 +1,6 @@ import curry from 'next/dist/compiled/lodash.curry' import type { webpack } from 'next/dist/compiled/webpack/webpack' +import { lt as semverLessThan } from 'next/dist/compiled/semver' import { loader, plugin } from '../../helpers' import { pipe } from '../../utils' import type { ConfigurationContext, ConfigurationFn } from '../../utils' @@ -151,7 +152,6 @@ export const css = curry(async function css( prependData: sassPrependData, additionalData: sassAdditionalData, implementation: sassImplementation, - experimental: { useUpgradedLoader: sassUseUpgradedLoader } = {}, ...sassOptions } = ctx.sassOptions @@ -163,15 +163,23 @@ export const css = curry(async function css( ctx.experimental.useLightningcss ) + // Since sass is an optional peer dependency, it may be missing. + let sassVersion = '' + try { + sassVersion = require.resolve('sass') + } catch {} + + // The modern Sass API with breaking changes was added in sass@1.45.0. + // https://sass-lang.com/documentation/breaking-changes/legacy-js-api + // Since sass-loader and our peer dependency sass version is ^1.3.0, + // we need to use the legacy Sass API for versions less than 1.45.0. + const shouldUseLegacySassAPI = semverLessThan(sassVersion, '1.45.0') + const sassPreprocessors: webpack.RuleSetUseItem[] = [ // First, process files with `sass-loader`: this inlines content, and // compiles away the proprietary syntax. { - loader: require.resolve( - sassUseUpgradedLoader - ? 'next/dist/compiled/sass-loader-16' - : 'next/dist/compiled/sass-loader' - ), + loader: require.resolve('next/dist/compiled/sass-loader'), options: { implementation: sassImplementation, // Source maps are required so that `resolve-url-loader` can locate @@ -186,8 +194,8 @@ export const css = curry(async function css( // Since it's optional and not required, we'll disable it by default // to avoid the confusion. fibers: false, - // TODO: Remove this once we upgrade to sass-loader 16 - silenceDeprecations: ['legacy-js-api'], + // TODO(jiwon): Once the peer dependency for sass is upgraded to >= 1.45.0, we can remove this. + api: shouldUseLegacySassAPI ? 'legacy' : 'modern', ...sassOptions, }, additionalData: sassPrependData || sassAdditionalData, From b6a1944170ccf7ddbfda2007e50a78b47ce03226 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 04:44:18 +0900 Subject: [PATCH 11/19] cargo add semver --- Cargo.lock | 1 + crates/next-core/Cargo.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 287f07ea90ded..72c428ea0d9c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4025,6 +4025,7 @@ dependencies = [ "regex", "remove_console", "rustc-hash 1.1.0", + "semver 1.0.23", "serde", "serde_json", "swc_core", diff --git a/crates/next-core/Cargo.toml b/crates/next-core/Cargo.toml index f5bce8214cf26..29a226dd6cf0b 100644 --- a/crates/next-core/Cargo.toml +++ b/crates/next-core/Cargo.toml @@ -76,6 +76,7 @@ turbopack-nodejs = { workspace = true } turbopack-static = { workspace = true } turbopack-trace-server = { workspace = true } turbopack-trace-utils = { workspace = true } +semver.workspace = true [build-dependencies] turbo-tasks-build = { workspace = true } From 7a910d6f4fe4bac38c1bb7386f1f8214c6c15544 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 04:44:31 +0900 Subject: [PATCH 12/19] [no ci] wip --- .../src/next_shared/webpack_rules/sass.rs | 25 ++++++++++++++++--- .../use-upgraded-loader/basic-module.test.ts | 23 +++++------------ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/crates/next-core/src/next_shared/webpack_rules/sass.rs b/crates/next-core/src/next_shared/webpack_rules/sass.rs index 296142d0f49ba..735433bdc77fa 100644 --- a/crates/next-core/src/next_shared/webpack_rules/sass.rs +++ b/crates/next-core/src/next_shared/webpack_rules/sass.rs @@ -1,9 +1,14 @@ use std::mem::take; use anyhow::{bail, Result}; +use semver::Version; use serde_json::Value as JsonValue; use turbo_tasks::{ResolvedVc, Vc}; use turbopack::module_options::{LoaderRuleItem, OptionWebpackRules, WebpackRules}; +use turbopack_core::{ + reference_type::ReferenceType, + resolve::{node::node_cjs_resolve_options, parse::Request::Module, resolve}, +}; use turbopack_node::transforms::webpack::WebpackLoaderItem; #[turbo_tasks::function] @@ -15,10 +20,24 @@ pub async fn maybe_add_sass_loader( let Some(mut sass_options) = sass_options.as_object().cloned() else { bail!("sass_options must be an object"); }; - // TODO: Remove this once we upgrade to sass-loader 16 + + // Since sass is an optional peer dependency, it may be missing. + let sass_version = + Version::parse(&resolve_from::resolve_from(".", "sass").unwrap_or_default())?; + // The modern Sass API with breaking changes was added in sass@1.45.0. + // https://sass-lang.com/documentation/breaking-changes/legacy-js-api + // Since sass-loader and our peer dependency sass version is ^1.3.0, + // we need to use the legacy Sass API for versions less than 1.45.0. + let should_use_legacy_sass_api = sass_version < Version::parse("1.45.0")?; + + // TODO(jiwon): Once the peer dependency for sass is upgraded to >= 1.45.0, we can remove this. sass_options.insert( - "silenceDeprecations".into(), - serde_json::json!(["legacy-js-api"]), + "api".into(), + serde_json::json!(if should_use_legacy_sass_api { + "legacy" + } else { + "modern" + }), ); let mut rules = if let Some(webpack_rules) = webpack_rules { webpack_rules.await?.clone_value() diff --git a/test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts b/test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts index 1c7774cb4beaf..5914d91c2caf3 100644 --- a/test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts +++ b/test/e2e/app-dir/scss/use-upgraded-loader/basic-module.test.ts @@ -4,8 +4,7 @@ import { colorToRgb } from 'next-test-utils' describe('Legacy sass-loader', () => { const { next: nextWithLegacyLoader } = nextTestSetup({ files: __dirname, - dependencies: { sass: '1.54.0' }, - nextConfig: undefined, + dependencies: { sass: '1.80.7' }, }) it('should render the module for the legacy sass-loader', async () => { @@ -14,21 +13,17 @@ describe('Legacy sass-loader', () => { await browser.elementByCss('#verify-red').getComputedCss('color') ).toBe(colorToRgb('red')) }) - - it('should show deprecation warning', async () => { - expect(nextWithLegacyLoader.cliOutput).toContain( - 'Deprecation: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0' - ) - }) }) describe('Upgraded sass-loader', () => { const { next: nextWithUpgradedLoader } = nextTestSetup({ files: __dirname, - dependencies: { sass: '1.54.0' }, + dependencies: { sass: '1.80.7' }, nextConfig: { - experimental: { - useUpgradedLoader: true, + sassOptions: { + experimental: { + useUpgradedLoader: true, + }, }, }, }) @@ -39,10 +34,4 @@ describe('Upgraded sass-loader', () => { await browser.elementByCss('#verify-red').getComputedCss('color') ).toBe(colorToRgb('red')) }) - - it('should not show deprecation warning', async () => { - expect(nextWithUpgradedLoader.cliOutput).not.toContain( - 'Deprecation: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0' - ) - }) }) From 55b8db5c89ed96b96aac0c6cae623709bd2a2c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Fri, 15 Nov 2024 19:46:47 +0900 Subject: [PATCH 13/19] sass_version: Version --- .../src/next_shared/webpack_rules/sass.rs | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/crates/next-core/src/next_shared/webpack_rules/sass.rs b/crates/next-core/src/next_shared/webpack_rules/sass.rs index 735433bdc77fa..980803ce2ef83 100644 --- a/crates/next-core/src/next_shared/webpack_rules/sass.rs +++ b/crates/next-core/src/next_shared/webpack_rules/sass.rs @@ -1,13 +1,19 @@ -use std::mem::take; +use std::{io::Read, mem::take}; use anyhow::{bail, Result}; use semver::Version; use serde_json::Value as JsonValue; use turbo_tasks::{ResolvedVc, Vc}; +use turbo_tasks_fs::{FileContent, FileSystemPath}; use turbopack::module_options::{LoaderRuleItem, OptionWebpackRules, WebpackRules}; use turbopack_core::{ + asset::{Asset, AssetContent}, + package_json::read_package_json, reference_type::ReferenceType, - resolve::{node::node_cjs_resolve_options, parse::Request::Module, resolve}, + resolve::{ + node::node_cjs_resolve_options, parse::Request::Module, pattern::Pattern, resolve, + resolve_raw, + }, }; use turbopack_node::transforms::webpack::WebpackLoaderItem; @@ -15,6 +21,7 @@ use turbopack_node::transforms::webpack::WebpackLoaderItem; pub async fn maybe_add_sass_loader( sass_options: Vc, webpack_rules: Option>, + package_dir: Vc, ) -> Result> { let sass_options = sass_options.await?; let Some(mut sass_options) = sass_options.as_object().cloned() else { @@ -22,8 +29,48 @@ pub async fn maybe_add_sass_loader( }; // Since sass is an optional peer dependency, it may be missing. - let sass_version = - Version::parse(&resolve_from::resolve_from(".", "sass").unwrap_or_default())?; + let sass_package_json_path = resolve_raw( + package_dir, + { + // Vc + { + // Pattern + Pattern::Constant("sass/pacakge.json".into()) + } + .cell() + }, + false, + ) + .first_source() + .await?; + + let sass_version = match &*sass_package_json_path { + Some(sass_package_json) => { + let json_content = sass_package_json.content().await?; + match &*json_content { + AssetContent::File(file_content) => match &*file_content.await? { + FileContent::Content(file) => { + let mut reader = file.read(); + let mut buf = Vec::new(); + reader.read_to_end(&mut buf)?; + let pkg_json = serde_json::from_slice::(&buf)?; + pkg_json + .get("version") + .unwrap() + .as_str() + .map(Version::parse) + } + _ => None, + }, + _ => None, + } + } + None => None, + } + .transpose()?; + + let sass_version = sass_version.unwrap_or_else(|| Version::new(1, 0, 0)); + // The modern Sass API with breaking changes was added in sass@1.45.0. // https://sass-lang.com/documentation/breaking-changes/legacy-js-api // Since sass-loader and our peer dependency sass version is ^1.3.0, From af40e046c754aaa8fda7796a150c452e49a2cf7d Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 20:24:07 +0900 Subject: [PATCH 14/19] fix: webpack require package json for version --- packages/next/src/build/webpack/config/blocks/css/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/src/build/webpack/config/blocks/css/index.ts b/packages/next/src/build/webpack/config/blocks/css/index.ts index bb6a3cec10ec9..fe7fa42f9f4d3 100644 --- a/packages/next/src/build/webpack/config/blocks/css/index.ts +++ b/packages/next/src/build/webpack/config/blocks/css/index.ts @@ -166,7 +166,7 @@ export const css = curry(async function css( // Since sass is an optional peer dependency, it may be missing. let sassVersion = '' try { - sassVersion = require.resolve('sass') + sassVersion = require(require.resolve('sass/package.json')).version } catch {} // The modern Sass API with breaking changes was added in sass@1.45.0. From 00e1ab9a55f9d1389b7304af63dcd6329446b35e Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 20:30:36 +0900 Subject: [PATCH 15/19] install crates --- Cargo.lock | 1 + crates/next-core/Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 72c428ea0d9c1..1afdabb1b880f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4049,6 +4049,7 @@ dependencies = [ "turbopack-image", "turbopack-node", "turbopack-nodejs", + "turbopack-resolve", "turbopack-static", "turbopack-trace-server", "turbopack-trace-utils", diff --git a/crates/next-core/Cargo.toml b/crates/next-core/Cargo.toml index 29a226dd6cf0b..137cf71196aca 100644 --- a/crates/next-core/Cargo.toml +++ b/crates/next-core/Cargo.toml @@ -33,6 +33,7 @@ tracing = { workspace = true } rustc-hash = { workspace = true } react_remove_properties = "0.24.25" remove_console = "0.25.25" +semver = { workspace = true } auto-hash-map = { workspace = true } @@ -76,7 +77,7 @@ turbopack-nodejs = { workspace = true } turbopack-static = { workspace = true } turbopack-trace-server = { workspace = true } turbopack-trace-utils = { workspace = true } -semver.workspace = true +turbopack-resolve = { workspace = true } [build-dependencies] turbo-tasks-build = { workspace = true } From 317edbf43994638e530a542f25f070f5003892e1 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 20:30:46 +0900 Subject: [PATCH 16/19] fix unused imports --- .../src/next_shared/webpack_rules/sass.rs | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/crates/next-core/src/next_shared/webpack_rules/sass.rs b/crates/next-core/src/next_shared/webpack_rules/sass.rs index 980803ce2ef83..b5961ec1dcb90 100644 --- a/crates/next-core/src/next_shared/webpack_rules/sass.rs +++ b/crates/next-core/src/next_shared/webpack_rules/sass.rs @@ -8,12 +8,7 @@ use turbo_tasks_fs::{FileContent, FileSystemPath}; use turbopack::module_options::{LoaderRuleItem, OptionWebpackRules, WebpackRules}; use turbopack_core::{ asset::{Asset, AssetContent}, - package_json::read_package_json, - reference_type::ReferenceType, - resolve::{ - node::node_cjs_resolve_options, parse::Request::Module, pattern::Pattern, resolve, - resolve_raw, - }, + resolve::{pattern::Pattern, resolve_raw}, }; use turbopack_node::transforms::webpack::WebpackLoaderItem; @@ -28,17 +23,9 @@ pub async fn maybe_add_sass_loader( bail!("sass_options must be an object"); }; - // Since sass is an optional peer dependency, it may be missing. let sass_package_json_path = resolve_raw( package_dir, - { - // Vc - { - // Pattern - Pattern::Constant("sass/pacakge.json".into()) - } - .cell() - }, + Pattern::Constant("sass/package.json".into()).cell(), false, ) .first_source() @@ -46,15 +33,15 @@ pub async fn maybe_add_sass_loader( let sass_version = match &*sass_package_json_path { Some(sass_package_json) => { - let json_content = sass_package_json.content().await?; - match &*json_content { + let sass_package_json_content = sass_package_json.content().await?; + match &*sass_package_json_content { AssetContent::File(file_content) => match &*file_content.await? { FileContent::Content(file) => { let mut reader = file.read(); let mut buf = Vec::new(); reader.read_to_end(&mut buf)?; - let pkg_json = serde_json::from_slice::(&buf)?; - pkg_json + let json_value = serde_json::from_slice::(&buf)?; + json_value .get("version") .unwrap() .as_str() @@ -67,9 +54,8 @@ pub async fn maybe_add_sass_loader( } None => None, } - .transpose()?; - - let sass_version = sass_version.unwrap_or_else(|| Version::new(1, 0, 0)); + .transpose()? + .unwrap_or_else(|| Version::new(1, 45, 0)); // The modern Sass API with breaking changes was added in sass@1.45.0. // https://sass-lang.com/documentation/breaking-changes/legacy-js-api From d5e75c0e336d6fa86568f199768a1ec85fc46dad Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 20:34:04 +0900 Subject: [PATCH 17/19] fix: pass missing param --- crates/next-core/src/next_shared/webpack_rules/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/next-core/src/next_shared/webpack_rules/mod.rs b/crates/next-core/src/next_shared/webpack_rules/mod.rs index eda92a6e58a52..ac9ad4e27e026 100644 --- a/crates/next-core/src/next_shared/webpack_rules/mod.rs +++ b/crates/next-core/src/next_shared/webpack_rules/mod.rs @@ -17,7 +17,7 @@ pub async fn webpack_loader_options( conditions: Vec, ) -> Result>> { let rules = *next_config.webpack_rules(conditions).await?; - let rules = *maybe_add_sass_loader(next_config.sass_config(), rules.map(|v| *v)).await?; + let rules = *maybe_add_sass_loader(next_config.sass_config(), rules.map(|v| *v), project_path).await?; let rules = if foreign { rules } else { From 2baa38f75a6f9ade2456ca4f5183bb50eb9b9abe Mon Sep 17 00:00:00 2001 From: Jiwon Choi Date: Fri, 15 Nov 2024 22:25:16 +0900 Subject: [PATCH 18/19] Update packages/next/src/build/webpack/config/blocks/css/index.ts --- packages/next/src/build/webpack/config/blocks/css/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/next/src/build/webpack/config/blocks/css/index.ts b/packages/next/src/build/webpack/config/blocks/css/index.ts index fe7fa42f9f4d3..c25a3a68f29f8 100644 --- a/packages/next/src/build/webpack/config/blocks/css/index.ts +++ b/packages/next/src/build/webpack/config/blocks/css/index.ts @@ -164,7 +164,8 @@ export const css = curry(async function css( ) // Since sass is an optional peer dependency, it may be missing. - let sassVersion = '' + // enable modern API by default + let sassVersion = '1.45.0' try { sassVersion = require(require.resolve('sass/package.json')).version } catch {} From 8476e4bb431ff3fc3bbbaa3408600fb795d286c4 Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Fri, 15 Nov 2024 22:32:58 +0900 Subject: [PATCH 19/19] fix: dereference and use ResolvedVc type --- crates/next-core/src/next_shared/webpack_rules/mod.rs | 3 ++- crates/next-core/src/next_shared/webpack_rules/sass.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/next-core/src/next_shared/webpack_rules/mod.rs b/crates/next-core/src/next_shared/webpack_rules/mod.rs index ac9ad4e27e026..72825edc1dc37 100644 --- a/crates/next-core/src/next_shared/webpack_rules/mod.rs +++ b/crates/next-core/src/next_shared/webpack_rules/mod.rs @@ -17,7 +17,8 @@ pub async fn webpack_loader_options( conditions: Vec, ) -> Result>> { let rules = *next_config.webpack_rules(conditions).await?; - let rules = *maybe_add_sass_loader(next_config.sass_config(), rules.map(|v| *v), project_path).await?; + let rules = + *maybe_add_sass_loader(next_config.sass_config(), rules.map(|v| *v), *project_path).await?; let rules = if foreign { rules } else { diff --git a/crates/next-core/src/next_shared/webpack_rules/sass.rs b/crates/next-core/src/next_shared/webpack_rules/sass.rs index b5961ec1dcb90..b21791cc21a86 100644 --- a/crates/next-core/src/next_shared/webpack_rules/sass.rs +++ b/crates/next-core/src/next_shared/webpack_rules/sass.rs @@ -16,7 +16,7 @@ use turbopack_node::transforms::webpack::WebpackLoaderItem; pub async fn maybe_add_sass_loader( sass_options: Vc, webpack_rules: Option>, - package_dir: Vc, + package_dir: ResolvedVc, ) -> Result> { let sass_options = sass_options.await?; let Some(mut sass_options) = sass_options.as_object().cloned() else { @@ -24,7 +24,7 @@ pub async fn maybe_add_sass_loader( }; let sass_package_json_path = resolve_raw( - package_dir, + *package_dir, Pattern::Constant("sass/package.json".into()).cell(), false, )