@microsoft/loader-load-themed-styles 1.9.179 → 2.0.0

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/README.md CHANGED
@@ -28,7 +28,6 @@ var css = require("@microsoft/loader-load-themed-styles!css!./file.css");
28
28
  {
29
29
  loader: "@microsoft/loader-load-themed-styles", // creates style nodes from JS strings
30
30
  options: {
31
- namedExport: 'default',
32
31
  async: false
33
32
  }
34
33
  },
@@ -60,22 +59,6 @@ var css = require("@microsoft/loader-load-themed-styles!css!./file.css");
60
59
 
61
60
  ## Options
62
61
 
63
- ### `namedExport` (string, defaults to `undefined`)
64
-
65
- By default, css modules will be exported as a commonjs export:
66
-
67
- ```js
68
- module.exports = { ... };
69
- ```
70
-
71
- To override this, you may provide a named export to export to a specifically named thing. This
72
- is useful in exporting as the default in es6 module import scenarios. For example, providing
73
- "default" for the named export will output this:
74
-
75
- ```js
76
- module.exports.default = { ... };
77
- ```
78
-
79
62
  ### `async` (boolean, defaults to `false`)
80
63
 
81
64
  By default, `@microsoft/load-themed-styles` loads styles synchronously. This can have adverse performance effects
@@ -10,11 +10,6 @@ import { loader } from 'webpack';
10
10
  * @public
11
11
  */
