@compiled/webpack-loader 0.8.5 → 0.8.6

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/dist/utils.js CHANGED
@@ -1,6 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSources = exports.getOptimizeAssetsHook = exports.getAssetSourceContents = exports.setPluginConfiguredOption = void 0;
4
+ /**
5
+ * Helper function to set plugin configured option on the @compiled/webpack-loader
6
+ *
7
+ * @param use
8
+ * @param pluginName
9
+ */
10
+ const setOptionOnCompiledWebpackLoader = (use, pluginName) => {
11
+ if (!use || !Array.isArray(use) || !use.length) {
12
+ return;
13
+ }
14
+ for (const nestedUse of use) {
15
+ if (typeof nestedUse === 'object' && nestedUse.loader === '@compiled/webpack-loader') {
16
+ const { options } = nestedUse;
17
+ if (options !== undefined && typeof options === 'object' && options.extract !== undefined) {
18
+ options[pluginName] = true;
19
+ }
20
+ }
21
+ }
22
+ };
4
23
  /**
5
24
  * Sets an option on the plugin config to tell loaders that the plugin has been configured.
6
25
  * Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
@@ -10,34 +29,17 @@ exports.getSources = exports.getOptimizeAssetsHook = exports.getAssetSourceConte
10
29
  * @returns
11
30
  */
12
31
  const setPluginConfiguredOption = (rules, pluginName) => {
13
- for (const rule of rules) {
14
- const use = rule.use;
15
- if (!use || typeof use === 'string') {
16
- continue;
17
- }
18
- if (Array.isArray(use)) {
19
- if (!use.length) {
20
- continue;
21
- }
22
- for (const nestedUse of use) {
23
- if (typeof nestedUse !== 'object' || nestedUse.loader !== '@compiled/webpack-loader') {
24
- continue;
25
- }
26
- const { options } = nestedUse;
27
- if (!options || typeof options !== 'object' || !options.extract) {
28
- continue;
29
- }
30
- options[pluginName] = true;
32
+ var _a;
33
+ for (const r of rules) {
34
+ const rule = r;
35
+ const nestedRules = (_a = rule.oneOf) !== null && _a !== void 0 ? _a : rule.rules;
36
+ if (nestedRules) {
37
+ for (const nestedRule of nestedRules) {
38
+ setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
31
39
  }
32
40
  }
33
41
  else {
34
- if (typeof use === 'object' && use.loader === '@compiled/webpack-loader') {
35
- const { options } = use;
36
- if (!options || typeof options !== 'object' || !options.extract) {
37
- continue;
38
- }
39
- options[pluginName] = true;
40
- }
42
+ setOptionOnCompiledWebpackLoader(rule.use, pluginName);
41
43
  }
42
44
  }
43
45
  };
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACI,MAAM,yBAAyB,GAAG,CACvC,KAA8B,EAC9B,UAAkB,EACZ,EAAE;IACR,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,GAAG,GAAI,IAAoB,CAAC,GAAG,CAAC;QACtC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YACnC,SAAS;SACV;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACtB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;gBACf,SAAS;aACV;YACD,KAAK,MAAM,SAAS,IAAI,GAAG,EAAE;gBAC3B,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,MAAM,KAAK,0BAA0B,EAAE;oBACpF,SAAS;iBACV;gBACD,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;gBAC9B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;oBAC/D,SAAS;iBACV;gBACD,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;aAC5B;SACF;aAAM;YACL,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,0BAA0B,EAAE;gBACxE,MAAM,EAA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;AA7BW,QAAA,qBAAqB,yBA6BhC;AAEF;;;GAGG;AACI,MAAM,UAAU,GAAG,CAAC,QAAkB,EAAkB,EAAE;IAC/D,MAAM,EAAE,OAAO,EAAE;IACf,iBAAiB;IACjB,QAAQ,CAAC,OAAO;QAChB,iBAAiB;QACjB,EAAE,CAAC;IAEL,OAAO;IACL,iBAAiB;IACjB,OAAO;QACP,iBAAiB;QACjB,OAAO,CAAC,iBAAiB,CAAC,CAC3B,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,UAAU,cAarB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compiled/webpack-loader",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "A familiar and performant compile time CSS-in-JS library for React.",
5
5
  "homepage": "https://compiledcssinjs.com/docs/pkg-webpack-loader",
6
6
  "bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
@@ -20,9 +20,9 @@
20
20
  "src"
21
21
  ],
22
22
  "dependencies": {
23
- "@babel/core": "^7.17.5",
24
- "@compiled/babel-plugin": "^0.14.0",
25
- "@compiled/babel-plugin-strip-runtime": "^0.14.0",
23
+ "@babel/core": "^7.17.8",
24
+ "@compiled/babel-plugin": "^0.14.1",
25
+ "@compiled/babel-plugin-strip-runtime": "^0.14.1",
26
26
  "@compiled/css": "^0.8.2",
27
27
  "@compiled/react": "0.10.4",
28
28
  "@compiled/utils": "^0.6.16",
package/src/utils.ts CHANGED
@@ -1,5 +1,26 @@
1
1
  import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } from 'webpack';
2
2
 
3
+ /**
4
+ * Helper function to set plugin configured option on the @compiled/webpack-loader
5
+ *
6
+ * @param use
7
+ * @param pluginName
8
+ */
9
+ const setOptionOnCompiledWebpackLoader = (use: RuleSetRule['use'], pluginName: string) => {
10
+ if (!use || !Array.isArray(use) || !use.length) {
11
+ return;
12
+ }
13
+
14
+ for (const nestedUse of use) {
15
+ if (typeof nestedUse === 'object' && nestedUse.loader === '@compiled/webpack-loader') {
16
+ const { options } = nestedUse;
17
+ if (options !== undefined && typeof options === 'object' && options.extract !== undefined) {
18
+ options[pluginName] = true;
19
+ }
20
+ }
21
+ }
22
+ };
23
+
3
24
  /**
4
25
  * Sets an option on the plugin config to tell loaders that the plugin has been configured.
5
26
  * Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
@@ -12,33 +33,15 @@ export const setPluginConfiguredOption = (
12
33
  rules: (RuleSetRule | '...')[],
13
34
  pluginName: string
14
35
  ): void => {
15
- for (const rule of rules) {
16
- const use = (rule as RuleSetRule).use;
17
- if (!use || typeof use === 'string') {
18
- continue;
19
- }
20
- if (Array.isArray(use)) {
21
- if (!use.length) {
22
- continue;
23
- }
24
- for (const nestedUse of use) {
25
- if (typeof nestedUse !== 'object' || nestedUse.loader !== '@compiled/webpack-loader') {
26
- continue;
27
- }
28
- const { options } = nestedUse;
29
- if (!options || typeof options !== 'object' || !options.extract) {
30
- continue;
31
- }
32
- options[pluginName] = true;
36
+ for (const r of rules) {
37
+ const rule = r as RuleSetRule;
38
+ const nestedRules = rule.oneOf ?? rule.rules;
39
+ if (nestedRules) {
40
+ for (const nestedRule of nestedRules) {
41
+ setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
33
42
  }
34
43
  } else {
35
- if (typeof use === 'object' && use.loader === '@compiled/webpack-loader') {
36
- const { options } = use;
37
- if (!options || typeof options !== 'object' || !options.extract) {
38
- continue;
39
- }
40
- options[pluginName] = true;
41
- }
44
+ setOptionOnCompiledWebpackLoader(rule.use, pluginName);
42
45
  }
43
46
  }
44
47
  };