Skip to content

Commit e86752a

Browse files
committed
Update regex
1 parent 129042a commit e86752a

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,31 @@ You must use the wrapper around [`debug`](https://www.npmjs.com/package/debug) n
1212

1313
Do not:
1414
* Alias your `import` or `require` of `Debug`
15+
* Spread your `import` of `require` of `Debug` over more than one line
1516
* Put more than one `debug()` call on a single line
16-
* Have a comment including a `debug('call')`
1717
* Other crazy things
1818

1919
Just make simple debug statements.
2020

2121
```js
2222
import { Debug } from 'webpack-strip-debug-loader'
2323

24-
const debug = Debug('feature')
24+
// Or use require if you prefer that
25+
const { Debug } = require("webpack-strip-debug-loader")
26+
27+
const debug = Debug("feature")
2528
const debugFoo = Debug('foo')
2629

2730
if (somethingOfInterestHappens) {
28-
debug('something happened')
31+
debug("something happened")
2932
}
3033

3134
if (foo) {
32-
debugFoo('foo happened', foo)
35+
debugFoo(
36+
'foo happened',
37+
foo,
38+
{ ...foo }
39+
)
3340
}
3441
```
3542

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-strip-debug-loader",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Strips debug imports, declarations and expressions from your webpack bundles",
55
"main": "dist",
66
"repository": {

src/purge.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const purge = source => {
2-
// No Imports: /import\s.+\sfrom\s+'webpack-strip-debug-loader'|.*require\('webpack-strip-debug-loader'\).*/
3-
// No Declarations: /(var|let|const)?\s+debug(\w?)+\s*=\s*Debug\(.+\)/g
4-
// No Invocations: /\s*debug(\w?)+\s*?\(.+\)/g
2+
// No Imports: /import\s.+\sfrom\s+['"]webpack-strip-debug-loader['"]|.*require\(['"]webpack-strip-debug-loader['"]\).*/
3+
// No Declarations: /(var|let|const)?\s+debug(\w?)+\s*=\s*Debug\([\s\S]*?.*\)/g
4+
// No Invocations: /\s*debug(\w?)+\s*?\([\s\S]*?.*\)/g
55

66
return source.replace(
7-
/(import\s.+\sfrom\s+'webpack-strip-debug-loader'|.*require\('webpack-strip-debug-loader'\).*)|((var|let|const)?\s+debug(\w?)+\s*=\s*Debug\(.+\))|(\s*debug(\w?)+\s*?\(.+\))/g,
7+
/(import\s.+\sfrom\s+['"]webpack-strip-debug-loader['"]|.*require\(['"]webpack-strip-debug-loader['"]\).*)|((var|let|const)?\s+debug(\w?)+\s*=\s*Debug\([\s\S]*?.*\))|(\s*debug(\w?)+\s*?\([\s\S]*?.*\))/g,
88
'\n'
99
)
1010
}

0 commit comments

Comments
 (0)