Skip to content

Commit

Permalink
loadLinariaOptions: fix node_modules regexp for Windows (#1225)
Browse files Browse the repository at this point in the history
  • Loading branch information
nstepien committed Mar 25, 2023
1 parent a62e7ba commit 7c66f74
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export type PluginOptions = StrictOptions & {
const explorerSync = cosmiconfigSync('linaria');

const cache = new WeakMap<Partial<PluginOptions>, StrictOptions>();
const defaultOverrides = {};
const nodeModulesRegExp = /[\\/]node_modules[\\/]/;

export default function loadLinariaOptions(
overrides: Partial<PluginOptions> = {}
overrides: Partial<PluginOptions> = defaultOverrides
): StrictOptions {
if (cache.has(overrides)) {
return cache.get(overrides)!;
Expand All @@ -37,13 +39,13 @@ export default function loadLinariaOptions(
},
{
// The old `ignore` option is used as a default value for `ignore` rule.
test: ignore ?? /[\\/]node_modules[\\/]/,
test: ignore ?? nodeModulesRegExp,
action: 'ignore',
},
{
// Do not ignore ES-modules
test: (filename, code) => {
if (!/\/node_modules\//.test(filename)) {
if (!nodeModulesRegExp.test(filename)) {
return false;
}

Expand Down

0 comments on commit 7c66f74

Please sign in to comment.