diff --git a/build-tests/heft-sass-test/config/sass.json b/build-tests/heft-sass-test/config/sass.json index bade2384d3c..a4993854d2f 100644 --- a/build-tests/heft-sass-test/config/sass.json +++ b/build-tests/heft-sass-test/config/sass.json @@ -9,5 +9,8 @@ "secondaryGeneratedTsFolders": ["lib"], "excludeFiles": ["./ignored1.scss", "ignored2.scss"], + "fileExtensions": [".module.scss", ".module.sass", ".module.css"], + "nonModuleFileExtensions": [".global.scss", ".global.sass", ".global.css"], + "silenceDeprecations": ["mixed-decls", "import", "global-builtin", "color-functions"] } diff --git a/build-tests/heft-sass-test/src/ExampleApp.tsx b/build-tests/heft-sass-test/src/ExampleApp.tsx index 57f3f692066..5f9e7d817b2 100644 --- a/build-tests/heft-sass-test/src/ExampleApp.tsx +++ b/build-tests/heft-sass-test/src/ExampleApp.tsx @@ -3,11 +3,11 @@ import * as React from 'react'; -import styles from './styles.sass'; -import oldStyles from './stylesCSS.css'; -import altSyntaxStyles from './stylesAltSyntax.scss'; -import stylesUseSyntax from './stylesUseSyntax.sass'; -import stylesUseAltSyntax from './stylesUseAltSyntax.scss'; +import styles from './styles.module.sass'; +import oldStyles from './stylesCSS.module.css'; +import altSyntaxStyles from './stylesAltSyntax.module.scss'; +import stylesUseSyntax from './stylesUseSyntax.module.sass'; +import stylesUseAltSyntax from './stylesUseAltSyntax.module.scss'; import './stylesAltSyntax.global.scss'; /** diff --git a/build-tests/heft-sass-test/src/styles.sass b/build-tests/heft-sass-test/src/styles.module.sass similarity index 91% rename from build-tests/heft-sass-test/src/styles.sass rename to build-tests/heft-sass-test/src/styles.module.sass index a79830ecfef..61be0178191 100644 --- a/build-tests/heft-sass-test/src/styles.sass +++ b/build-tests/heft-sass-test/src/styles.module.sass @@ -1,28 +1,28 @@ -/** - * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. - * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. - */ - -// Testing Sass imports -@import 'stylesImport' - -// Testing node_modules imports -@import '~buttono/buttono' - -// Testing root styles -html, body - margin: 0 - height: 100% - background-color: #c0c0c0 - font-family: Tahoma, sans-serif - -// Testing Sass classes -.exampleApp - background-color: #ffffff - padding: 20px - border-radius: 5px - width: 400px - -.exampleButton - @include buttono-block() - @include buttono-style-modifier($background-color: mediumorchid) +/** + * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. + * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. + */ + +// Testing Sass imports +@import 'stylesImport' + +// Testing node_modules imports +@import 'pkg:buttono/buttono' + +// Testing root styles +html, body + margin: 0 + height: 100% + background-color: #c0c0c0 + font-family: Tahoma, sans-serif + +// Testing Sass classes +.exampleApp + background-color: #ffffff + padding: 20px + border-radius: 5px + width: 400px + +.exampleButton + @include buttono-block() + @include buttono-style-modifier($background-color: mediumorchid) diff --git a/build-tests/heft-sass-test/src/stylesAltSyntax.scss b/build-tests/heft-sass-test/src/stylesAltSyntax.module.scss similarity index 100% rename from build-tests/heft-sass-test/src/stylesAltSyntax.scss rename to build-tests/heft-sass-test/src/stylesAltSyntax.module.scss diff --git a/build-tests/heft-sass-test/src/stylesCSS.css b/build-tests/heft-sass-test/src/stylesCSS.module.css similarity index 100% rename from build-tests/heft-sass-test/src/stylesCSS.css rename to build-tests/heft-sass-test/src/stylesCSS.module.css diff --git a/build-tests/heft-sass-test/src/stylesUseAltSyntax.scss b/build-tests/heft-sass-test/src/stylesUseAltSyntax.module.scss similarity index 100% rename from build-tests/heft-sass-test/src/stylesUseAltSyntax.scss rename to build-tests/heft-sass-test/src/stylesUseAltSyntax.module.scss diff --git a/build-tests/heft-sass-test/src/stylesUseSyntax.sass b/build-tests/heft-sass-test/src/stylesUseSyntax.module.sass similarity index 100% rename from build-tests/heft-sass-test/src/stylesUseSyntax.sass rename to build-tests/heft-sass-test/src/stylesUseSyntax.module.sass diff --git a/build-tests/heft-sass-test/src/test/__snapshots__/lib-commonjs.test.ts.snap b/build-tests/heft-sass-test/src/test/__snapshots__/lib-commonjs.test.ts.snap index 6825ac5b4bc..6561952445e 100644 --- a/build-tests/heft-sass-test/src/test/__snapshots__/lib-commonjs.test.ts.snap +++ b/build-tests/heft-sass-test/src/test/__snapshots__/lib-commonjs.test.ts.snap @@ -4,14 +4,14 @@ exports[`SASS CJS Shims ignored1.scss: files 1`] = `Array []`; exports[`SASS CJS Shims ignored2.scss: files 1`] = `Array []`; -exports[`SASS CJS Shims styles.sass: files 1`] = ` +exports[`SASS CJS Shims styles.module.sass: files 1`] = ` Array [ - "styles.css", - "styles.sass.js", + "styles.module.css", + "styles.module.sass.js", ] `; -exports[`SASS CJS Shims styles.sass: styles.css 1`] = ` +exports[`SASS CJS Shims styles.module.sass: styles.module.css 1`] = ` "/** * * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -80,8 +80,8 @@ html, body { }" `; -exports[`SASS CJS Shims styles.sass: styles.sass.js 1`] = ` -"module.exports = require(\\"./styles.css\\"); +exports[`SASS CJS Shims styles.module.sass: styles.module.sass.js 1`] = ` +"module.exports = require(\\"./styles.module.css\\"); module.exports.default = module.exports;" `; @@ -104,16 +104,14 @@ exports[`SASS CJS Shims stylesAltSyntax.global.scss: stylesAltSyntax.global.css exports[`SASS CJS Shims stylesAltSyntax.global.scss: stylesAltSyntax.global.scss.js 1`] = `"require(\\"./stylesAltSyntax.global.css\\");"`; -exports[`SASS CJS Shims stylesAltSyntax.scss: files 1`] = ` +exports[`SASS CJS Shims stylesAltSyntax.module.scss: files 1`] = ` Array [ - "stylesAltSyntax.css", - "stylesAltSyntax.global.css", - "stylesAltSyntax.global.scss.js", - "stylesAltSyntax.scss.js", + "stylesAltSyntax.module.css", + "stylesAltSyntax.module.scss.js", ] `; -exports[`SASS CJS Shims stylesAltSyntax.scss: stylesAltSyntax.css 1`] = ` +exports[`SASS CJS Shims stylesAltSyntax.module.scss: stylesAltSyntax.module.css 1`] = ` "/** * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -123,31 +121,19 @@ exports[`SASS CJS Shims stylesAltSyntax.scss: stylesAltSyntax.css 1`] = ` }" `; -exports[`SASS CJS Shims stylesAltSyntax.scss: stylesAltSyntax.global.css 1`] = ` -"/** - * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. - * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. - */ -.ms-label { - margin-bottom: 20px; -}" -`; - -exports[`SASS CJS Shims stylesAltSyntax.scss: stylesAltSyntax.global.scss.js 1`] = `"require(\\"./stylesAltSyntax.global.css\\");"`; - -exports[`SASS CJS Shims stylesAltSyntax.scss: stylesAltSyntax.scss.js 1`] = ` -"module.exports = require(\\"./stylesAltSyntax.css\\"); +exports[`SASS CJS Shims stylesAltSyntax.module.scss: stylesAltSyntax.module.scss.js 1`] = ` +"module.exports = require(\\"./stylesAltSyntax.module.css\\"); module.exports.default = module.exports;" `; -exports[`SASS CJS Shims stylesUseAltSyntax.scss: files 1`] = ` +exports[`SASS CJS Shims stylesUseAltSyntax.module.scss: files 1`] = ` Array [ - "stylesUseAltSyntax.css", - "stylesUseAltSyntax.scss.js", + "stylesUseAltSyntax.module.css", + "stylesUseAltSyntax.module.scss.js", ] `; -exports[`SASS CJS Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.css 1`] = ` +exports[`SASS CJS Shims stylesUseAltSyntax.module.scss: stylesUseAltSyntax.module.css 1`] = ` "/** * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -185,19 +171,19 @@ exports[`SASS CJS Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.css 1`] = ` }" `; -exports[`SASS CJS Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.scss.js 1`] = ` -"module.exports = require(\\"./stylesUseAltSyntax.css\\"); +exports[`SASS CJS Shims stylesUseAltSyntax.module.scss: stylesUseAltSyntax.module.scss.js 1`] = ` +"module.exports = require(\\"./stylesUseAltSyntax.module.css\\"); module.exports.default = module.exports;" `; -exports[`SASS CJS Shims stylesUseSyntax.sass: files 1`] = ` +exports[`SASS CJS Shims stylesUseSyntax.module.sass: files 1`] = ` Array [ - "stylesUseSyntax.css", - "stylesUseSyntax.sass.js", + "stylesUseSyntax.module.css", + "stylesUseSyntax.module.sass.js", ] `; -exports[`SASS CJS Shims stylesUseSyntax.sass: stylesUseSyntax.css 1`] = ` +exports[`SASS CJS Shims stylesUseSyntax.module.sass: stylesUseSyntax.module.css 1`] = ` "/** * * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -251,7 +237,7 @@ exports[`SASS CJS Shims stylesUseSyntax.sass: stylesUseSyntax.css 1`] = ` }" `; -exports[`SASS CJS Shims stylesUseSyntax.sass: stylesUseSyntax.sass.js 1`] = ` -"module.exports = require(\\"./stylesUseSyntax.css\\"); +exports[`SASS CJS Shims stylesUseSyntax.module.sass: stylesUseSyntax.module.sass.js 1`] = ` +"module.exports = require(\\"./stylesUseSyntax.module.css\\"); module.exports.default = module.exports;" `; diff --git a/build-tests/heft-sass-test/src/test/__snapshots__/lib-css.test.ts.snap b/build-tests/heft-sass-test/src/test/__snapshots__/lib-css.test.ts.snap index 732c90b7f46..439187a2df7 100644 --- a/build-tests/heft-sass-test/src/test/__snapshots__/lib-css.test.ts.snap +++ b/build-tests/heft-sass-test/src/test/__snapshots__/lib-css.test.ts.snap @@ -4,13 +4,13 @@ exports[`SASS No Shims ignored1.scss: files 1`] = `Array []`; exports[`SASS No Shims ignored2.scss: files 1`] = `Array []`; -exports[`SASS No Shims styles.sass: files 1`] = ` +exports[`SASS No Shims styles.module.sass: files 1`] = ` Array [ - "styles.css", + "styles.module.css", ] `; -exports[`SASS No Shims styles.sass: styles.css 1`] = ` +exports[`SASS No Shims styles.module.sass: styles.module.css 1`] = ` "/** * * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -95,14 +95,13 @@ exports[`SASS No Shims stylesAltSyntax.global.scss: stylesAltSyntax.global.css 1 }" `; -exports[`SASS No Shims stylesAltSyntax.scss: files 1`] = ` +exports[`SASS No Shims stylesAltSyntax.module.scss: files 1`] = ` Array [ - "stylesAltSyntax.css", - "stylesAltSyntax.global.css", + "stylesAltSyntax.module.css", ] `; -exports[`SASS No Shims stylesAltSyntax.scss: stylesAltSyntax.css 1`] = ` +exports[`SASS No Shims stylesAltSyntax.module.scss: stylesAltSyntax.module.css 1`] = ` "/** * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -112,23 +111,13 @@ exports[`SASS No Shims stylesAltSyntax.scss: stylesAltSyntax.css 1`] = ` }" `; -exports[`SASS No Shims stylesAltSyntax.scss: stylesAltSyntax.global.css 1`] = ` -"/** - * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. - * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. - */ -.ms-label { - margin-bottom: 20px; -}" -`; - -exports[`SASS No Shims stylesUseAltSyntax.scss: files 1`] = ` +exports[`SASS No Shims stylesUseAltSyntax.module.scss: files 1`] = ` Array [ - "stylesUseAltSyntax.css", + "stylesUseAltSyntax.module.css", ] `; -exports[`SASS No Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.css 1`] = ` +exports[`SASS No Shims stylesUseAltSyntax.module.scss: stylesUseAltSyntax.module.css 1`] = ` "/** * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -166,13 +155,13 @@ exports[`SASS No Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.css 1`] = ` }" `; -exports[`SASS No Shims stylesUseSyntax.sass: files 1`] = ` +exports[`SASS No Shims stylesUseSyntax.module.sass: files 1`] = ` Array [ - "stylesUseSyntax.css", + "stylesUseSyntax.module.css", ] `; -exports[`SASS No Shims stylesUseSyntax.sass: stylesUseSyntax.css 1`] = ` +exports[`SASS No Shims stylesUseSyntax.module.sass: stylesUseSyntax.module.css 1`] = ` "/** * * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. diff --git a/build-tests/heft-sass-test/src/test/__snapshots__/lib.test.ts.snap b/build-tests/heft-sass-test/src/test/__snapshots__/lib.test.ts.snap index 078979eed43..3a5d74f9644 100644 --- a/build-tests/heft-sass-test/src/test/__snapshots__/lib.test.ts.snap +++ b/build-tests/heft-sass-test/src/test/__snapshots__/lib.test.ts.snap @@ -4,15 +4,15 @@ exports[`SASS ESM Shims ignored1.scss: files 1`] = `Array []`; exports[`SASS ESM Shims ignored2.scss: files 1`] = `Array []`; -exports[`SASS ESM Shims styles.sass: files 1`] = ` +exports[`SASS ESM Shims styles.module.sass: files 1`] = ` Array [ - "styles.css", - "styles.sass.d.ts", - "styles.sass.js", + "styles.module.css", + "styles.module.sass.d.ts", + "styles.module.sass.js", ] `; -exports[`SASS ESM Shims styles.sass: styles.css 1`] = ` +exports[`SASS ESM Shims styles.module.sass: styles.module.css 1`] = ` "/** * * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -81,7 +81,7 @@ html, body { }" `; -exports[`SASS ESM Shims styles.sass: styles.sass.d.ts 1`] = ` +exports[`SASS ESM Shims styles.module.sass: styles.module.sass.d.ts 1`] = ` "declare interface IStyles { exampleImport: string; exampleApp: string; @@ -91,7 +91,7 @@ declare const styles: IStyles; export default styles;" `; -exports[`SASS ESM Shims styles.sass: styles.sass.js 1`] = `"export { default } from \\"./styles.css\\";"`; +exports[`SASS ESM Shims styles.module.sass: styles.module.sass.js 1`] = `"export { default } from \\"./styles.module.css\\";"`; exports[`SASS ESM Shims stylesAltSyntax.global.scss: files 1`] = ` Array [ @@ -115,18 +115,15 @@ exports[`SASS ESM Shims stylesAltSyntax.global.scss: stylesAltSyntax.global.scss exports[`SASS ESM Shims stylesAltSyntax.global.scss: stylesAltSyntax.global.scss.js 1`] = `"import \\"./stylesAltSyntax.global.css\\";export {};"`; -exports[`SASS ESM Shims stylesAltSyntax.scss: files 1`] = ` +exports[`SASS ESM Shims stylesAltSyntax.module.scss: files 1`] = ` Array [ - "stylesAltSyntax.css", - "stylesAltSyntax.global.css", - "stylesAltSyntax.global.scss.d.ts", - "stylesAltSyntax.global.scss.js", - "stylesAltSyntax.scss.d.ts", - "stylesAltSyntax.scss.js", + "stylesAltSyntax.module.css", + "stylesAltSyntax.module.scss.d.ts", + "stylesAltSyntax.module.scss.js", ] `; -exports[`SASS ESM Shims stylesAltSyntax.scss: stylesAltSyntax.css 1`] = ` +exports[`SASS ESM Shims stylesAltSyntax.module.scss: stylesAltSyntax.module.css 1`] = ` "/** * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -136,21 +133,7 @@ exports[`SASS ESM Shims stylesAltSyntax.scss: stylesAltSyntax.css 1`] = ` }" `; -exports[`SASS ESM Shims stylesAltSyntax.scss: stylesAltSyntax.global.css 1`] = ` -"/** - * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. - * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. - */ -.ms-label { - margin-bottom: 20px; -}" -`; - -exports[`SASS ESM Shims stylesAltSyntax.scss: stylesAltSyntax.global.scss.d.ts 1`] = `"export {};"`; - -exports[`SASS ESM Shims stylesAltSyntax.scss: stylesAltSyntax.global.scss.js 1`] = `"import \\"./stylesAltSyntax.global.css\\";export {};"`; - -exports[`SASS ESM Shims stylesAltSyntax.scss: stylesAltSyntax.scss.d.ts 1`] = ` +exports[`SASS ESM Shims stylesAltSyntax.module.scss: stylesAltSyntax.module.scss.d.ts 1`] = ` "declare interface IStyles { label: string; } @@ -158,17 +141,17 @@ declare const styles: IStyles; export default styles;" `; -exports[`SASS ESM Shims stylesAltSyntax.scss: stylesAltSyntax.scss.js 1`] = `"export { default } from \\"./stylesAltSyntax.css\\";"`; +exports[`SASS ESM Shims stylesAltSyntax.module.scss: stylesAltSyntax.module.scss.js 1`] = `"export { default } from \\"./stylesAltSyntax.module.css\\";"`; -exports[`SASS ESM Shims stylesUseAltSyntax.scss: files 1`] = ` +exports[`SASS ESM Shims stylesUseAltSyntax.module.scss: files 1`] = ` Array [ - "stylesUseAltSyntax.css", - "stylesUseAltSyntax.scss.d.ts", - "stylesUseAltSyntax.scss.js", + "stylesUseAltSyntax.module.css", + "stylesUseAltSyntax.module.scss.d.ts", + "stylesUseAltSyntax.module.scss.js", ] `; -exports[`SASS ESM Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.css 1`] = ` +exports[`SASS ESM Shims stylesUseAltSyntax.module.scss: stylesUseAltSyntax.module.css 1`] = ` "/** * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -206,7 +189,7 @@ exports[`SASS ESM Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.css 1`] = ` }" `; -exports[`SASS ESM Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.scss.d.ts 1`] = ` +exports[`SASS ESM Shims stylesUseAltSyntax.module.scss: stylesUseAltSyntax.module.scss.d.ts 1`] = ` "declare interface IStyles { label: string; exampleList: string; @@ -218,17 +201,17 @@ declare const styles: IStyles; export default styles;" `; -exports[`SASS ESM Shims stylesUseAltSyntax.scss: stylesUseAltSyntax.scss.js 1`] = `"export { default } from \\"./stylesUseAltSyntax.css\\";"`; +exports[`SASS ESM Shims stylesUseAltSyntax.module.scss: stylesUseAltSyntax.module.scss.js 1`] = `"export { default } from \\"./stylesUseAltSyntax.module.css\\";"`; -exports[`SASS ESM Shims stylesUseSyntax.sass: files 1`] = ` +exports[`SASS ESM Shims stylesUseSyntax.module.sass: files 1`] = ` Array [ - "stylesUseSyntax.css", - "stylesUseSyntax.sass.d.ts", - "stylesUseSyntax.sass.js", + "stylesUseSyntax.module.css", + "stylesUseSyntax.module.sass.d.ts", + "stylesUseSyntax.module.sass.js", ] `; -exports[`SASS ESM Shims stylesUseSyntax.sass: stylesUseSyntax.css 1`] = ` +exports[`SASS ESM Shims stylesUseSyntax.module.sass: stylesUseSyntax.module.css 1`] = ` "/** * * This file gets transpiled by the heft-sass-plugin and output to the lib/ folder. * * Then Webpack uses css-loader to embed, and finally style-loader to apply it to the DOM. @@ -282,7 +265,7 @@ exports[`SASS ESM Shims stylesUseSyntax.sass: stylesUseSyntax.css 1`] = ` }" `; -exports[`SASS ESM Shims stylesUseSyntax.sass: stylesUseSyntax.sass.d.ts 1`] = ` +exports[`SASS ESM Shims stylesUseSyntax.module.sass: stylesUseSyntax.module.sass.d.ts 1`] = ` "declare interface IStyles { exampleAnchor: string; } @@ -290,4 +273,4 @@ declare const styles: IStyles; export default styles;" `; -exports[`SASS ESM Shims stylesUseSyntax.sass: stylesUseSyntax.sass.js 1`] = `"export { default } from \\"./stylesUseSyntax.css\\";"`; +exports[`SASS ESM Shims stylesUseSyntax.module.sass: stylesUseSyntax.module.sass.js 1`] = `"export { default } from \\"./stylesUseSyntax.module.css\\";"`; diff --git a/build-tests/heft-sass-test/src/test/__snapshots__/sass-ts.test.ts.snap b/build-tests/heft-sass-test/src/test/__snapshots__/sass-ts.test.ts.snap index 7879c34de58..1c7500668ba 100644 --- a/build-tests/heft-sass-test/src/test/__snapshots__/sass-ts.test.ts.snap +++ b/build-tests/heft-sass-test/src/test/__snapshots__/sass-ts.test.ts.snap @@ -4,13 +4,13 @@ exports[`SASS Typings ignored1.scss: files 1`] = `Array []`; exports[`SASS Typings ignored2.scss: files 1`] = `Array []`; -exports[`SASS Typings styles.sass: files 1`] = ` +exports[`SASS Typings styles.module.sass: files 1`] = ` Array [ - "styles.sass.d.ts", + "styles.module.sass.d.ts", ] `; -exports[`SASS Typings styles.sass: styles.sass.d.ts 1`] = ` +exports[`SASS Typings styles.module.sass: styles.module.sass.d.ts 1`] = ` "declare interface IStyles { exampleImport: string; exampleApp: string; @@ -28,16 +28,13 @@ Array [ exports[`SASS Typings stylesAltSyntax.global.scss: stylesAltSyntax.global.scss.d.ts 1`] = `"export {};"`; -exports[`SASS Typings stylesAltSyntax.scss: files 1`] = ` +exports[`SASS Typings stylesAltSyntax.module.scss: files 1`] = ` Array [ - "stylesAltSyntax.global.scss.d.ts", - "stylesAltSyntax.scss.d.ts", + "stylesAltSyntax.module.scss.d.ts", ] `; -exports[`SASS Typings stylesAltSyntax.scss: stylesAltSyntax.global.scss.d.ts 1`] = `"export {};"`; - -exports[`SASS Typings stylesAltSyntax.scss: stylesAltSyntax.scss.d.ts 1`] = ` +exports[`SASS Typings stylesAltSyntax.module.scss: stylesAltSyntax.module.scss.d.ts 1`] = ` "declare interface IStyles { label: string; } @@ -45,13 +42,13 @@ declare const styles: IStyles; export default styles;" `; -exports[`SASS Typings stylesUseAltSyntax.scss: files 1`] = ` +exports[`SASS Typings stylesUseAltSyntax.module.scss: files 1`] = ` Array [ - "stylesUseAltSyntax.scss.d.ts", + "stylesUseAltSyntax.module.scss.d.ts", ] `; -exports[`SASS Typings stylesUseAltSyntax.scss: stylesUseAltSyntax.scss.d.ts 1`] = ` +exports[`SASS Typings stylesUseAltSyntax.module.scss: stylesUseAltSyntax.module.scss.d.ts 1`] = ` "declare interface IStyles { label: string; exampleList: string; @@ -63,13 +60,13 @@ declare const styles: IStyles; export default styles;" `; -exports[`SASS Typings stylesUseSyntax.sass: files 1`] = ` +exports[`SASS Typings stylesUseSyntax.module.sass: files 1`] = ` Array [ - "stylesUseSyntax.sass.d.ts", + "stylesUseSyntax.module.sass.d.ts", ] `; -exports[`SASS Typings stylesUseSyntax.sass: stylesUseSyntax.sass.d.ts 1`] = ` +exports[`SASS Typings stylesUseSyntax.module.sass: stylesUseSyntax.module.sass.d.ts 1`] = ` "declare interface IStyles { exampleAnchor: string; } diff --git a/build-tests/heft-sass-test/src/utilities/configurableModule.sass b/build-tests/heft-sass-test/src/utilities/_configurableModule.sass similarity index 100% rename from build-tests/heft-sass-test/src/utilities/configurableModule.sass rename to build-tests/heft-sass-test/src/utilities/_configurableModule.sass diff --git a/build-tests/heft-sass-test/src/utilities/relativeImport.sass b/build-tests/heft-sass-test/src/utilities/_relativeImport.sass similarity index 98% rename from build-tests/heft-sass-test/src/utilities/relativeImport.sass rename to build-tests/heft-sass-test/src/utilities/_relativeImport.sass index 49289ad2a51..627b27fa18e 100644 --- a/build-tests/heft-sass-test/src/utilities/relativeImport.sass +++ b/build-tests/heft-sass-test/src/utilities/_relativeImport.sass @@ -1,5 +1,5 @@ -/** - * This file is not used by the example component. However, it verifies that relative Sass imports are successful. +/** + * This file is not used by the example component. However, it verifies that relative Sass imports are successful. */ @import '../stylesImport' \ No newline at end of file diff --git a/build-tests/heft-sass-test/src/utilities/useSyntaxRelativeImport.sass b/build-tests/heft-sass-test/src/utilities/_useSyntaxRelativeImport.sass similarity index 100% rename from build-tests/heft-sass-test/src/utilities/useSyntaxRelativeImport.sass rename to build-tests/heft-sass-test/src/utilities/_useSyntaxRelativeImport.sass diff --git a/common/changes/@rushstack/heft-sass-plugin/sass-partials_2025-05-12-22-27.json b/common/changes/@rushstack/heft-sass-plugin/sass-partials_2025-05-12-22-27.json new file mode 100644 index 00000000000..ef02fe4ebd5 --- /dev/null +++ b/common/changes/@rushstack/heft-sass-plugin/sass-partials_2025-05-12-22-27.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/heft-sass-plugin", + "comment": "Fix an issue where the SCSS module classifier evaluated SCSS partials instead of ignoring them (since they aren't directly importable).", + "type": "patch" + } + ], + "packageName": "@rushstack/heft-sass-plugin" +} \ No newline at end of file diff --git a/heft-plugins/heft-sass-plugin/src/SassProcessor.ts b/heft-plugins/heft-sass-plugin/src/SassProcessor.ts index 3c8719653c8..76b4db9d83e 100644 --- a/heft-plugins/heft-sass-plugin/src/SassProcessor.ts +++ b/heft-plugins/heft-sass-plugin/src/SassProcessor.ts @@ -607,7 +607,8 @@ export class SassProcessor { const url: URL = pathToHeftUrl(absolutePath); const isPartial: boolean = isSassPartial(absolutePath); - const isModule: boolean = this._isFileModule(absolutePath); + // SCSS partials are not modules, insofar as they cannot be imported directly. + const isModule: boolean = isPartial ? false : this._isFileModule(absolutePath); const fileRecord: IFileRecord = { absolutePath, @@ -670,7 +671,7 @@ export class SassProcessor { let record: IFileRecord | undefined = this._fileInfo.get(filePath); if (!record) { const isPartial: boolean = isSassPartial(filePath); - const isModule: boolean = this._isFileModule(filePath); + const isModule: boolean = isPartial ? false : this._isFileModule(filePath); const url: URL = pathToHeftUrl(filePath); record = { absolutePath: filePath,