Skip to content

Commit 0267e26

Browse files
committed
feat(src): Add production option to ScanOptions
1 parent af4b161 commit 0267e26

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const DEFAULT_OPTIONS: ScanOptions & WithScanOptions = {
1818
includeChildren: true,
1919
log: false,
2020
clearLog: false,
21+
production: false,
2122
};
2223
let currentOptions: ScanOptions & WithScanOptions = DEFAULT_OPTIONS;
2324
export const getCurrentOptions = () => currentOptions;
@@ -53,7 +54,10 @@ export const scan = (
5354
) => {
5455
currentOptions = options ?? currentOptions;
5556

56-
if (inited || isInIframe() || currentOptions.enabled === false || isProd()) {
57+
if (!currentOptions.production && isProd()) {
58+
return;
59+
}
60+
if (inited || isInIframe() || currentOptions.enabled === false) {
5761
return;
5862
}
5963
inited = true;

src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ export interface ScanOptions {
7373
* @default true
7474
*/
7575
log?: boolean;
76+
/**
77+
* Also run in production
78+
*
79+
* @default false
80+
*/
81+
production?: boolean;
7682
}
7783

7884
export interface WithScanOptions {

test/src/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ scan({
77
enabled: true,
88
log: true,
99
clearLog: true,
10+
production: true,
1011
});
1112

1213
export const App = () => {

0 commit comments

Comments
 (0)