From 7ec112011b4db7c8c569442c3dbc0a92075aafdb Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Mon, 8 Apr 2024 18:29:48 +0300 Subject: [PATCH] test: fix --- .../esModule-option.test.js.snap | 108 ++--------- test/__snapshots__/loader.test.js.snap | 170 +++++++++++++++++- test/esModule-option.test.js | 9 + test/fixtures/css-modules-link.js | 15 ++ test/fixtures/css-modules.js | 2 +- test/fixtures/lazy-css-modules.js | 6 +- test/loader.test.js | 5 +- 7 files changed, 213 insertions(+), 102 deletions(-) create mode 100644 test/fixtures/css-modules-link.js diff --git a/test/__snapshots__/esModule-option.test.js.snap b/test/__snapshots__/esModule-option.test.js.snap index f4a125aa..4b2609cf 100644 --- a/test/__snapshots__/esModule-option.test.js.snap +++ b/test/__snapshots__/esModule-option.test.js.snap @@ -4269,14 +4269,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "autoStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "autoStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazyAutoStyleTag": DOM 1`] = ` " @@ -4306,14 +4299,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazyAutoStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazyAutoStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazySingletonStyleTag": DOM 1`] = ` " @@ -4343,14 +4329,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazySingletonStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazySingletonStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazyStyleTag": DOM 1`] = ` " @@ -4380,14 +4359,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazyStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "lazyStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "linkTag": DOM 1`] = ` " @@ -4438,14 +4410,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "singletonStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "singletonStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "styleTag": DOM 1`] = ` " @@ -4472,14 +4437,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "styleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "styleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "autoStyleTag": DOM 1`] = ` " @@ -4506,14 +4464,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "autoStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "autoStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazyAutoStyleTag": DOM 1`] = ` " @@ -4543,14 +4494,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazyAutoStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazyAutoStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazySingletonStyleTag": DOM 1`] = ` " @@ -4580,14 +4524,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazySingletonStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazySingletonStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazyStyleTag": DOM 1`] = ` " @@ -4617,14 +4554,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazyStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "lazyStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "linkTag": DOM 1`] = ` " @@ -4675,14 +4605,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "singletonStyleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "singletonStyleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "styleTag": DOM 1`] = ` " @@ -4709,14 +4632,7 @@ exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader": } `; -exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "styleTag": warnings 1`] = ` -[ - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", - "ModuleDependencyWarning: export 'default' (imported as 'content') was not found in '!!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./es-modules.css' (possible exports: bar, baz, foo)", -] -`; +exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true,"exportOnlyLocals":true}}}, MODULE_TYPE: "es-modules", INJECT_TYPE: "styleTag": warnings 1`] = `[]`; exports[`"esModule" option CONFIG: {"styleLoader":{"esModule":true},"cssLoader":{"esModule":true,"modules":{"namedExport":true}}}, MODULE_TYPE: "commonjs-modules", INJECT_TYPE: "autoStyleTag": DOM 1`] = ` " diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap index 3e062544..904b2afd 100644 --- a/test/__snapshots__/loader.test.js.snap +++ b/test/__snapshots__/loader.test.js.snap @@ -923,6 +923,118 @@ exports[`loader should work when the "injectType" option is "styleTag": errors 1 exports[`loader should work when the "injectType" option is "styleTag": warnings 1`] = `[]`; +exports[`loader should work with css modules when the "injectType" option is "autoStyleTag": DOM 1`] = ` +" + style-loader test + + + +

Body

+
+ + + +
Water
Ground
" +`; + +exports[`loader should work with css modules when the "injectType" option is "autoStyleTag": errors 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "autoStyleTag": warnings 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "lazyAutoStyleTag": DOM 1`] = ` +" + style-loader test + + + +

Body

+
+ + + +
Water
Ground
" +`; + +exports[`loader should work with css modules when the "injectType" option is "lazyAutoStyleTag": errors 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "lazyAutoStyleTag": warnings 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "lazySingletonStyleTag": DOM 1`] = ` +" + style-loader test + + + +

Body

+
+ + + +
Water
Ground
" +`; + +exports[`loader should work with css modules when the "injectType" option is "lazySingletonStyleTag": errors 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "lazySingletonStyleTag": warnings 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "lazyStyleTag": DOM 1`] = ` +" + style-loader test + + + +

Body

