Skip to content

Commit

Permalink
test: sass modules "@use" (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
donnysim authored and evilebottnawi committed Oct 7, 2019
1 parent aa9b53b commit 185ba80
Show file tree
Hide file tree
Showing 42 changed files with 50,463 additions and 134 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"npm-run-all": "^4.1.5",
"popper.js": "^1.15.0",
"prettier": "^1.18.2",
"sass": "^1.22.10",
"sass": "^1.23.0",
"standard-version": "^7.0.0",
"style-loader": "^1.0.0",
"webpack": "^4.39.3",
Expand Down
49,684 changes: 49,554 additions & 130 deletions test/__snapshots__/loader.test.js.snap

Large diffs are not rendered by default.

387 changes: 387 additions & 0 deletions test/loader.test.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/sass/error-file-not-found-use-2.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "./another/_module.scss"
1 change: 1 addition & 0 deletions test/sass/error-file-not-found-use.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "does-not-exist"
1 change: 1 addition & 0 deletions test/sass/error-use.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "error"
1 change: 1 addition & 0 deletions test/sass/use-_index.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~sass-package-with-underscore-index" as module
5 changes: 5 additions & 0 deletions test/sass/use-alias.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use 'path-to-alias'
@use "~@sass" as module
@use "~@path-to-sass-dir/dir-with-underscore-index" as module1
@use "~@path-to-sass-dir/dir-with-underscore-index/" as module2
@use "~@/path-to-sass-dir/dir-with-underscore-index" as module3
1 change: 1 addition & 0 deletions test/sass/use-bootstrap-sass-package.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~bootstrap-sass" as bootstrap with ($icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/")
2 changes: 2 additions & 0 deletions test/sass/use-bootstrap-sass.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@use "~bootstrap-sass/assets/stylesheets/bootstrap" with ($icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/")

1 change: 1 addition & 0 deletions test/sass/use-bootstrap.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~bootstrap" as bootstrap
1 change: 1 addition & 0 deletions test/sass/use-custom-sass-field.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~sass-custom-sass-field" as module
7 changes: 7 additions & 0 deletions test/sass/use-from-npm-org-pkg.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* @use ~@org/pkg */
@use "~@org/pkg"
/* @use ~@org/bar/foo */
@use "~@org/bar/foo"

.foo
background: #000
1 change: 1 addition & 0 deletions test/sass/use-index.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~sass-package-with-index" as module
1 change: 1 addition & 0 deletions test/sass/use-main-field.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~sass-main-field" as module
4 changes: 4 additions & 0 deletions test/sass/use-other-style.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Importing a scss module does not require to set the extension explicitly... */
@use "../scss/another/module" as module
/* ...but it is allowed */
@use "../scss/another/module.scss" as module1
1 change: 1 addition & 0 deletions test/sass/use-sass-field.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~sass-sass-field" as module
1 change: 1 addition & 0 deletions test/sass/use-style-field.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~sass-style-field" as module
18 changes: 18 additions & 0 deletions test/sass/use-with-extension.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@use "example.sass" as module1
@use "./example.sass" as module2
@use "../sass/example.sass" as module3
// TODO https://github.com/sass/dart-sass/issues/798#issuecomment-521229911
// @use "example-1.SASS" as module4
@use "example-2.sass" as module5
@use "./example-2.sass" as module6
@use "../sass/example-2.sass" as module7
// TODO https://github.com/sass/dart-sass/issues/798#issuecomment-521229911
// @use "example-3.SASS" as module8
@use "nested/example-4.sass" as module9
@use "./nested/example-4.sass" as modul10e
@use "../sass/nested/example-4.sass" as module11
@use "nested/example-5.sass" as module12
@use "./nested/example-5.sass" as module13
@use "../sass/nested/example-5.sass" as module14
// TODO https://github.com/sass/dart-sass/issues/798#issuecomment-521229911
// @use "nested/example-6.SASS" as module15
112 changes: 112 additions & 0 deletions test/sass/use-with-underscore.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
@use "_underscore-file" as module1
@use "underscore-file" as module2
@use "./_underscore-file" as module3
@use "./underscore-file" as module4
@use "../sass/_underscore-file" as module5
@use "../sass/underscore-file" as module6
@use "_underscore-file.sass" as module7
@use "./_underscore-file.sass" as module8
@use "../sass/_underscore-file.sass" as module9
@use "../sass/underscore-file.sass" as module10
// SASS
@use "_underscore-file-1" as module11
@use "underscore-file-1" as module12
@use "./_underscore-file-1" as module13
@use "./underscore-file-1" as module14
@use "../sass/_underscore-file-1" as module15
@use "../sass/underscore-file-1" as module16
@use "_underscore-file-1.sass" as module17
@use "underscore-file-1.sass" as module18
@use "./_underscore-file-1.sass" as module19
@use "./underscore-file-1.sass" as module20
@use "../sass/_underscore-file-1.sass" as module21
@use "../sass/underscore-file-1.sass" as module22
// SCSS
@use "_underscore-file-2" as module23
@use "underscore-file-2" as module24
@use "./_underscore-file-2" as module25
@use "./underscore-file-2" as module26
@use "../sass/_underscore-file-2" as module27
@use "../sass/underscore-file-2" as module28
@use "_underscore-file-2.scss" as module29
@use "underscore-file-2.scss" as module30
@use "./_underscore-file-2.scss" as module31
@use "./underscore-file-2.scss" as module32
@use "../sass/_underscore-file-2.scss" as module33
@use "../sass/underscore-file-2.scss" as module34
// CSS
@use "_underscore-file-3" as module35
@use "underscore-file-3" as module36
@use "./_underscore-file-3" as module37
@use "./underscore-file-3" as module38
@use "../sass/_underscore-file-3" as module39
@use "../sass/underscore-file-3" as module40
// underscore index SASS
@use "_underscore-dir" as module41
@use "./_underscore-dir" as module42
@use "../sass/_underscore-dir" as module43
@use "_underscore-dir/_index" as module44
@use "./_underscore-dir/_index" as module45
@use "../sass/_underscore-dir/_index" as module46
@use "_underscore-dir/_index.sass" as module47
@use "./_underscore-dir/_index.sass" as module48
@use "../sass/_underscore-dir/_index.sass" as module49
@use "_underscore-dir/index" as module50
@use "./_underscore-dir/index" as module51
@use "../sass/_underscore-dir/index" as module52
@use "_underscore-dir/index.sass" as module53
@use "./_underscore-dir/index.sass" as module54
@use "../sass/_underscore-dir/index.sass" as module55
// index SASS
@use "_underscore-dir-1" as module56
@use "./_underscore-dir-1" as module57
@use "../sass/_underscore-dir-1" as module58
@use "_underscore-dir-1/index" as module59
@use "./_underscore-dir-1/index" as module60
@use "../sass/_underscore-dir-1/index" as module61
@use "_underscore-dir-1/index.sass" as module62
@use "./_underscore-dir-1/index.sass" as module63
@use "../sass/_underscore-dir-1/index.sass" as module64
// underscore index SCSS
@use "_underscore-dir-2" as module65
@use "./_underscore-dir-2" as module66
@use "../sass/_underscore-dir-2" as module67
@use "_underscore-dir-2/_index" as module68
@use "./_underscore-dir-2/_index" as module69
@use "../sass/_underscore-dir-2/_index" as module70
@use "_underscore-dir-2/_index.scss" as module71
@use "./_underscore-dir-2/_index.scss" as module72
@use "../sass/_underscore-dir-2/_index.scss" as module73
@use "_underscore-dir-2/index" as module74
@use "./_underscore-dir-2/index" as module75
@use "../sass/_underscore-dir-2/index" as module76
@use "_underscore-dir-2/index.scss" as module77
@use "./_underscore-dir-2/index.scss" as module78
@use "../sass/_underscore-dir-2/index.scss" as module79
// index SCSS
@use "_underscore-dir-3" as module80
@use "./_underscore-dir-3" as module81
@use "../sass/_underscore-dir-3" as module82
@use "_underscore-dir-3/index" as module83
@use "./_underscore-dir-3/index" as module84
@use "../sass/_underscore-dir-3/index" as module85
@use "_underscore-dir-3/index.scss" as module86
@use "./_underscore-dir-3/index.scss" as module87
@use "../sass/_underscore-dir-3/index.scss" as module88
// underscore index CSS
@use "_underscore-dir-4" as module89
@use "./_underscore-dir-4" as module90
@use "../sass/_underscore-dir-4" as module91
@use "_underscore-dir-4/_index" as module92
@use "./_underscore-dir-4/_index" as module93
@use "../sass/_underscore-dir-4/_index" as module94
@use "_underscore-dir-4/index" as module95
@use "./_underscore-dir-4/index" as module96
@use "../sass/_underscore-dir-4/index" as module97
// index CSS
@use "_underscore-dir-5" as module98
@use "./_underscore-dir-5" as module99
@use "../sass/_underscore-dir-5" as module100
@use "_underscore-dir-5/index" as module101
@use "./_underscore-dir-5/index" as module102
@use "../sass/_underscore-dir-5/index" as module103
75 changes: 75 additions & 0 deletions test/sass/use-without-extension-and-underscore.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Filename
@import "word" as module1
@import "./word" as module2
@import "../sass/word" as module3
@import "word-1" as module4
@import "./word-1" as module5
@import "../sass/word-1" as module6
@import "word-2" as module7
@import "./word-2" as module8
@import "../sass/word-2" as module9
@import "word-3" as module10
@import "./word-3" as module11
@import "../sass/word-3" as module12
@import "word-4" as module13
@import "./word-4" as module14
@import "../sass/word-4" as module15
@import "word-5" as module16
@import "./word-5" as module17
@import "../sass/word-5" as module18
@import "word-6" as module19
@import "./word-6" as module20
@import "../sass/word-6" as module21
@import "word-7" as module22
@import "./word-7" as module23
@import "../sass/word-7" as module24
@import "word-8" as module25
@import "./word-8" as module26
@import "../sass/word-8" as module27
@import "word-9" as module28
@import "./word-9" as module29
@import "../sass/word-9" as module30
@import "word-10" as module31
@import "./word-10" as module32
@import "../sass/word-10" as module33
@import "word-11" as module34
@import "./word-11" as module35
@import "../sass/word-11" as module36
// Directory/filename
@import 'directory/file' as module37
@import './directory/file' as module38
@import '../sass/directory/file' as module39
@import 'directory-1/file' as module40
@import './directory-1/file' as module41
@import '../sass/directory-1/file' as module42
@import 'directory-2/file' as module43
@import './directory-2/file' as module44
@import '../sass/directory-2/file' as module45
@import 'directory-3/file' as module46
@import './directory-3/file' as module47
@import '../sass/directory-3/file' as module48
@import 'directory-4/file' as module49
@import './directory-4/file' as module50
@import '../sass/directory-4/file' as module51
@import 'directory-5/file' as module52
@import './directory-5/file' as module53
@import '../sass/directory-5/file' as module54
// Directory/filename with `_index` and `index`
@import 'directory-6/file' as module55
@import './directory-6/file' as module56
@import '../sass/directory-6/file' as module57
@import 'directory-7/file' as module58
@import './directory-7/file' as module59
@import '../sass/directory-7/file' as module60
@import 'directory-8/file' as module61
@import './directory-8/file' as module62
@import '../sass/directory-8/file' as module63
@import 'directory-9/file' as module64
@import './directory-9/file' as module65
@import '../sass/directory-9/file' as module66
@import 'directory-10/file' as module67
@import './directory-10/file' as module68
@import '../sass/directory-10/file' as module69
@import 'directory-11/file' as module70
@import './directory-11/file' as module71
@import '../sass/directory-11/file' as module72
23 changes: 23 additions & 0 deletions test/sass/uses.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@use "sass:meta"
/* @use another/module */
@use "another/module"
/* @use another/underscore */
@use "another/underscore" as underscore
/* @use another/_underscore */
@use "another/_underscore" as underscore2
/* @use ~sass/underscore */
@use "~sass/underscore" as underscore3
// Import a module with a dot in its name
// @see https://github.com/webpack-contrib/sass-loader/issues/167
/* @use ~sass/some.module */
@use "~sass/some.module"
// The local util file should take precedence over Node's util module
// See https://github.com/webpack-contrib/sass-loader/issues/556
/* @use util */
@use "util"
/* @use ~module */
@use "~module" as module2
/* @use ~another */
@use "~another" as another
// Should prefer `scss`
@use "~@org/style"
1 change: 1 addition & 0 deletions test/scss/error-file-not-found-use-2.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "./another/_module.scss";
1 change: 1 addition & 0 deletions test/scss/error-file-not-found-use.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "does-not-exist";
1 change: 1 addition & 0 deletions test/scss/error-use.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "error";
1 change: 1 addition & 0 deletions test/scss/use-_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~scss-package-with-underscore-index" as module;
5 changes: 5 additions & 0 deletions test/scss/use-alias.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use 'path-to-alias';
@use "~@scss" as module;
@use "~@path-to-scss-dir/dir-with-underscore-index" as module1;
@use "~@path-to-scss-dir/dir-with-underscore-index/" as module2;
@use "~@/path-to-scss-dir/dir-with-underscore-index" as module3;
3 changes: 3 additions & 0 deletions test/scss/use-bootstrap-sass-package.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@use "~bootstrap-sass" as bootstrap with (
$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/"
);
3 changes: 3 additions & 0 deletions test/scss/use-bootstrap-sass.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@use "~bootstrap-sass/assets/stylesheets/bootstrap" with (
$icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/"
);
1 change: 1 addition & 0 deletions test/scss/use-bootstrap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~bootstrap" as bootstrap;
1 change: 1 addition & 0 deletions test/scss/use-custom-sass-field.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~scss-custom-sass-field" as module;
8 changes: 8 additions & 0 deletions test/scss/use-from-npm-org-pkg.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* @use "~@org/pkg"; */
@use "~@org/pkg";
/* @use "~@org/bar/foo"; */
@use "~@org/bar/foo";

.foo {
background: #000;
}
1 change: 1 addition & 0 deletions test/scss/use-index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~scss-package-with-index" as module;
1 change: 1 addition & 0 deletions test/scss/use-main-field.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~scss-main-field" as module;
4 changes: 4 additions & 0 deletions test/scss/use-other-style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Importing a sass module does not require to set the extension explicitly... */
@use "../sass/another/module" as module1;
/* ...but it is allowed */
@use "../sass/another/module.sass" as module2;
1 change: 1 addition & 0 deletions test/scss/use-sass-field.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~scss-sass-field" as module;
1 change: 1 addition & 0 deletions test/scss/use-style-field.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use "~scss-style-field" as module;
18 changes: 18 additions & 0 deletions test/scss/use-with-extension.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@use "example.scss" as module1;
@use "./example.scss" as module2;
@use "../scss/example.scss" as module3;
// TODO https://github.com/sass/dart-sass/issues/798#issuecomment-521229911
// @use "example-1.SCSS" as module4;
@use "example-2.scss" as module5;
@use "./example-2.scss" as module6;
@use "../scss/example-2.scss" as module7;
// TODO https://github.com/sass/dart-sass/issues/798#issuecomment-521229911
// @use "example-3.SCSS" as module8;
@use "nested/example-4.scss" as module9;
@use "./nested/example-4.scss" as module10;
@use "../scss/nested/example-4.scss" as module11;
@use "nested/example-5.scss" as module12;
@use "./nested/example-5.scss" as module13;
@use "../scss/nested/example-5.scss" as module14;
// TODO https://github.com/sass/dart-sass/issues/798#issuecomment-521229911
// @use "nested/example-6.SCSS" as module15;
Loading

0 comments on commit 185ba80

Please sign in to comment.