question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exclude regular expression path should be OS neutral

See original GitHub issue

The regular expression in the exclude property of a loader configuration can be used to exclude file paths, but the paths provided to the regular expressions are operating system dependent, e.g. on Windows the paths are in the form of “a\b\c” and on Unix-based operating systems “a/b/c”. This makes writing correct regular expressions more difficult (and especially to test them).

My proposal is to always supply paths in the Unix style to the regular expression (e.g. “a/b/c”), and to document this clearly.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:4
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rjgottencommented, Jul 6, 2018

@bebraw Any specific reason for closing this with a blunt ‘fix it yourself’?

To have projects handled correctly cross-platform, one needs to take care to write excludes either with obnoxiously bloated regexes like

exclude : /(?:\/|\\)excluded(?:\/|\\)path-segment(?:\/|\\)/

or use the function syntax everywhere with custom path normalization strewn in, e.g.

exclude : (path) => /\/excluded\/path-segment\//i.test(makeOSNeutral(path))

Is that the kind of burden you should be placing on authors?

Webpack itself is in a position to offer a ‘OS-neutral’ POSIX path here — What users expect is being offered here in 99.999…% percent of all cases to begin with… — which will still be *nix-compatible and shouldn’t break the status quo.

Imho it’s downright negligent to do nothing and tell users to fix it themselves. Webpack is complicated enough without latent bugs being introduced into build configurations by implicit OS dependencies…

1reaction
watjurkcommented, Oct 16, 2021

Hi, any update on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating regex to exclude a string in path
What you could do is move the negative lookahead to the beginning to assert that what follows is not /debug or /debug/ :....
Read more >
Regular Expressions Cheat Sheet by DaveChild
A quick reference guide for regular expressions (regex), including symbols, ranges, grouping, assertions and some sample patterns to get you started.
Read more >
Untitled
The regular expression must satisfy following conditions. com ... This post will provide the regex for matching specific numbers of sub-directories in a...
Read more >
User and Workspace Settings - Visual Studio Code
You can quickly clear a search term or filter with the Clear Settings Search ... the editor should remove adjacent closing quotes or...
Read more >
Exclude or filter files using file type and regular ...
Certain files and file types can be globally excluded from a backup ... your backup using both file type and regular expression exclusions....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found