+
+ + + +
Water
Ground
" +`; + +exports[`loader should work with css modules when the "injectType" option is "lazyStyleTag": errors 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "lazyStyleTag": warnings 1`] = `[]`; + exports[`loader should work with css modules when the "injectType" option is "linkTag": DOM 1`] = ` " style-loader test @@ -934,13 +1046,69 @@ exports[`loader should work with css modules when the "injectType" option is "li -
Water
Ground
" +
Water
Ground
" `; exports[`loader should work with css modules when the "injectType" option is "linkTag": errors 1`] = `[]`; exports[`loader should work with css modules when the "injectType" option is "linkTag": warnings 1`] = `[]`; +exports[`loader should work with css modules when the "injectType" option is "singletonStyleTag": DOM 1`] = ` +" + style-loader test + + + +

Body

+
+ + + +
Water
Ground
" +`; + +exports[`loader should work with css modules when the "injectType" option is "singletonStyleTag": errors 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "singletonStyleTag": warnings 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "styleTag": DOM 1`] = ` +" + style-loader test + + + +

Body

+
+ + + +
Water
Ground
" +`; + +exports[`loader should work with css modules when the "injectType" option is "styleTag": errors 1`] = `[]`; + +exports[`loader should work with css modules when the "injectType" option is "styleTag": warnings 1`] = `[]`; + exports[`loader should work: DOM 1`] = ` " style-loader test diff --git a/test/esModule-option.test.js b/test/esModule-option.test.js index db5cc28b..8f6dbb0b 100644 --- a/test/esModule-option.test.js +++ b/test/esModule-option.test.js @@ -96,6 +96,15 @@ describe('"esModule" option', () => { {}, { module: { + parser: { + javascript: { + exportsPresence: + esModuleValue.cssLoader.modules && + esModuleValue.cssLoader.modules.exportOnlyLocals + ? false + : "error", + }, + }, rules: [ { test: /\.css$/i, diff --git a/test/fixtures/css-modules-link.js b/test/fixtures/css-modules-link.js new file mode 100644 index 00000000..dbfeff1d --- /dev/null +++ b/test/fixtures/css-modules-link.js @@ -0,0 +1,15 @@ +import './css-modules.css'; + +const node1 = document.createElement("DIV"); +const textNode1 = document.createTextNode("Water"); + +node1.appendChild(textNode1); + +document.body.appendChild(node1); + +const node2 = document.createElement("DIV"); +const textNode2 = document.createTextNode("Ground"); + +node2.appendChild(textNode2); + +document.body.appendChild(node2); diff --git a/test/fixtures/css-modules.js b/test/fixtures/css-modules.js index 1ece0b37..6418e735 100644 --- a/test/fixtures/css-modules.js +++ b/test/fixtures/css-modules.js @@ -1,4 +1,4 @@ -import styles from './css-modules.css'; +import * as styles from './css-modules.css'; const node1 = document.createElement("DIV"); const textNode1 = document.createTextNode("Water"); diff --git a/test/fixtures/lazy-css-modules.js b/test/fixtures/lazy-css-modules.js index feace1f7..4a6474c2 100644 --- a/test/fixtures/lazy-css-modules.js +++ b/test/fixtures/lazy-css-modules.js @@ -1,4 +1,4 @@ -import styles from './css-modules.css'; +import styles, { myClassName, myComposingClass } from './css-modules.css'; styles.use(); @@ -6,7 +6,7 @@ const node1 = document.createElement("DIV"); const textNode1 = document.createTextNode("Water"); node1.appendChild(textNode1); -node1.className = styles.locals.myClassName; +node1.className = myClassName; document.body.appendChild(node1); @@ -14,6 +14,6 @@ const node2 = document.createElement("DIV"); const textNode2 = document.createTextNode("Ground"); node2.appendChild(textNode2); -node2.className = styles.locals.myComposingClass; +node2.className = myComposingClass; document.body.appendChild(node2); diff --git a/test/loader.test.js b/test/loader.test.js index 4ea543fb..b0217867 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -74,7 +74,10 @@ describe("loader", () => { it(`should work with css modules when the "injectType" option is "${injectType}"`, async () => { expect.assertions(3); - const entry = getEntryByInjectType("css-modules.js", injectType); + const entry = getEntryByInjectType( + injectType === "linkTag" ? "css-modules-link.js" : "css-modules.js", + injectType, + ); const compiler = getCompiler( entry, {},