@compiled/webpack-loader 0.13.0 → 0.14.1

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.
@@ -26,7 +26,7 @@ let hasErrored = false;
26
26
  * @returns
27
27
  */
28
28
  function getLoaderOptions(context) {
29
- const { bake = true, extract = false, importReact = undefined, nonce = undefined, resolve = {}, extensions = undefined, parserBabelPlugins = [], transformerBabelPlugins = [], [extract_plugin_1.pluginName]: isPluginEnabled = false, ssr = false, optimizeCss = true, addComponentName = false, classNameCompressionMap = undefined, extractStylesToDirectory = undefined, resolver = undefined, importSources = undefined, } = typeof context.getOptions === 'undefined'
29
+ const { bake = true, extract = false, importReact = undefined, nonce = undefined, resolve = {}, extensions = undefined, parserBabelPlugins = utils_1.DEFAULT_PARSER_BABEL_PLUGINS, transformerBabelPlugins = [], [extract_plugin_1.pluginName]: isPluginEnabled = false, ssr = false, optimizeCss = true, addComponentName = false, classNameCompressionMap = undefined, extractStylesToDirectory = undefined, resolver = undefined, importSources = undefined, } = typeof context.getOptions === 'undefined'
30
30
  ? // Webpack v4 flow
31
31
  (0, loader_utils_1.getOptions)(context)
32
32
  : // Webpack v5 flow
@@ -109,7 +109,7 @@ function getLoaderOptions(context) {
109
109
  * @param code
110
110
  */
111
111
  async function compiledLoader(code) {
112
- var _a, _b, _c, _d, _e, _f;
112
+ var _a, _b, _c, _d;
113
113
  const callback = this.async();
114
114
  // Bail early if Compiled isn't in the module or we're looking at compiled runtime code
115
115
  if (code.indexOf('@compiled/react') === -1 ||
@@ -118,16 +118,18 @@ async function compiledLoader(code) {
118
118
  }
119
119
  try {
120
120
  const includedFiles = [];
121
- const _g = getLoaderOptions(this), { resolve } = _g, options = __rest(_g, ["resolve"]);
121
+ const _e = getLoaderOptions(this), { resolve } = _e, options = __rest(_e, ["resolve"]);
122
122
  // Transform to an AST using the local babel config.
123
123
  const ast = await (0, core_1.parseAsync)(code, {
124
124
  filename: this.resourcePath,
125
+ babelrc: false,
126
+ configFile: false,
125
127
  caller: { name: 'compiled' },
126
128
  rootMode: 'upward-optional',
127
129
  parserOpts: {
128
- plugins: (_a = options.parserBabelPlugins) !== null && _a !== void 0 ? _a : undefined,
130
+ plugins: options.parserBabelPlugins,
129
131
  },
130
- plugins: (_b = options.transformerBabelPlugins) !== null && _b !== void 0 ? _b : undefined,
132
+ plugins: (_a = options.transformerBabelPlugins) !== null && _a !== void 0 ? _a : undefined,
131
133
  });
132
134
  // Transform using the Compiled Babel Plugin - we deliberately turn off using the local config.
133
135
  const result = await (0, core_1.transformFromAstAsync)(ast, code, {
@@ -136,10 +138,10 @@ async function compiledLoader(code) {
136
138
  sourceMaps: true,
137
139
  filename: this.resourcePath,
138
140
  parserOpts: {
139
- plugins: (_c = options.parserBabelPlugins) !== null && _c !== void 0 ? _c : undefined,
141
+ plugins: options.parserBabelPlugins,
140
142
  },
141
143
  plugins: [
142
- ...((_d = options.transformerBabelPlugins) !== null && _d !== void 0 ? _d : []),
144
+ ...((_b = options.transformerBabelPlugins) !== null && _b !== void 0 ? _b : []),
143
145
  options.extract && [
144
146
  '@compiled/babel-plugin-strip-runtime',
145
147
  {
@@ -156,7 +158,7 @@ async function compiledLoader(code) {
156
158
  ? options.resolver
157
159
  : (0, create_default_resolver_1.createDefaultResolver)({
158
160
  resolveOptions: resolve,
159
- webpackResolveOptions: (_e = this._compilation) === null || _e === void 0 ? void 0 : _e.options.resolve,
161
+ webpackResolveOptions: (_c = this._compilation) === null || _c === void 0 ? void 0 : _c.options.resolve,
160
162
  }) }),
161
163
  ],
162
164
  ].filter(utils_1.toBoolean),
@@ -164,7 +166,7 @@ async function compiledLoader(code) {
164
166
  includedFiles.forEach((file) => {
165
167
  this.addDependency((0, path_1.normalize)(file));
166
168
  });
167
- callback(null, (result === null || result === void 0 ? void 0 : result.code) || '', (_f = result === null || result === void 0 ? void 0 : result.map) !== null && _f !== void 0 ? _f : undefined);
169
+ callback(null, (result === null || result === void 0 ? void 0 : result.code) || '', (_d = result === null || result === void 0 ? void 0 : result.map) !== null && _d !== void 0 ? _d : undefined);
168
170
  }
169
171
  catch (e) {
170
172
  // @ts-expect-error Not checking for error type
@@ -1 +1 @@
1
- {"version":3,"file":"compiled-loader.js","sourceRoot":"","sources":["../src/compiled-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAAiC;AAEjC,sCAAgE;AAChE,2CAAyD;AACzD,+CAA0C;AAG1C,uEAAkE;AAClE,qDAA8D;AAG9D,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAA6C;IACrE,MAAM,EACJ,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,WAAW,GAAG,SAAS,EACvB,KAAK,GAAG,SAAS,EACjB,OAAO,GAAG,EAAE,EACZ,UAAU,GAAG,SAAS,EACtB,kBAAkB,GAAG,EAAE,EACvB,uBAAuB,GAAG,EAAE,EAC5B,CAAC,2BAAU,CAAC,EAAE,eAAe,GAAG,KAAK,EACrC,GAAG,GAAG,KAAK,EACX,WAAW,GAAG,IAAI,EAClB,gBAAgB,GAAG,KAAK,EACxB,uBAAuB,GAAG,SAAS,EACnC,wBAAwB,GAAG,SAAS,EACpC,QAAQ,GAAG,SAAS,EACpB,aAAa,GAAG,SAAS,GAC1B,GAA0B,OAAO,OAAO,CAAC,UAAU,KAAK,WAAW;QAClE,CAAC,CAAC,kBAAkB;YAClB,IAAA,yBAAU,EAAC,OAAO,CAAC;QACrB,CAAC,CAAC,kBAAkB;YAClB,OAAO,CAAC,UAAU,CAAC;gBACjB,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,SAAS;qBAChB;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,SAAS;qBAChB;oBACD,WAAW,EAAE;wBACX,IAAI,EAAE,SAAS;qBAChB;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;qBACf;oB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AAC,QAAQ;4BAClB,CAAC,CAAC,IAAA,+CAAqB,EAAC;gCACpB,cAAc,EAAE,OAAO;gCACvB,qBAAqB,EAAE,MAAA,IAAI,CAAC,YAAY,0CAAE,OAAO,CAAC,OAAO;6BAC1D,CAAC;iBAET;aACF,CAAC,MAAM,CAAC,iBAAS,CAAC;SACpB,CAAC,CAAC;QAEH,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7B,IAAI,CAAC,aAAa,CAAC,IAAA,gBAAS,EAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,IAAI,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,EAAE,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,SAAS,CAAC,CAAC;KAC9D;IAAC,OAAO,CAAU,EAAE;QACnB,+CAA+C;QAC/C,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7E,QAAQ,CAAC,KAAK,CAAC,CAAC;KACjB;AACH,CAAC;AA9ED,iCA8EC;AAED,SAAgB,KAAK;IACnB,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,2BAAU,CAAC,EAAE;QAC1D,IAAI,CAAC,SAAS,CACZ,IAAA,mBAAW,EAAC,gBAAgB,CAAC,CAC3B,gLAAgL,CACjL,CACF,CAAC;QAEF,4FAA4F;QAC5F,UAAU,GAAG,IAAI,CAAC;KACnB;AACH,CAAC;AAZD,sBAYC"}
@@ -11,8 +11,11 @@ function createDefaultResolver({ resolveOptions, webpackResolveOptions }) {
11
11
  // Setup the default resolver, where webpack will merge any passed in options with the default
12
12
  // resolve configuration. Ideally, we use this.getResolve({ ...resolve, useSyncFileSystemCalls: true, })
13
13
  // However, it does not work correctly when in development mode :/
14
+ // @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
15
+ // compatible with @types/node fs types
14
16
  const resolver = enhanced_resolve_1.ResolverFactory.createResolver(Object.assign(Object.assign(Object.assign({
15
- // @ts-expect-error
17
+ // @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
18
+ // compatible with @types/node fs types
16
19
  fileSystem: new enhanced_resolve_1.CachedInputFileSystem(fs_1.default, 4000) }, (webpackResolveOptions !== null && webpackResolveOptions !== void 0 ? webpackResolveOptions : {})), resolveOptions), {
17
20
  // This makes the resolver invoke the callback synchronously
18
21
  useSyncFileSystemCalls: true }));
@@ -1 +1 @@
1
- {"version":3,"file":"create-default-resolver.js","sourceRoot":"","sources":["../src/create-default-resolver.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,+BAA+B;AAG/B,uDAA0E;AAQ1E,SAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAU;IACrF,8FAA8F;IAC9F,wGAAwG;IACxG,kEAAkE;IAClE,MAAM,QAAQ,GAAG,kCAAe,CAAC,cAAc;QAC7C,mBAAmB;QACnB,UAAU,EAAE,IAAI,wCAAqB,CAAC,YAAE,EAAE,IAAI,CAAC,IAC5C,CAAC,qBAAqB,aAArB,qBAAqB,cAArB,qBAAqB,GAAI,EAAE,CAAC,GAC7B,cAAc;QACjB,4DAA4D;QAC5D,sBAAsB,EAAE,IAAI,IAC5B,CAAC;IAEH,OAAO;QACL,6EAA6E;QAC7E,WAAW,EAAE,CAAC,OAAe,EAAE,OAAe,EAAE,EAAE;YAChD,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,OAAO,CAAW,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC;AAnBD,sDAmBC"}
1
+ {"version":3,"file":"create-default-resolver.js","sourceRoot":"","sources":["../src/create-default-resolver.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,+BAA+B;AAG/B,uDAA0E;AAQ1E,SAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,qBAAqB,EAAU;IACrF,8FAA8F;IAC9F,wGAAwG;IACxG,kEAAkE;IAElE,0EAA0E;IAC1E,uCAAuC;IACvC,MAAM,QAAQ,GAAG,kCAAe,CAAC,cAAc;QAC7C,0EAA0E;QAC1E,uCAAuC;QACvC,UAAU,EAAE,IAAI,wCAAqB,CAAC,YAAE,EAAE,IAAI,CAAC,IAC5C,CAAC,qBAAqB,aAArB,qBAAqB,cAArB,qBAAqB,GAAI,EAAE,CAAC,GAC7B,cAAc;QACjB,4DAA4D;QAC5D,sBAAsB,EAAE,IAAI,IAC5B,CAAC;IAEH,OAAO;QACL,6EAA6E;QAC7E,WAAW,EAAE,CAAC,OAAe,EAAE,OAAe,EAAE,EAAE;YAChD,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,OAAO,CAAW,CAAC;QACvE,CAAC;KACF,CAAC;AACJ,CAAC;AAvBD,sDAuBC"}
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } from 'webpack';
1
+ import type { Compilation as CompilationType, Compiler, sources, WebpackOptionsNormalized } from 'webpack';
2
2
  /**
3
3
  * Sets an option on the plugin config to tell loaders that the plugin has been configured.
4
4
  * Bundling will throw if this option is missing (i.e. consumers did not setup correctly).
@@ -7,7 +7,7 @@ import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } f
7
7
  * @param pluginName
8
8
  * @returns
9
9
  */
10
- export declare const setPluginConfiguredOption: (rules: (RuleSetRule | '...')[], pluginName: string) => void;
10
+ export declare const setPluginConfiguredOption: (rules: WebpackOptionsNormalized['module']['rules'], pluginName: string) => void;
11
11
  /**
12
12
  * Returns the string representation of an assets source.
13
13
  *
package/dist/utils.js CHANGED
@@ -13,7 +13,8 @@ const setOptionOnCompiledWebpackLoader = (use, pluginName) => {
13
13
  return;
14
14
  }
15
15
  for (const nestedUse of use) {
16
- if (typeof nestedUse === 'object' &&
16
+ if (nestedUse &&
17
+ typeof nestedUse === 'object' &&
17
18
  (nestedUse.loader === '@compiled/webpack-loader' ||
18
19
  ((_a = nestedUse.loader) === null || _a === void 0 ? void 0 : _a.includes('/node_modules/@compiled/webpack-loader')))) {
19
20
  const { options } = nestedUse;
@@ -34,11 +35,16 @@ const setOptionOnCompiledWebpackLoader = (use, pluginName) => {
34
35
  const setPluginConfiguredOption = (rules, pluginName) => {
35
36
  var _a;
36
37
  for (const r of rules) {
38
+ if (!r) {
39
+ continue;
40
+ }
37
41
  const rule = r;
38
42
  const nestedRules = (_a = rule.oneOf) !== null && _a !== void 0 ? _a : rule.rules;
39
43
  if (nestedRules) {
40
44
  for (const nestedRule of nestedRules) {
41
- setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
45
+ if (nestedRule) {
46
+ setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
47
+ }
42
48
  }
43
49
  }
44
50
  else {
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAM,gCAAgC,GAAG,CAAC,GAAuB,EAAE,UAAkB,EAAE,EAAE;;IACvF,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;QAC9C,OAAO;KACR;IAED,KAAK,MAAM,SAAS,IAAI,GAAG,EAAE;QAC3B,IACE,OAAO,SAAS,KAAK,QAAQ;YAC7B,CAAC,SAAS,CAAC,MAAM,KAAK,0BAA0B;iBAC9C,MAAA,SAAS,CAAC,MAAM,0CAAE,QAAQ,CAAC,wCAAwC,CAAC,CAAA,CA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M,qBAAqB,GAAG,CACnC,QAAkB,EAClB,WAA4B,EAC+B,EAAE;IAC7D,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE;IAC5B,iBAAiB;IACjB,QAAQ,CAAC,OAAO;QAChB,iBAAiB;QACjB,OAAO,CAAC,SAAS,CAAC,CAAC;IACrB,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,cAAc;IAClB,iBAAiB;IACjB,WAAW,CAAC,KAAK,CAAC,aAAa;QAC/B,iBAAiB;QACjB,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC;IAEnC,OAAO;QACL,GAAG,EAAE,CAAC,UAAkB,EAAE,QAAqD,EAAE,EAAE;YACjF,cAAc,CAAC,GAAG,CAChB,UAAU;gBACR,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC;oBACE,IAAI,EAAE,UAAU;oBAChB,KAAK,EAAE,WAAW,CAAC,kCAAkC;iBACtD,EACL,QAAQ,CACT,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;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.13.0",
3
+ "version": "0.14.1",
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",
@@ -25,7 +25,7 @@
25
25
  "@compiled/babel-plugin": "^0.29.0",
26
26
  "@compiled/babel-plugin-strip-runtime": "^0.29.0",
27
27
  "@compiled/css": "^0.14.0",
28
- "@compiled/utils": "^0.11.1",
28
+ "@compiled/utils": "^0.11.2",
29
29
  "enhanced-resolve": "^5.15.0",
30
30
  "loader-utils": "^2.0.4",
31
31
  "webpack-sources": "^3.2.3"
@@ -1,7 +1,7 @@
1
1
  import { normalize } from 'path';
2
2
 
3
3
  import { parseAsync, transformFromAstAsync } from '@babel/core';
4
- import { createError, toBoolean } from '@compiled/utils';
4
+ import { createError, DEFAULT_PARSER_BABEL_PLUGINS, toBoolean } from '@compiled/utils';
5
5
  import { getOptions } from 'loader-utils';
6
6
  import type { LoaderContext } from 'webpack';
7
7
 
@@ -25,7 +25,7 @@ function getLoaderOptions(context: LoaderContext<CompiledLoaderOptions>) {
25
25
  nonce = undefined,
26
26
  resolve = {},
27
27
  extensions = undefined,
28
- parserBabelPlugins = [],
28
+ parserBabelPlugins = DEFAULT_PARSER_BABEL_PLUGINS,
29
29
  transformerBabelPlugins = [],
30
30
  [pluginName]: isPluginEnabled = false,
31
31
  ssr = false,
@@ -140,10 +140,12 @@ export default async function compiledLoader(
140
140
  // Transform to an AST using the local babel config.
141
141
  const ast = await parseAsync(code, {
142
142
  filename: this.resourcePath,
143
+ babelrc: false,
144
+ configFile: false,
143
145
  caller: { name: 'compiled' },
144
146
  rootMode: 'upward-optional',
145
147
  parserOpts: {
146
- plugins: options.parserBabelPlugins ?? undefined,
148
+ plugins: options.parserBabelPlugins,
147
149
  },
148
150
  plugins: options.transformerBabelPlugins ?? undefined,
149
151
  });
@@ -155,7 +157,7 @@ export default async function compiledLoader(
155
157
  sourceMaps: true,
156
158
  filename: this.resourcePath,
157
159
  parserOpts: {
158
- plugins: options.parserBabelPlugins ?? undefined,
160
+ plugins: options.parserBabelPlugins,
159
161
  },
160
162
  plugins: [
161
163
  ...(options.transformerBabelPlugins ?? []),
@@ -14,8 +14,12 @@ export function createDefaultResolver({ resolveOptions, webpackResolveOptions }:
14
14
  // Setup the default resolver, where webpack will merge any passed in options with the default
15
15
  // resolve configuration. Ideally, we use this.getResolve({ ...resolve, useSyncFileSystemCalls: true, })
16
16
  // However, it does not work correctly when in development mode :/
17
+
18
+ // @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
19
+ // compatible with @types/node fs types
17
20
  const resolver = ResolverFactory.createResolver({
18
- // @ts-expect-error
21
+ // @ts-expect-error - enhanced-resolve CachedInputFileSystem types are not
22
+ // compatible with @types/node fs types
19
23
  fileSystem: new CachedInputFileSystem(fs, 4000),
20
24
  ...(webpackResolveOptions ?? {}),
21
25
  ...resolveOptions,
package/src/utils.ts CHANGED
@@ -1,4 +1,10 @@
1
- import type { Compilation as CompilationType, Compiler, sources, RuleSetRule } from 'webpack';
1
+ import type {
2
+ Compilation as CompilationType,
3
+ Compiler,
4
+ sources,
5
+ RuleSetRule,
6
+ WebpackOptionsNormalized,
7
+ } from 'webpack';
2
8
 
3
9
  /**
4
10
  * Helper function to set plugin configured option on the @compiled/webpack-loader
@@ -13,6 +19,7 @@ const setOptionOnCompiledWebpackLoader = (use: RuleSetRule['use'], pluginName: s
13
19
 
14
20
  for (const nestedUse of use) {
15
21
  if (
22
+ nestedUse &&
16
23
  typeof nestedUse === 'object' &&
17
24
  (nestedUse.loader === '@compiled/webpack-loader' ||
18
25
  nestedUse.loader?.includes('/node_modules/@compiled/webpack-loader'))
@@ -34,15 +41,21 @@ const setOptionOnCompiledWebpackLoader = (use: RuleSetRule['use'], pluginName: s
34
41
  * @returns
35
42
  */
36
43
  export const setPluginConfiguredOption = (
37
- rules: (RuleSetRule | '...')[],
44
+ rules: WebpackOptionsNormalized['module']['rules'],
38
45
  pluginName: string
39
46
  ): void => {
40
47
  for (const r of rules) {
48
+ if (!r) {
49
+ continue;
50
+ }
51
+
41
52
  const rule = r as RuleSetRule;
42
53
  const nestedRules = rule.oneOf ?? rule.rules;
43
54
  if (nestedRules) {
44
55
  for (const nestedRule of nestedRules) {
45
- setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
56
+ if (nestedRule) {
57
+ setOptionOnCompiledWebpackLoader(nestedRule.use, pluginName);
58
+ }
46
59
  }
47
60
  } else {
48
61
  setOptionOnCompiledWebpackLoader(rule.use, pluginName);