diff --git a/README.md b/README.md index 19ceaa14..4f549e94 100644 --- a/README.md +++ b/README.md @@ -109,15 +109,14 @@ module.exports = { ## Options -| Name | Type | Default | Description | -| :-----------------------------------: | :-------------------------: | :------------------------------------------------: | :--------------------------------------------------------------------- | -| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enables/Disables `url`/`image-set` functions handling | -| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enables/Disables `@import` at-rules handling | -| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `{auto: true}` | Enables/Disables CSS Modules and their configuration | -| **[`icss`](#icss)** | `{Boolean}` | `true` if `modules` are enabled, `false` otherwise | Enables/Disables Interoperable CSS | -| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps | -| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Enables/Disables or setups number of loaders applied before CSS loader | -| **[`esModule`](#esmodule)** | `{Boolean}` | `true` | Use ES modules syntax | +| Name | Type | Default | Description | +| :-----------------------------------: | :-------------------------: | :----------------: | :--------------------------------------------------------------------- | +| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enables/Disables `url`/`image-set` functions handling | +| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enables/Disables `@import` at-rules handling | +| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `{auto: true}` | Enables/Disables CSS Modules and their configuration | +| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps | +| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Enables/Disables or setups number of loaders applied before CSS loader | +| **[`esModule`](#esmodule)** | `{Boolean}` | `true` | Use ES modules syntax | ### `url` @@ -526,6 +525,7 @@ module.exports = { loader: 'css-loader', options: { modules: { + compileType: 'module', mode: 'local', auto: true, exportGlobals: true, @@ -543,6 +543,38 @@ module.exports = { }; ``` +##### `compileType` + +Type: `'module' | 'icss'` +Default: `'module'` + +Controls the level of compilation applied to the input styles. + +The `module` handles `class` and `id` scoping and `@value` values. +The `icss` will only compile the low level `Interoperable CSS` format for declaring `:import` and `:export` dependencies between CSS and other languages. + +ICSS underpins CSS Module support, and provides a low level syntax for other tools to implement CSS-module variations of their own. + +**webpack.config.js** + +```js +module.exports = { + module: { + rules: [ + { + test: /\.css$/i, + loader: 'css-loader', + options: { + modules: { + compileType: 'icss', + }, + }, + }, + ], + }, +}; +``` + ##### `auto` Type: `Boolean|RegExp|Function` @@ -1001,33 +1033,6 @@ module.exports = { }; ``` -### `icss` - -Type: Boolean Default: `true` if `modules` are enabled, false otherwise - -Enables/disables handling of the low level "Interoperable CSS" format for declaring -import and export dependencies between CSS and other languages. ICSS enables -CSS Module support, and is enabled automatically when `modules` are enabled. It -can also be enabled independently to allow other loaders to handle processing CSS modules. - -**webpack.config.js** - -```js -module.exports = { - module: { - rules: [ - { - test: /\.css$/i, - loader: 'css-loader', - options: { - icss: true, - }, - }, - ], - }, -}; -``` - ### `sourceMap` Type: `Boolean` diff --git a/src/index.js b/src/index.js index 8aeca76b..b96e3c41 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,7 @@ import { shouldUseModulesPlugins, shouldUseImportPlugin, shouldUseURLPlugin, + shouldUseIcssPlugin, getPreRequester, getExportCode, getFilter, @@ -51,9 +52,7 @@ export default async function loader(content, map, meta) { const replacements = []; const exports = []; - const needUseModulesPlugins = shouldUseModulesPlugins(options); - - if (needUseModulesPlugins) { + if (shouldUseModulesPlugins(options)) { plugins.push(...getModulesPlugins(options, this)); } @@ -112,7 +111,7 @@ export default async function loader(content, map, meta) { const icssPluginImports = []; const icssPluginApi = []; - if (needUseModulesPlugins || options.icss) { + if (shouldUseIcssPlugin(options)) { const icssResolver = this.getResolve({ conditionNames: ['style'], extensions: [], diff --git a/src/options.json b/src/options.json index a7703f3f..cfaf8eee 100644 --- a/src/options.json +++ b/src/options.json @@ -36,6 +36,10 @@ "type": "object", "additionalProperties": false, "properties": { + "compileType": { + "description": "Controls the extent to which css-loader will process module code (https://github.com/webpack-contrib/css-loader#type)", + "enum": ["module", "icss"] + }, "auto": { "description": "Allows auto enable CSS modules based on filename (https://github.com/webpack-contrib/css-loader#auto).", "anyOf": [ diff --git a/src/utils.js b/src/utils.js index eadecc60..7988ab89 100644 --- a/src/utils.js +++ b/src/utils.js @@ -125,6 +125,7 @@ function getModulesOptions(rawOptions, loaderContext) { } let modulesOptions = { + compileType: rawOptions.icss ? 'icss' : 'module', auto: true, mode: 'local', exportGlobals: false, @@ -201,12 +202,22 @@ function getModulesOptions(rawOptions, loaderContext) { } function normalizeOptions(rawOptions, loaderContext) { + if (rawOptions.icss) { + loaderContext.emitWarning( + new Error( + 'The "icss" option is deprecated, use "modules.compileType: "icss"" instead' + ) + ); + } + const modulesOptions = getModulesOptions(rawOptions, loaderContext); + return { url: typeof rawOptions.url === 'undefined' ? true : rawOptions.url, import: typeof rawOptions.import === 'undefined' ? true : rawOptions.import, modules: modulesOptions, - icss: modulesOptions ? true : rawOptions.icss, + // TODO remove in the next major release + icss: typeof rawOptions.icss === 'undefined' ? false : rawOptions.icss, sourceMap: typeof rawOptions.sourceMap === 'boolean' ? rawOptions.sourceMap @@ -242,7 +253,11 @@ function shouldUseURLPlugin(options) { } function shouldUseModulesPlugins(options) { - return Boolean(options.modules); + return options.modules.compileType === 'module'; +} + +function shouldUseIcssPlugin(options) { + return options.icss === true || Boolean(options.modules); } function getModulesPlugins(options, loaderContext) { @@ -545,6 +560,7 @@ export { shouldUseModulesPlugins, shouldUseImportPlugin, shouldUseURLPlugin, + shouldUseIcssPlugin, normalizeUrl, requestify, getFilter, diff --git a/test/__snapshots__/icss.test.js.snap b/test/__snapshots__/icss.test.js.snap deleted file mode 100644 index d7dd69c6..00000000 --- a/test/__snapshots__/icss.test.js.snap +++ /dev/null @@ -1,313 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ICSS show work with the case "duplicate-export": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "duplicate-export": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"_test\\": \\"_right_value\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "duplicate-export": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/duplicate-export/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "duplicate-export": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "duplicate-export-in-multiple-export": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "duplicate-export-in-multiple-export": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"_test\\": \\"_right_value\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "duplicate-export-in-multiple-export": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/duplicate-export-in-multiple-export/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "duplicate-export-in-multiple-export": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "empty-export": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "empty-export": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "empty-export": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/empty-export/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "empty-export": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "empty-import": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "empty-import": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "empty-import": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/empty-import/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "empty-import": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "export": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "export": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"_test\\": \\"_test\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "export": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/export/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "export": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "export-reserved-keywords": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "export-reserved-keywords": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"constructor\\": \\"constructor\\", - \\"toString\\": \\"toString\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "export-reserved-keywords": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/export-reserved-keywords/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "export-reserved-keywords": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "import": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "import": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../src/index.js??[ident]!./vars.css\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "import": result 1`] = ` -Array [ - Array [ - "../../src/index.js?[ident]!./icss/tests-cases/import/vars.css", - " -", - "", - ], - Array [ - "./icss/tests-cases/import/source.css", - ".className { - color: red; -} -", - "", - ], -] -`; - -exports[`ICSS show work with the case "import": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "import-reserved-keywords": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "import-reserved-keywords": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../src/index.js??[ident]!./vars.css\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n display: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\", - \\"secondary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\"\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "import-reserved-keywords": result 1`] = ` -Array [ - Array [ - "../../src/index.js?[ident]!./icss/tests-cases/import-reserved-keywords/vars.css", - " -", - "", - ], - Array [ - "./icss/tests-cases/import-reserved-keywords/source.css", - ".className { - color: red; - display: block; -} -", - "", - ], -] -`; - -exports[`ICSS show work with the case "import-reserved-keywords": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "multiple-export": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "multiple-export": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"_test\\": \\"_test\\", - \\"_foo\\": \\"_bar\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "multiple-export": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/multiple-export/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "multiple-export": warnings 1`] = `Array []`; - -exports[`ICSS show work with the case "multiple-keys-values-in-export": errors 1`] = `Array []`; - -exports[`ICSS show work with the case "multiple-keys-values-in-export": module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); -// Exports -___CSS_LOADER_EXPORT___.locals = { - \\"_test\\": \\"_test\\", - \\"_test1\\": \\"1\\", - \\"_test2\\": \\"'string'\\", - \\"_test3\\": \\"1px 2px 3px\\", - \\"_test4\\": \\"1px 2px 3px, 1px 2px 3px\\" -}; -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`ICSS show work with the case "multiple-keys-values-in-export": result 1`] = ` -Array [ - Array [ - "./icss/tests-cases/multiple-keys-values-in-export/source.css", - " -", - "", - ], -] -`; - -exports[`ICSS show work with the case "multiple-keys-values-in-export": warnings 1`] = `Array []`; diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index 353654e5..f64fdcd5 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -12304,3 +12304,703 @@ Array [ `; exports[`"modules" option should work with the \`exportGlobals\` option (the \`mode\` option is \`pure\`): warnings 1`] = `Array []`; + +exports[`"modules" option show work and warn about the "icss" option deprecation: errors 1`] = `Array []`; + +exports[`"modules" option show work and warn about the "icss" option deprecation: module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../../src/index.js??[ident]!./vars.css\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work and warn about the "icss" option deprecation: result 1`] = ` +Array [ + Array [ + "../../src/index.js?[ident]!./modules/icss/tests-cases/import/vars.css", + " +", + "", + ], + Array [ + "./modules/icss/tests-cases/import/source.css", + ".className { + color: red; +} +", + "", + ], +] +`; + +exports[`"modules" option show work and warn about the "icss" option deprecation: warnings 1`] = ` +Array [ + "ModuleWarning: Module Warning (from \`replaced original path\`): +The \\"icss\\" option is deprecated, use \\"modules.compileType: \\"icss\\"\\" instead", + "ModuleWarning: Module Warning (from \`replaced original path\`): +The \\"icss\\" option is deprecated, use \\"modules.compileType: \\"icss\\"\\" instead", +] +`; + +exports[`"modules" option show work with the "compileType" and "exportOnlyLocals" options: errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" and "exportOnlyLocals" options: module 1`] = ` +"// Imports +import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../../src/index.js??[ident]!./vars.css\\"; +var ___CSS_LOADER_EXPORT___ = {}; +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" and "exportOnlyLocals" options: result 1`] = ` +Object { + "locals": Object { + "primary-color": "red", + }, +} +`; + +exports[`"modules" option show work with the "compileType" and "exportOnlyLocals" options: warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" and "namedExport" options: errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" and "namedExport" options: module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +import ___CSS_LOADER_ICSS_IMPORT_0___, * as ___CSS_LOADER_ICSS_IMPORT_0____NAMED___ from \\"-!../../../../../../src/index.js??[ident]!./vars.css\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0____NAMED___[\\"primaryColor\\"] + \\";\\\\n}\\\\n\\", \\"\\"]); +// Exports +export const primaryColor = \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0____NAMED___[\\"primaryColor\\"] + \\"\\"; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" and "namedExport" options: result 1`] = ` +Array [ + Array [ + "../../src/index.js?[ident]!./modules/icss/tests-cases/import/vars.css", + " +", + "", + ], + Array [ + "./modules/icss/tests-cases/import/source.css", + ".className { + color: red; +} +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" and "namedExport" options: warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option using the "module" value: errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option using the "module" value: module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\"; +import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../src/index.js??[ident]!./values.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_1___ from \\"-!../../../../src/index.js??[ident]!./something.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_2___ from \\"-!../../../../src/index.js??[ident]!./imported-simple.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_3___ from \\"-!../../../../src/index.js??[ident]!./relative.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_4___ from \\"-!../../../../src/index.js??[ident]!./top-relative.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_5___ from \\"-!../../../../src/index.js??[ident]!../issue-861/node_modules/package/style.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_6___ from \\"-!../../../../src/index.js??[ident]!./alias.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_7___ from \\"-!../../../../src/index.js??[ident]!./scss-file.scss\\"; +import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../../src/index.js??[ident]!./test-other.css\\"; +import ___CSS_LOADER_GET_URL_IMPORT___ from \\"../../../../src/runtime/getUrl.js\\"; +import ___CSS_LOADER_URL_IMPORT_0___ from \\"../../url/img.png\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___, \\"(min-width: 100px)\\"); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_1___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_2___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_3___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_4___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_5___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_6___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_7___, \\"\\", true); +var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"._2ZmR2b3YBVn0i8sme-abcC {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-def\\"] + \\";\\\\n}\\\\n\\\\n._3dxIylSbTBEe450DFBxy5D {\\\\n color: blue;\\\\n}\\\\n\\\\n.EcQSwQce4PuQ5vNAybT9N {\\\\n display: block;\\\\n}\\\\n\\\\n.hTH4alr_d-S0jPncN6ib3 {\\\\n width: \\" + ___CSS_LOADER_ICSS_IMPORT_1___.locals[\\"v-something\\"] + \\";\\\\n}\\\\n\\\\n._7sobwviowI6_CZkzLjYZG {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-other\\"] + \\";\\\\n}\\\\n\\\\n.YpDepip9R1BGGAy-rGgvc {\\\\n prop: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-def\\"] + \\";\\\\n duplicate: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-other\\"] + \\";\\\\n}\\\\n\\\\n._3dfrN27nghAjb3tcT6R_Ov {\\\\n color: red;\\\\n}\\\\n\\\\n._3aPunKIij5oyAtcB6y9-Xm {\\\\n color: yellow;\\\\n}\\\\n\\\\n._3Qp0o615k38gm2l4OVRknw {\\\\n color: gray;\\\\n}\\\\n\\\\n._2Zsff12VKF2NbAGVE1sdzC {\\\\n color: gray;\\\\n}\\\\n\\\\n._3itMfHbLQSSkBisENyA8TF {\\\\n color: gainsboro;\\\\n}\\\\n\\\\n._2ChGydqcGYRLzAo3_Iomr2 {\\\\n color: gainsboro;\\\\n}\\\\n\\\\n._1ai7yu9kkZ_8JwK0EMbe6U {\\\\n color: #BF4040;\\\\n}\\\\n\\\\n.OX01CBO1Ma7xJh6yAybXq {\\\\n color: black;\\\\n}\\\\n\\\\n@media (min-width: 960px) {\\\\n ._2Yk-wvfy8t_ESEwwB1Fc0y {\\\\n padding: 0 20px;\\\\n }\\\\n}\\\\n\\\\n.\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"s-white\\"] + \\" {\\\\n color: white;\\\\n}\\\\n\\\\n@media \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"m-small\\"] + \\" {\\\\n ._2Yk-wvfy8t_ESEwwB1Fc0y {\\\\n padding: 20px 20px;\\\\n }\\\\n}\\\\n@value v-comment: /* comment */;\\\\n\\\\n._2PhbElc8FsODw7KMuxWJyk {\\\\n v-ident: validIdent;\\\\n v-pre-defined-ident: left;\\\\n v-string: 'content';\\\\n v-string-1: '';\\\\n v-url: url(https://www.exammple.com/images/my-background.png);\\\\n v-url-1: url('https://www.exammple.com/images/my-background.png');\\\\n v-url-2: url(\\\\\\"https://www.exammple.com/images/my-background.png\\\\\\");\\\\n v-integer: 100;\\\\n v-integer-1: -100;\\\\n v-integer-2: +100;\\\\n v-number: .60;\\\\n v-number-1: -456.8;\\\\n v-number-2: -3.4e-2;\\\\n v-dimension: 12px;\\\\n v-percentage: 100%;\\\\n v-hex: #fff;\\\\n v-comment: v-comment 10px v-comment;\\\\n v-function: rgb(0,0,0);\\\\n v-unicode-range: U+0025-00FF;\\\\n mutliple: #fff .60 100%;\\\\n}\\\\n\\\\n\\\\na {\\\\n content: 'content';\\\\n}\\\\n\\\\n@supports (content: 'content') {\\\\n a {\\\\n content: 'content';\\\\n }\\\\n}\\\\n\\\\n[class~='content'] {\\\\n color:green;\\\\n}\\\\n\\\\n._1qvhWcgsRpzv9-_jaooxI0 {\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\\\n._1-QX-dLNLF1zFn-cPfLHcH {\\\\n background: red;\\\\n}\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"v-def\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-def\\"] + \\"\\", + \\"v-other\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"v-other\\"] + \\"\\", + \\"s-white\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"s-white\\"] + \\"\\", + \\"m-small\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"m-small\\"] + \\"\\", + \\"v-something\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_1___.locals[\\"v-something\\"] + \\"\\", + \\"v-foo\\": \\"blue\\", + \\"v-bar\\": \\"block\\", + \\"v-primary\\": \\"#BF4040\\", + \\"s-black\\": \\"black-selector\\", + \\"m-large\\": \\"(min-width: 960px)\\", + \\"v-ident\\": \\"validIdent\\", + \\"v-pre-defined-ident\\": \\"left\\", + \\"v-string\\": \\"'content'\\", + \\"v-string-1\\": \\"''\\", + \\"v-url\\": \\"url(https://www.exammple.com/images/my-background.png)\\", + \\"v-url-1\\": \\"url('https://www.exammple.com/images/my-background.png')\\", + \\"v-url-2\\": \\"url(\\\\\\"https://www.exammple.com/images/my-background.png\\\\\\")\\", + \\"v-integer\\": \\"100\\", + \\"v-integer-1\\": \\"-100\\", + \\"v-integer-2\\": \\"+100\\", + \\"v-number\\": \\".60\\", + \\"v-number-1\\": \\"-456.8\\", + \\"v-number-2\\": \\"-3.4e-2\\", + \\"v-dimension\\": \\"12px\\", + \\"v-percentage\\": \\"100%\\", + \\"v-hex\\": \\"#fff\\", + \\"v-function\\": \\"rgb(0,0,0)\\", + \\"v-unicode-range\\": \\"U+0025-00FF\\", + \\"ghi\\": \\"_2ZmR2b3YBVn0i8sme-abcC\\", + \\"class\\": \\"_3dxIylSbTBEe450DFBxy5D\\", + \\"other\\": \\"EcQSwQce4PuQ5vNAybT9N\\", + \\"other-other\\": \\"hTH4alr_d-S0jPncN6ib3\\", + \\"green\\": \\"_7sobwviowI6_CZkzLjYZG\\", + \\"foo\\": \\"YpDepip9R1BGGAy-rGgvc\\", + \\"simple\\": \\"_3dfrN27nghAjb3tcT6R_Ov \\" + ___CSS_LOADER_ICSS_IMPORT_2___.locals[\\"imported-simple\\"] + \\"\\", + \\"relative\\": \\"_3aPunKIij5oyAtcB6y9-Xm \\" + ___CSS_LOADER_ICSS_IMPORT_3___.locals[\\"imported-relative\\"] + \\"\\", + \\"top-relative\\": \\"_3Qp0o615k38gm2l4OVRknw \\" + ___CSS_LOADER_ICSS_IMPORT_4___.locals[\\"imported-relative\\"] + \\"\\", + \\"module\\": \\"_2Zsff12VKF2NbAGVE1sdzC \\" + ___CSS_LOADER_ICSS_IMPORT_5___.locals[\\"imported-module\\"] + \\"\\", + \\"alias\\": \\"_3itMfHbLQSSkBisENyA8TF \\" + ___CSS_LOADER_ICSS_IMPORT_6___.locals[\\"imported-alias\\"] + \\"\\", + \\"alias-duplicate\\": \\"_2ChGydqcGYRLzAo3_Iomr2 \\" + ___CSS_LOADER_ICSS_IMPORT_6___.locals[\\"imported-alias\\"] + \\"\\", + \\"primary-selector\\": \\"_1ai7yu9kkZ_8JwK0EMbe6U\\", + \\"black-selector\\": \\"OX01CBO1Ma7xJh6yAybXq\\", + \\"header\\": \\"_2Yk-wvfy8t_ESEwwB1Fc0y\\", + \\"foobarbaz\\": \\"_2PhbElc8FsODw7KMuxWJyk\\", + \\"url\\": \\"_1qvhWcgsRpzv9-_jaooxI0\\", + \\"main\\": \\"_1-QX-dLNLF1zFn-cPfLHcH \\" + ___CSS_LOADER_ICSS_IMPORT_7___.locals[\\"scssClass\\"] + \\"\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option using the "module" value: result 1`] = ` +Array [ + Array [ + "../../src/index.js?[ident]!./modules/composes/test-other.css", + "._24axXNO_oC23T0D0YAz-0Y { + d: d; +} +", + "(min-width: 100px)", + ], + Array [ + "../../src/index.js?[ident]!./modules/composes/values.css", + " +", + "", + ], + Array [ + "../../src/index.js?[ident]!./modules/composes/something.css", + " +", + "", + ], + Array [ + "../../src/index.js?[ident]!./modules/composes/imported-simple.css", + "._1LcKtmpK51ikm2OTXu6tSg { + display: block; +} +", + "", + ], + Array [ + "../../src/index.js?[ident]!./modules/composes/relative.css", + "._1bYd-W6Pwrt_8yXpE4FBEu { + display: inline; +} +", + "", + ], + Array [ + "../../src/index.js?[ident]!./modules/composes/top-relative.css", + "._2RvZm_IQCQC3YXopKglSUM { + display: flex; +} +", + "", + ], + Array [ + "../../src/index.js?[ident]!./modules/issue-861/node_modules/package/style.css", + "._2212NWEpBgAjfmZAD6jJwU { + display: inline-block; +} +", + "", + ], + Array [ + "../../src/index.js?[ident]!./modules/composes/alias.css", + ".gASNE59vLxrkyu1XPoUrX { + display: table; +} +", + "", + ], + Array [ + "../../src/index.js?[ident]!./modules/composes/scss-file.scss", + "._14lUoCryZnM4Rrkm49iWuC { + color: red; + padding: 15px; +}", + "", + ], + Array [ + "./modules/composes/composes.css", + "._2ZmR2b3YBVn0i8sme-abcC { + color: red; +} + +._3dxIylSbTBEe450DFBxy5D { + color: blue; +} + +.EcQSwQce4PuQ5vNAybT9N { + display: block; +} + +.hTH4alr_d-S0jPncN6ib3 { + width: 2112moon; +} + +._7sobwviowI6_CZkzLjYZG { + color: green; +} + +.YpDepip9R1BGGAy-rGgvc { + prop: red; + duplicate: green; +} + +._3dfrN27nghAjb3tcT6R_Ov { + color: red; +} + +._3aPunKIij5oyAtcB6y9-Xm { + color: yellow; +} + +._3Qp0o615k38gm2l4OVRknw { + color: gray; +} + +._2Zsff12VKF2NbAGVE1sdzC { + color: gray; +} + +._3itMfHbLQSSkBisENyA8TF { + color: gainsboro; +} + +._2ChGydqcGYRLzAo3_Iomr2 { + color: gainsboro; +} + +._1ai7yu9kkZ_8JwK0EMbe6U { + color: #BF4040; +} + +.OX01CBO1Ma7xJh6yAybXq { + color: black; +} + +@media (min-width: 960px) { + ._2Yk-wvfy8t_ESEwwB1Fc0y { + padding: 0 20px; + } +} + +.white { + color: white; +} + +@media (min-width: 320px) { + ._2Yk-wvfy8t_ESEwwB1Fc0y { + padding: 20px 20px; + } +} +@value v-comment: /* comment */; + +._2PhbElc8FsODw7KMuxWJyk { + v-ident: validIdent; + v-pre-defined-ident: left; + v-string: 'content'; + v-string-1: ''; + v-url: url(https://www.exammple.com/images/my-background.png); + v-url-1: url('https://www.exammple.com/images/my-background.png'); + v-url-2: url(\\"https://www.exammple.com/images/my-background.png\\"); + v-integer: 100; + v-integer-1: -100; + v-integer-2: +100; + v-number: .60; + v-number-1: -456.8; + v-number-2: -3.4e-2; + v-dimension: 12px; + v-percentage: 100%; + v-hex: #fff; + v-comment: v-comment 10px v-comment; + v-function: rgb(0,0,0); + v-unicode-range: U+0025-00FF; + mutliple: #fff .60 100%; +} + + +a { + content: 'content'; +} + +@supports (content: 'content') { + a { + content: 'content'; + } +} + +[class~='content'] { + color:green; +} + +._1qvhWcgsRpzv9-_jaooxI0 { + background: url(/webpack/public/path/img.png); +} + +._1-QX-dLNLF1zFn-cPfLHcH { + background: red; +} +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option using the "module" value: warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"_test\\": \\"_right_value\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/duplicate-export/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export-in-multiple-export": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export-in-multiple-export": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"_test\\": \\"_right_value\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export-in-multiple-export": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/duplicate-export-in-multiple-export/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "duplicate-export-in-multiple-export": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "empty-export": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "empty-export": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "empty-export": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/empty-export/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "empty-export": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "empty-import": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "empty-import": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "empty-import": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/empty-import/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "empty-import": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "export": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "export": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"_test\\": \\"_test\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "export": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/export/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "export": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "export-reserved-keywords": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "export-reserved-keywords": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"constructor\\": \\"constructor\\", + \\"toString\\": \\"toString\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "export-reserved-keywords": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/export-reserved-keywords/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "export-reserved-keywords": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "import": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "import": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../../src/index.js??[ident]!./vars.css\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "import": result 1`] = ` +Array [ + Array [ + "../../src/index.js?[ident]!./modules/icss/tests-cases/import/vars.css", + " +", + "", + ], + Array [ + "./modules/icss/tests-cases/import/source.css", + ".className { + color: red; +} +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "import": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "import-reserved-keywords": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "import-reserved-keywords": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../../src/index.js??[ident]!./vars.css\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n display: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\", + \\"secondary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\"\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "import-reserved-keywords": result 1`] = ` +Array [ + Array [ + "../../src/index.js?[ident]!./modules/icss/tests-cases/import-reserved-keywords/vars.css", + " +", + "", + ], + Array [ + "./modules/icss/tests-cases/import-reserved-keywords/source.css", + ".className { + color: red; + display: block; +} +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "import-reserved-keywords": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-export": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-export": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"_test\\": \\"_test\\", + \\"_foo\\": \\"_bar\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-export": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/multiple-export/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-export": warnings 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-keys-values-in-export": errors 1`] = `Array []`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-keys-values-in-export": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../../src/runtime/api.js\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"_test\\": \\"_test\\", + \\"_test1\\": \\"1\\", + \\"_test2\\": \\"'string'\\", + \\"_test3\\": \\"1px 2px 3px\\", + \\"_test4\\": \\"1px 2px 3px, 1px 2px 3px\\" +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-keys-values-in-export": result 1`] = ` +Array [ + Array [ + "./modules/icss/tests-cases/multiple-keys-values-in-export/source.css", + " +", + "", + ], +] +`; + +exports[`"modules" option show work with the "compileType" option, case "multiple-keys-values-in-export": warnings 1`] = `Array []`; diff --git a/test/__snapshots__/validate-options.test.js.snap b/test/__snapshots__/validate-options.test.js.snap index fb725763..489d9fd1 100644 --- a/test/__snapshots__/validate-options.test.js.snap +++ b/test/__snapshots__/validate-options.test.js.snap @@ -51,7 +51,7 @@ exports[`validate options should throw an error on the "importLoaders" option wi exports[`validate options should throw an error on the "modules" option with "{"auto":"invalid"}" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.auto should be one of these: @@ -63,6 +63,13 @@ exports[`validate options should throw an error on the "modules" option with "{" * options.modules.auto should be a boolean." `; +exports[`validate options should throw an error on the "modules" option with "{"compileType":"unknown"}" value 1`] = ` +"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. + - options.modules.compileType should be one of these: + \\"module\\" | \\"icss\\" + -> Controls the extent to which css-loader will process module code (https://github.com/webpack-contrib/css-loader#type)" +`; + exports[`validate options should throw an error on the "modules" option with "{"exportGlobals":"invalid"}" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules.exportGlobals should be a boolean. @@ -109,7 +116,7 @@ exports[`validate options should throw an error on the "modules" option with "{" exports[`validate options should throw an error on the "modules" option with "{"localIdentRegExp":true}" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.localIdentRegExp should be one of these: @@ -123,7 +130,7 @@ exports[`validate options should throw an error on the "modules" option with "{" exports[`validate options should throw an error on the "modules" option with "{"mode":"globals"}" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: @@ -138,7 +145,7 @@ exports[`validate options should throw an error on the "modules" option with "{" exports[`validate options should throw an error on the "modules" option with "{"mode":"locals"}" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: @@ -153,7 +160,7 @@ exports[`validate options should throw an error on the "modules" option with "{" exports[`validate options should throw an error on the "modules" option with "{"mode":"pures"}" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: @@ -168,7 +175,7 @@ exports[`validate options should throw an error on the "modules" option with "{" exports[`validate options should throw an error on the "modules" option with "{"mode":true}" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: @@ -189,53 +196,53 @@ exports[`validate options should throw an error on the "modules" option with "{" exports[`validate options should throw an error on the "modules" option with "globals" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" * options.modules should be an object: - object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" + object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" `; exports[`validate options should throw an error on the "modules" option with "locals" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" * options.modules should be an object: - object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" + object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" `; exports[`validate options should throw an error on the "modules" option with "pures" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" * options.modules should be an object: - object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" + object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" `; exports[`validate options should throw an error on the "modules" option with "true" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: - boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } + boolean | \\"local\\" | \\"global\\" | \\"pure\\" | object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" * options.modules should be an object: - object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" + object { compileType?, auto?, mode?, localIdentName?, localIdentContext?, localIdentHashPrefix?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }" `; exports[`validate options should throw an error on the "sourceMap" option with "true" value 1`] = ` diff --git a/test/fixtures/icss/tests-cases/duplicate-export-in-multiple-export/source.css b/test/fixtures/modules/icss/tests-cases/duplicate-export-in-multiple-export/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/duplicate-export-in-multiple-export/source.css rename to test/fixtures/modules/icss/tests-cases/duplicate-export-in-multiple-export/source.css diff --git a/test/fixtures/icss/tests-cases/duplicate-export-in-multiple-export/source.js b/test/fixtures/modules/icss/tests-cases/duplicate-export-in-multiple-export/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/duplicate-export-in-multiple-export/source.js rename to test/fixtures/modules/icss/tests-cases/duplicate-export-in-multiple-export/source.js diff --git a/test/fixtures/icss/tests-cases/duplicate-export/source.css b/test/fixtures/modules/icss/tests-cases/duplicate-export/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/duplicate-export/source.css rename to test/fixtures/modules/icss/tests-cases/duplicate-export/source.css diff --git a/test/fixtures/icss/tests-cases/duplicate-export/source.js b/test/fixtures/modules/icss/tests-cases/duplicate-export/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/duplicate-export/source.js rename to test/fixtures/modules/icss/tests-cases/duplicate-export/source.js diff --git a/test/fixtures/icss/tests-cases/empty-export/source.css b/test/fixtures/modules/icss/tests-cases/empty-export/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/empty-export/source.css rename to test/fixtures/modules/icss/tests-cases/empty-export/source.css diff --git a/test/fixtures/icss/tests-cases/empty-export/source.js b/test/fixtures/modules/icss/tests-cases/empty-export/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/empty-export/source.js rename to test/fixtures/modules/icss/tests-cases/empty-export/source.js diff --git a/test/fixtures/icss/tests-cases/empty-import/source.css b/test/fixtures/modules/icss/tests-cases/empty-import/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/empty-import/source.css rename to test/fixtures/modules/icss/tests-cases/empty-import/source.css diff --git a/test/fixtures/icss/tests-cases/empty-import/source.js b/test/fixtures/modules/icss/tests-cases/empty-import/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/empty-import/source.js rename to test/fixtures/modules/icss/tests-cases/empty-import/source.js diff --git a/test/fixtures/icss/tests-cases/export-reserved-keywords/source.css b/test/fixtures/modules/icss/tests-cases/export-reserved-keywords/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/export-reserved-keywords/source.css rename to test/fixtures/modules/icss/tests-cases/export-reserved-keywords/source.css diff --git a/test/fixtures/icss/tests-cases/export-reserved-keywords/source.js b/test/fixtures/modules/icss/tests-cases/export-reserved-keywords/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/export-reserved-keywords/source.js rename to test/fixtures/modules/icss/tests-cases/export-reserved-keywords/source.js diff --git a/test/fixtures/icss/tests-cases/export/source.css b/test/fixtures/modules/icss/tests-cases/export/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/export/source.css rename to test/fixtures/modules/icss/tests-cases/export/source.css diff --git a/test/fixtures/icss/tests-cases/export/source.js b/test/fixtures/modules/icss/tests-cases/export/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/export/source.js rename to test/fixtures/modules/icss/tests-cases/export/source.js diff --git a/test/fixtures/icss/tests-cases/import-reserved-keywords/source.css b/test/fixtures/modules/icss/tests-cases/import-reserved-keywords/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/import-reserved-keywords/source.css rename to test/fixtures/modules/icss/tests-cases/import-reserved-keywords/source.css diff --git a/test/fixtures/icss/tests-cases/import-reserved-keywords/source.js b/test/fixtures/modules/icss/tests-cases/import-reserved-keywords/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/import-reserved-keywords/source.js rename to test/fixtures/modules/icss/tests-cases/import-reserved-keywords/source.js diff --git a/test/fixtures/icss/tests-cases/import-reserved-keywords/vars.css b/test/fixtures/modules/icss/tests-cases/import-reserved-keywords/vars.css similarity index 100% rename from test/fixtures/icss/tests-cases/import-reserved-keywords/vars.css rename to test/fixtures/modules/icss/tests-cases/import-reserved-keywords/vars.css diff --git a/test/fixtures/icss/tests-cases/import/source.css b/test/fixtures/modules/icss/tests-cases/import/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/import/source.css rename to test/fixtures/modules/icss/tests-cases/import/source.css diff --git a/test/fixtures/icss/tests-cases/import/source.js b/test/fixtures/modules/icss/tests-cases/import/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/import/source.js rename to test/fixtures/modules/icss/tests-cases/import/source.js diff --git a/test/fixtures/icss/tests-cases/import/vars.css b/test/fixtures/modules/icss/tests-cases/import/vars.css similarity index 100% rename from test/fixtures/icss/tests-cases/import/vars.css rename to test/fixtures/modules/icss/tests-cases/import/vars.css diff --git a/test/fixtures/icss/tests-cases/multiple-export/source.css b/test/fixtures/modules/icss/tests-cases/multiple-export/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/multiple-export/source.css rename to test/fixtures/modules/icss/tests-cases/multiple-export/source.css diff --git a/test/fixtures/icss/tests-cases/multiple-export/source.js b/test/fixtures/modules/icss/tests-cases/multiple-export/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/multiple-export/source.js rename to test/fixtures/modules/icss/tests-cases/multiple-export/source.js diff --git a/test/fixtures/icss/tests-cases/multiple-keys-values-in-export/source.css b/test/fixtures/modules/icss/tests-cases/multiple-keys-values-in-export/source.css similarity index 100% rename from test/fixtures/icss/tests-cases/multiple-keys-values-in-export/source.css rename to test/fixtures/modules/icss/tests-cases/multiple-keys-values-in-export/source.css diff --git a/test/fixtures/icss/tests-cases/multiple-keys-values-in-export/source.js b/test/fixtures/modules/icss/tests-cases/multiple-keys-values-in-export/source.js similarity index 100% rename from test/fixtures/icss/tests-cases/multiple-keys-values-in-export/source.js rename to test/fixtures/modules/icss/tests-cases/multiple-keys-values-in-export/source.js diff --git a/test/icss.test.js b/test/icss.test.js deleted file mode 100644 index ff1ba97f..00000000 --- a/test/icss.test.js +++ /dev/null @@ -1,35 +0,0 @@ -import path from 'path'; -import fs from 'fs'; - -import { - compile, - getCompiler, - getErrors, - getExecutedCode, - getModuleSource, - getWarnings, -} from './helpers/index'; - -const testCasesPath = path.join(__dirname, 'fixtures/icss/tests-cases'); -const testCases = fs.readdirSync(testCasesPath); - -describe('ICSS', () => { - testCases.forEach((name) => { - it(`show work with the case "${name}"`, async () => { - const compiler = getCompiler(`./icss/tests-cases/${name}/source.js`, { - modules: false, - icss: true, - }); - const stats = await compile(compiler); - - expect( - getModuleSource(`./icss/tests-cases/${name}/source.css`, stats) - ).toMatchSnapshot('module'); - expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); - }); - }); -}); diff --git a/test/modules-option.test.js b/test/modules-option.test.js index cf0e8074..a9883efd 100644 --- a/test/modules-option.test.js +++ b/test/modules-option.test.js @@ -1166,4 +1166,114 @@ describe('"modules" option', () => { expect(getWarnings(stats)).toMatchSnapshot('warnings'); expect(getErrors(stats)).toMatchSnapshot('errors'); }); + + const icssTestCasesPath = path.join( + __dirname, + 'fixtures/modules/icss/tests-cases' + ); + const icssTestCases = fs.readdirSync(icssTestCasesPath); + + icssTestCases.forEach((name) => { + it(`show work with the "compileType" option, case "${name}"`, async () => { + const compiler = getCompiler( + `./modules/icss/tests-cases/${name}/source.js`, + { + modules: { + compileType: 'icss', + }, + } + ); + const stats = await compile(compiler); + + expect( + getModuleSource(`./modules/icss/tests-cases/${name}/source.css`, stats) + ).toMatchSnapshot('module'); + expect( + getExecutedCode('main.bundle.js', compiler, stats) + ).toMatchSnapshot('result'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + }); + + it('show work and warn about the "icss" option deprecation', async () => { + const compiler = getCompiler( + './modules/icss/tests-cases/import/source.js', + { + icss: true, + } + ); + const stats = await compile(compiler); + + expect( + getModuleSource('./modules/icss/tests-cases/import/source.css', stats) + ).toMatchSnapshot('module'); + expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( + 'result' + ); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + + it('show work with the "compileType" and "exportOnlyLocals" options', async () => { + const compiler = getCompiler( + './modules/icss/tests-cases/import/source.js', + { + modules: { + compileType: 'icss', + exportOnlyLocals: true, + }, + } + ); + const stats = await compile(compiler); + + expect( + getModuleSource('./modules/icss/tests-cases/import/source.css', stats) + ).toMatchSnapshot('module'); + expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( + 'result' + ); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + + it('show work with the "compileType" and "namedExport" options', async () => { + const compiler = getCompiler( + './modules/icss/tests-cases/import/source.js', + { + modules: { + compileType: 'icss', + namedExport: true, + }, + } + ); + const stats = await compile(compiler); + + expect( + getModuleSource('./modules/icss/tests-cases/import/source.css', stats) + ).toMatchSnapshot('module'); + expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( + 'result' + ); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + + it('show work with the "compileType" option using the "module" value', async () => { + const compiler = getCompiler('./modules/composes/composes.js', { + modules: { + compileType: 'module', + }, + }); + const stats = await compile(compiler); + + expect( + getModuleSource('./modules/composes/composes.css', stats) + ).toMatchSnapshot('module'); + expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( + 'result' + ); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); }); diff --git a/test/validate-options.test.js b/test/validate-options.test.js index dd95c0a4..aab9c711 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -21,6 +21,8 @@ describe('validate options', () => { 'global', 'local', 'pure', + { compileType: 'module' }, + { compileType: 'icss' }, { mode: 'global' }, { mode: 'local' }, { mode: 'pure' }, @@ -54,6 +56,7 @@ describe('validate options', () => { 'globals', 'locals', 'pures', + { compileType: 'unknown' }, { mode: true }, { mode: 'globals' }, { mode: 'locals' },