12
12
  export interface ILoadThemedStylesLoaderOptions {
13
- /**
14
- * If this parameter is specified, override the name of the value exported from this loader. This is useful in
15
- * exporting as the default in es6 module import scenarios. See the README for more information.
16
- */
17
- namedExport?: string;
18
13
  /**
19
14
  * If this parameter is set to "true," the "loadAsync" parameter is set to true in the call to loadStyles.
20
15
  * Defaults to false.
@@ -1 +1 @@
1
- {"version":3,"file":"LoadThemedStylesLoader.d.ts","sourceRoot":"","sources":["../src/LoadThemedStylesLoader.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAKjC;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAkC;;IAMxE,WAAkB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAErD;IAED;;OAEG;IACH,WAAkB,sBAAsB,IAAI,MAAM,CAEjD;IAED;;OAEG;WACW,2BAA2B,IAAI,IAAI;WAInC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM;CAoBlF"}
1
+ {"version":3,"file":"LoadThemedStylesLoader.d.ts","sourceRoot":"","sources":["../src/LoadThemedStylesLoader.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAKjC;;;;GAIG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAkC;;IAMxE,WAAkB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAErD;IAED;;OAEG;IACH,WAAkB,sBAAsB,IAAI,MAAM,CAEjD;IAED;;OAEG;WACW,2BAA2B,IAAI,IAAI;WAInC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,aAAa,EAAE,gBAAgB,EAAE,MAAM,GAAG,MAAM;CAoBlF"}
@@ -31,11 +31,11 @@ class LoadThemedStylesLoader {
31
31
  LoadThemedStylesLoader._loadedThemedStylesPath = loadedThemedStylesPath;
32
32
  }
33
33
  static pitch(remainingRequest) {
34
- const { namedExport, async = false } = loaderUtils.getOptions(this) || {};
35
- let exportName = 'module.exports';
36
- if (namedExport) {
37
- exportName += `.${namedExport}`;
34
+ const options = loaderUtils.getOptions(this) || {};
35
+ if (options.namedExport) {
36
+ throw new Error('The "namedExport" option has been removed.');
38
37
  }
38
+ const { async = false } = options;
39
39
  return [
40
40
  `var content = require(${loaderUtils.stringifyRequest(this, '!!' + remainingRequest)});`,
41
41
  `var loader = require(${JSON.stringify(LoadThemedStylesLoader._loadedThemedStylesPath)});`,
@@ -45,7 +45,7 @@ class LoadThemedStylesLoader {
45
45
  '// add the styles to the DOM',
46
46
  `for (var i = 0; i < content.length; i++) loader.loadStyles(content[i][1], ${async === true});`,
47
47
  '',
48
- `if(content.locals) ${exportName} = content.locals;`
48
+ 'if(content.locals) module.exports = content.locals;'
49
49
  ].join('\n');
50
50
  }
51
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LoadThemedStylesLoader.js","sourceRoot":"","sources":["../src/LoadThemedStylesLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAS3D,4CAA6C;AAE7C,MAAM,sBAAsB,GAAW,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAqBxF;;;;;GAKG;AACH,MAAa,sBAAsB;IAGjC;QACE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAEM,MAAM,KAAK,sBAAsB,CAAC,KAAa;QACpD,sBAAsB,CAAC,uBAAuB,GAAG,KAAK,CAAC;IACzD,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,sBAAsB;QACtC,OAAO,sBAAsB,CAAC,uBAAuB,CAAC;IACxD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,2BAA2B;QACvC,sBAAsB,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;IAC1E,CAAC;IAEM,MAAM,CAAC,KAAK,CAA6B,gBAAwB;QACtE,MAAM,EAAE,WAAW,EAAE,KAAK,GAAG,KAAK,EAAE,GAAmC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAE1G,IAAI,UAAU,GAAW,gBAAgB,CAAC;QAC1C,IAAI,WAAW,EAAE;YACf,UAAU,IAAI,IAAI,WAAW,EAAE,CAAC;SACjC;QAED,OAAO;YACL,yBAAyB,WAAW,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,gBAAgB,CAAC,IAAI;YACxF,wBAAwB,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,uBAAuB,CAAC,IAAI;YAC1F,EAAE;YACF,mEAAmE;YACnE,EAAE;YACF,8BAA8B;YAC9B,6EAA6E,KAAK,KAAK,IAAI,IAAI;YAC/F,EAAE;YACF,sBAAsB,UAAU,oBAAoB;SACrD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;;AA5CH,wDA6CC;AA5CgB,8CAAuB,GAAW,sBAAsB,CAAC","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(\"load-themed-styles\").loadStyles('... css text ...').\n * @packageDocumentation\n */\n\nimport { loader } from 'webpack';\nimport loaderUtils = require('loader-utils');\n\nconst loadedThemedStylesPath: 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 specified, override the name of the value exported from this loader. This is useful in\n * exporting as the default in es6 module import scenarios. See the README for more information.\n */\n namedExport?: string;\n\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}\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 */\nexport class LoadThemedStylesLoader {\n private static _loadedThemedStylesPath: string = loadedThemedStylesPath;\n\n public constructor() {\n throw new Error('Constructing \"LoadThemedStylesLoader\" is not supported.');\n }\n\n public static set loadedThemedStylesPath(value: string) {\n LoadThemedStylesLoader._loadedThemedStylesPath = value;\n }\n\n /**\n * Use this property to override the path to the `@microsoft/load-themed-styles` package.\n */\n public static get loadedThemedStylesPath(): string {\n return LoadThemedStylesLoader._loadedThemedStylesPath;\n }\n\n /**\n * Reset the path to the `@microsoft/load-themed-styles package` to the default.\n */\n public static resetLoadedThemedStylesPath(): void {\n LoadThemedStylesLoader._loadedThemedStylesPath = loadedThemedStylesPath;\n }\n\n public static pitch(this: loader.LoaderContext, remainingRequest: string): string {\n const { namedExport, async = false }: ILoadThemedStylesLoaderOptions = loaderUtils.getOptions(this) || {};\n\n let exportName: string = 'module.exports';\n if (namedExport) {\n exportName += `.${namedExport}`;\n }\n\n return [\n `var content = require(${loaderUtils.stringifyRequest(this, '!!' + remainingRequest)});`,\n `var loader = require(${JSON.stringify(LoadThemedStylesLoader._loadedThemedStylesPath)});`,\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++) loader.loadStyles(content[i][1], ${async === true});`,\n '',\n `if(content.locals) ${exportName} = content.locals;`\n ].join('\\n');\n }\n}\n"]}
1
+ {"version":3,"file":"LoadThemedStylesLoader.js","sourceRoot":"","sources":["../src/LoadThemedStylesLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAS3D,4CAA6C;AAE7C,MAAM,sBAAsB,GAAW,OAAO,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;AAexF;;;;;GAKG;AACH,MAAa,sBAAsB;IAGjC;QACE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAEM,MAAM,KAAK,sBAAsB,CAAC,KAAa;QACpD,sBAAsB,CAAC,uBAAuB,GAAG,KAAK,CAAC;IACzD,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,sBAAsB;QACtC,OAAO,sBAAsB,CAAC,uBAAuB,CAAC;IACxD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,2BAA2B;QACvC,sBAAsB,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;IAC1E,CAAC;IAEM,MAAM,CAAC,KAAK,CAA6B,gBAAwB;QACtE,MAAM,OAAO,GAAmC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACnF,IAAK,OAAmC,CAAC,WAAW,EAAE;YACpD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;SAC/D;QAED,MAAM,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;QAElC,OAAO;YACL,yBAAyB,WAAW,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,gBAAgB,CAAC,IAAI;YACxF,wBAAwB,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,uBAAuB,CAAC,IAAI;YAC1F,EAAE;YACF,mEAAmE;YACnE,EAAE;YACF,8BAA8B;YAC9B,6EAA6E,KAAK,KAAK,IAAI,IAAI;YAC/F,EAAE;YACF,qDAAqD;SACtD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;;AA5CH,wDA6CC;AA5CgB,8CAAuB,GAAW,sBAAsB,CAAC","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(\"load-themed-styles\").loadStyles('... css text ...').\n * @packageDocumentation\n */\n\nimport { loader } from 'webpack';\nimport loaderUtils = require('loader-utils');\n\nconst loadedThemedStylesPath: 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}\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 */\nexport class LoadThemedStylesLoader {\n private static _loadedThemedStylesPath: string = loadedThemedStylesPath;\n\n public constructor() {\n throw new Error('Constructing \"LoadThemedStylesLoader\" is not supported.');\n }\n\n public static set loadedThemedStylesPath(value: string) {\n LoadThemedStylesLoader._loadedThemedStylesPath = value;\n }\n\n /**\n * Use this property to override the path to the `@microsoft/load-themed-styles` package.\n */\n public static get loadedThemedStylesPath(): string {\n return LoadThemedStylesLoader._loadedThemedStylesPath;\n }\n\n /**\n * Reset the path to the `@microsoft/load-themed-styles package` to the default.\n */\n public static resetLoadedThemedStylesPath(): void {\n LoadThemedStylesLoader._loadedThemedStylesPath = loadedThemedStylesPath;\n }\n\n public static pitch(this: loader.LoaderContext, remainingRequest: string): string {\n const options: ILoadThemedStylesLoaderOptions = loaderUtils.getOptions(this) || {};\n if ((options as Record<string, unknown>).namedExport) {\n throw new Error('The \"namedExport\" option has been removed.');\n }\n\n const { async = false } = options;\n\n return [\n `var content = require(${loaderUtils.stringifyRequest(this, '!!' + remainingRequest)});`,\n `var loader = require(${JSON.stringify(LoadThemedStylesLoader._loadedThemedStylesPath)});`,\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++) loader.loadStyles(content[i][1], ${async === true});`,\n '',\n 'if(content.locals) module.exports = content.locals;'\n ].join('\\n');\n }\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.31.1"
8
+ "packageVersion": "7.31.2"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/loader-load-themed-styles",
3
- "version": "1.9.179",
3
+ "version": "2.0.0",
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",
@@ -16,16 +16,17 @@
16
16
  }
17
17
  },
18
18
  "peerDependencies": {
19
- "@types/webpack": "^4"
19
+ "@types/webpack": "^4",
20
+ "@microsoft/load-themed-styles": "^2.0.3"
20
21
  },
21
22
  "dependencies": {
22
- "@microsoft/load-themed-styles": "2.0.1",
23
23
  "loader-utils": "~1.1.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@rushstack/eslint-config": "3.0.1",
27
- "@rushstack/heft": "0.47.10",
28
- "@rushstack/heft-node-rig": "1.10.12",
26
+ "@microsoft/load-themed-styles": "2.0.3",
27
+ "@rushstack/eslint-config": "3.1.0",
28
+ "@rushstack/heft-node-rig": "1.11.0",
29
+ "@rushstack/heft": "0.48.0",
29
30
  "@types/heft-jest": "1.0.1",
30
31
  "@types/loader-utils": "1.1.3",
31
32
  "@types/node": "12.20.24",