@microsoft/webpack5-load-themed-styles-loader 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- @microsoft/webpack5-load-themed-styles-loader
2
-
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
-
5
- MIT License
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining
8
- a copy of this software and associated documentation files (the
9
- "Software"), to deal in the Software without restriction, including
10
- without limitation the rights to use, copy, modify, merge, publish,
11
- distribute, sublicense, and/or sell copies of the Software, and to
12
- permit persons to whom the Software is furnished to do so, subject to
13
- the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ @microsoft/webpack5-load-themed-styles-loader
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,76 +1,76 @@
1
- # @microsoft/webpack5-load-themed-styles-loader
2
-
3
- ## Installation
4
-
5
- `npm install @microsoft/webpack5-load-themed-styles-loader --save-dev`
6
-
7
- ## Overview
8
-
9
- This simple Webpack loader that wraps the loading of CSS in script equivalent
10
- to `require("@microsoft/load-themed-styles").loadStyles( /* css text */ )`.
11
- It is designed to be a replacement for style-loader.
12
-
13
- ## Usage
14
-
15
- [Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
16
-
17
- This loader is designed to be used in conjunction with css-loader.
18
-
19
- ``` javascript
20
- var css = require("@microsoft/webpack5-load-themed-styles-loader!css!./file.css");
21
- // => returns css code from file.css, uses load-themed-styles to load the CSS on the page.
22
- ```
23
-
24
- ### Example config
25
-
26
- ``` javascript
27
- use: [
28
- {
29
- loader: "@microsoft/webpack5-load-themed-styles-loader", // creates style nodes from JS strings
30
- options: {
31
- async: false
32
- }
33
- },
34
- {
35
- loader: "css-loader", // translates CSS into CommonJS
36
- options: {
37
- modules: true,
38
- importLoaders: 2,
39
- localIdentName: '[name]_[local]_[hash:base64:5]',
40
- minimize: false
41
- }
42
- },
43
- {
44
- loader: 'postcss-loader',
45
- options: {
46
- plugins: function () {
47
- return [
48
- require('autoprefixer')
49
- ];
50
- }
51
- }
52
- },
53
- {
54
- loader: "sass-loader",
55
- }
56
- ]
57
-
58
- ```
59
-
60
- ## Options
61
-
62
- ### `async` (boolean, defaults to `false`)
63
-
64
- By default, `@microsoft/load-themed-styles` loads styles synchronously. This can have adverse performance effects
65
- if many styles are loaded in quick succession. If the `async` option is set to `true`, the `loadStyles` function
66
- is called with the second parameter set to `true`, directing the function to debounce style loading causing fewer
67
- changes to the DOM.
68
-
69
-
70
- ## Links
71
-
72
- - [CHANGELOG.md](
73
- https://github.com/microsoft/rushstack/blob/main/webpack/webpack5-loader-load-themed-styles/CHANGELOG.md) - Find
74
- out what's new in the latest version
75
-
76
- `@microsoft/webpack5-load-themed-styles-loader` is part of the [Rush Stack](https://rushstack.io/) family of projects.
1
+ # @microsoft/webpack5-load-themed-styles-loader
2
+
3
+ ## Installation
4
+
5
+ `npm install @microsoft/webpack5-load-themed-styles-loader --save-dev`
6
+
7
+ ## Overview
8
+
9
+ This simple Webpack loader that wraps the loading of CSS in script equivalent
10
+ to `require("@microsoft/load-themed-styles").loadStyles( /* css text */ )`.
11
+ It is designed to be a replacement for style-loader.
12
+
13
+ ## Usage
14
+
15
+ [Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
16
+
17
+ This loader is designed to be used in conjunction with css-loader.
18
+
19
+ ``` javascript
20
+ var css = require("@microsoft/webpack5-load-themed-styles-loader!css!./file.css");
21
+ // => returns css code from file.css, uses load-themed-styles to load the CSS on the page.
22
+ ```
23
+
24
+ ### Example config
25
+
26
+ ``` javascript
27
+ use: [
28
+ {
29
+ loader: "@microsoft/webpack5-load-themed-styles-loader", // creates style nodes from JS strings
30
+ options: {
31
+ async: false
32
+ }
33
+ },
34
+ {
35
+ loader: "css-loader", // translates CSS into CommonJS
36
+ options: {
37
+ modules: true,
38
+ importLoaders: 2,
39
+ localIdentName: '[name]_[local]_[hash:base64:5]',
40
+ minimize: false
41
+ }
42
+ },
43
+ {
44
+ loader: 'postcss-loader',
45
+ options: {
46
+ plugins: function () {
47
+ return [
48
+ require('autoprefixer')
49
+ ];
50
+ }
51
+ }
52
+ },
53
+ {
54
+ loader: "sass-loader",
55
+ }
56
+ ]
57
+
58
+ ```
59
+
60
+ ## Options
61
+
62
+ ### `async` (boolean, defaults to `false`)
63
+
64
+ By default, `@microsoft/load-themed-styles` loads styles synchronously. This can have adverse performance effects
65
+ if many styles are loaded in quick succession. If the `async` option is set to `true`, the `loadStyles` function
66
+ is called with the second parameter set to `true`, directing the function to debounce style loading causing fewer
67
+ changes to the DOM.
68
+
69
+
70
+ ## Links
71
+
72
+ - [CHANGELOG.md](
73
+ https://github.com/microsoft/rushstack/blob/main/webpack/webpack5-loader-load-themed-styles/CHANGELOG.md) - Find
74
+ out what's new in the latest version
75
+
76
+ `@microsoft/webpack5-load-themed-styles-loader` is part of the [Rush Stack](https://rushstack.io/) family of projects.
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAU3D,MAAM,uBAAuB,GAAW,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAiBzF;;;;;GAKG;AAEH,sCAAsC;AAC/B,MAAM,KAAK,GAAkE,UAElF,gBAAwB;IAExB,MAAM,aAAa,GAAkD,IAAI,CAAC;IAC1E,MAAM,OAAO,GAAmC,aAAa,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;IACjF,IAAK,OAAmC,CAAC,WAAW,EAAE;QACpD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IAED,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,oBAAoB,GAAG,uBAAuB,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACpG,MAAM,kBAAkB,GAAW,IAAI,CAAC,SAAS,CAC/C,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,GAAG,gBAAgB,CAAC,CAC/E,CAAC;IAEF,MAAM,UAAU,GAAkD,QAAQ;QACxE,CAAC,CAAC;YACE,uBAAuB,kBAAkB,GAAG;YAC5C,8BAA8B,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG;SACtE;QACH,CAAC,CAAC;YACE,yBAAyB,kBAAkB,IAAI;YAC/C,wBAAwB,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI;SACjE,CAAC;IAEN,OAAO;QACL,GAAG,UAAU;QACb,EAAE;QACF,mEAAmE;QACnE,EAAE;QACF,8BAA8B;QAC9B,4CACE,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,mBAC5B,mBAAmB,KAAK,KAAK,IAAI,IAAI;QACrC,EAAE;QACF,qDAAqD;KACtD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC;AArCW,QAAA,KAAK,SAqChB","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * This simple loader wraps the loading of CSS in script equivalent to\n * require(\"\\@microsoft/load-themed-styles\").loadStyles('... css text ...').\n * @packageDocumentation\n */\n\nimport type { LoaderContext, PitchLoaderDefinitionFunction } from 'webpack';\n\nconst defaultThemedStylesPath: string = require.resolve('@microsoft/load-themed-styles');\n\n/**\n * Options for the loader.\n *\n * @public\n */\nexport interface ILoadThemedStylesLoaderOptions {\n /**\n * If this parameter is set to \"true,\" the \"loadAsync\" parameter is set to true in the call to loadStyles.\n * Defaults to false.\n */\n async?: boolean;\n loadThemedStylesPath?: string;\n esModule?: boolean;\n}\n\n/**\n * This simple loader wraps the loading of CSS in script equivalent to\n * require(\"load-themed-styles\").loadStyles('... css text ...').\n *\n * @public\n */\n\n// eslint-disable-next-line func-style\nexport const pitch: PitchLoaderDefinitionFunction<ILoadThemedStylesLoaderOptions> = function (\n this: LoaderContext<ILoadThemedStylesLoaderOptions>,\n remainingRequest: string\n): string {\n const loaderContext: LoaderContext<ILoadThemedStylesLoaderOptions> = this;\n const options: ILoadThemedStylesLoaderOptions = loaderContext.getOptions() || {};\n if ((options as Record<string, unknown>).namedExport) {\n throw new Error('The \"namedExport\" option has been removed.');\n }\n\n const { async = false, loadThemedStylesPath = defaultThemedStylesPath, esModule = false } = options;\n const stringifiedRequest: string = JSON.stringify(\n loaderContext.utils.contextify(loaderContext.context, '!!' + remainingRequest)\n );\n\n const importCode: [contentImport: string, loaderImport: string] = esModule\n ? [\n `import content from ${stringifiedRequest};`,\n `import { loadStyles } from ${JSON.stringify(loadThemedStylesPath)};`\n ]\n : [\n `var content = require(${stringifiedRequest});`,\n `var loader = require(${JSON.stringify(loadThemedStylesPath)});`\n ];\n\n return [\n ...importCode,\n '',\n 'if(typeof content === \"string\") content = [[module.id, content]];',\n '',\n '// add the styles to the DOM',\n `for (var i = 0; i < content.length; i++) ${\n esModule ? 'loadStyles' : 'loader.loadStyles'\n }(content[i][1], ${async === true});`,\n '',\n 'if(content.locals) module.exports = content.locals;'\n ].join('\\n');\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAU3D,MAAM,uBAAuB,GAAW,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAiBzF;;;;;GAKG;AAEH,sCAAsC;AAC/B,MAAM,KAAK,GAAkE,UAElF,gBAAwB;IAExB,MAAM,aAAa,GAAkD,IAAI,CAAC;IAC1E,MAAM,OAAO,GAAmC,aAAa,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;IACjF,IAAK,OAAmC,CAAC,WAAW,EAAE;QACpD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IAED,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,oBAAoB,GAAG,uBAAuB,EAAE,QAAQ,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACpG,MAAM,kBAAkB,GAAW,IAAI,CAAC,SAAS,CAC/C,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,GAAG,gBAAgB,CAAC,CAC/E,CAAC;IAEF,MAAM,UAAU,GAAkD,QAAQ;QACxE,CAAC,CAAC;YACE,uBAAuB,kBAAkB,GAAG;YAC5C,8BAA8B,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG;SACtE;QACH,CAAC,CAAC;YACE,yBAAyB,kBAAkB,IAAI;YAC/C,wBAAwB,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI;SACjE,CAAC;IAEN,OAAO;QACL,GAAG,UAAU;QACb,EAAE;QACF,mEAAmE;QACnE,EAAE;QACF,8BAA8B;QAC9B,4CACE,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,mBAC5B,mBAAmB,KAAK,KAAK,IAAI,IAAI;QACrC,EAAE;QACF,qDAAqD;KACtD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC;AArCW,QAAA,KAAK,SAqChB","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * This simple loader wraps the loading of CSS in script equivalent to\r\n * require(\"\\@microsoft/load-themed-styles\").loadStyles('... css text ...').\r\n * @packageDocumentation\r\n */\r\n\r\nimport type { LoaderContext, PitchLoaderDefinitionFunction } from 'webpack';\r\n\r\nconst defaultThemedStylesPath: string = require.resolve('@microsoft/load-themed-styles');\r\n\r\n/**\r\n * Options for the loader.\r\n *\r\n * @public\r\n */\r\nexport interface ILoadThemedStylesLoaderOptions {\r\n /**\r\n * If this parameter is set to \"true,\" the \"loadAsync\" parameter is set to true in the call to loadStyles.\r\n * Defaults to false.\r\n */\r\n async?: boolean;\r\n loadThemedStylesPath?: string;\r\n esModule?: boolean;\r\n}\r\n\r\n/**\r\n * This simple loader wraps the loading of CSS in script equivalent to\r\n * require(\"load-themed-styles\").loadStyles('... css text ...').\r\n *\r\n * @public\r\n */\r\n\r\n// eslint-disable-next-line func-style\r\nexport const pitch: PitchLoaderDefinitionFunction<ILoadThemedStylesLoaderOptions> = function (\r\n this: LoaderContext<ILoadThemedStylesLoaderOptions>,\r\n remainingRequest: string\r\n): string {\r\n const loaderContext: LoaderContext<ILoadThemedStylesLoaderOptions> = this;\r\n const options: ILoadThemedStylesLoaderOptions = loaderContext.getOptions() || {};\r\n if ((options as Record<string, unknown>).namedExport) {\r\n throw new Error('The \"namedExport\" option has been removed.');\r\n }\r\n\r\n const { async = false, loadThemedStylesPath = defaultThemedStylesPath, esModule = false } = options;\r\n const stringifiedRequest: string = JSON.stringify(\r\n loaderContext.utils.contextify(loaderContext.context, '!!' + remainingRequest)\r\n );\r\n\r\n const importCode: [contentImport: string, loaderImport: string] = esModule\r\n ? [\r\n `import content from ${stringifiedRequest};`,\r\n `import { loadStyles } from ${JSON.stringify(loadThemedStylesPath)};`\r\n ]\r\n : [\r\n `var content = require(${stringifiedRequest});`,\r\n `var loader = require(${JSON.stringify(loadThemedStylesPath)});`\r\n ];\r\n\r\n return [\r\n ...importCode,\r\n '',\r\n 'if(typeof content === \"string\") content = [[module.id, content]];',\r\n '',\r\n '// add the styles to the DOM',\r\n `for (var i = 0; i < content.length; i++) ${\r\n esModule ? 'loadStyles' : 'loader.loadStyles'\r\n }(content[i][1], ${async === true});`,\r\n '',\r\n 'if(content.locals) module.exports = content.locals;'\r\n ].join('\\n');\r\n};\r\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.37.2"
8
+ "packageVersion": "7.38.0"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/webpack5-load-themed-styles-loader",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "This simple loader wraps the loading of CSS in script equivalent to `require('load-themed-styles').loadStyles( /* css text */ )`. It is designed to be a replacement for style-loader.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "directory": "webpack/webpack5-loader-load-themed-styles"
12
12
  },
13
13
  "peerDependencies": {
14
- "@microsoft/load-themed-styles": "^2.0.84",
14
+ "@microsoft/load-themed-styles": "^2.0.86",
15
15
  "webpack": "^5"
16
16
  },
17
17
  "peerDependenciesMeta": {
@@ -23,9 +23,9 @@
23
23
  "webpack": "~5.82.1",
24
24
  "memfs": "3.4.3",
25
25
  "css-loader": "~6.6.0",
26
- "@microsoft/load-themed-styles": "2.0.84",
26
+ "@microsoft/load-themed-styles": "2.0.86",
27
27
  "local-node-rig": "1.0.0",
28
- "@rushstack/heft": "0.62.2",
28
+ "@rushstack/heft": "0.63.0",
29
29
  "@rushstack/node-core-library": "3.61.0"
30
30
  },
31
31
  "scripts": {