Skip to content

Commit

Permalink
feat: make exclude a global option
Browse files Browse the repository at this point in the history
  • Loading branch information
atlj committed Sep 15, 2023
1 parent 69a88c9 commit 3af641b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ The options can be specified in the `package.json` file under the `react-native-

The name of the folder with the source code which should be compiled. The folder should include an `index` file.

#### `exclude`

Glob pattern to be used while filtering the unnecessary files. Defaults to `'**/{__tests__,__fixtures__,__mocks__}/**'` if you don't specify it.

> This option only works with `commonjs` and `module` targets. To exclude files while building `typescript`, please see [the tsconfig exclude field](https://www.typescriptlang.org/tsconfig#exclude).
Example:

```json
{
"exclude": "ignore_me/**"
}
```

#### `output`

The name of the folder where the compiled files should be output to. It will contain separate folder for each target.
Expand All @@ -161,8 +175,6 @@ In addition, the following options are supported:

- `sourceMaps` (`boolean`): Sourcemaps are generated by default alongside the compiled files. You can disable them by setting the `sourceMaps` option to `false`.

- `ignorePattern` (`string`): Glob pattern to be used while filtering the unnecessary files. Defaults to `'**/{__tests__,__fixtures__,__mocks__}/**'` if you don't specify it.

Example:

```json
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-builder-bob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ yargs
root,
source: path.resolve(root, source as string),
output: path.resolve(root, output as string, 'commonjs'),
options: targetOptions,
options: { ...targetOptions, exclude: options.exclude },
report,
});
break;
Expand All @@ -427,7 +427,7 @@ yargs
root,
source: path.resolve(root, source as string),
output: path.resolve(root, output as string, 'module'),
options: targetOptions,
options: { ...targetOptions, exclude: options.exclude },
report,
});
break;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-builder-bob/src/targets/commonjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Options = Input & {
configFile?: string | false | null;
sourceMaps?: boolean;
copyFlow?: boolean;
ignorePattern?: string;
exclude?: string;
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-builder-bob/src/targets/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Options = Input & {
configFile?: string | false | null;
sourceMaps?: boolean;
copyFlow?: boolean;
ignorePattern?: string;
exclude?: string;
};
};

Expand Down
1 change: 1 addition & 0 deletions packages/react-native-builder-bob/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export type Options = {
source?: string;
output?: string;
targets?: (Target | [Target, object])[];
exclude?: string;
};
6 changes: 3 additions & 3 deletions packages/react-native-builder-bob/src/utils/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Options = Input & {
configFile?: string | false | null;
sourceMaps?: boolean;
copyFlow?: boolean;
ignorePattern?: string;
exclude?: string;
modules: 'commonjs' | false;
field: 'main' | 'module';
};
Expand All @@ -22,7 +22,7 @@ export default async function compile({
output,
babelrc = false,
configFile = false,
ignorePattern = '**/{__tests__,__fixtures__,__mocks__}/**',
exclude = '**/{__tests__,__fixtures__,__mocks__}/**',
modules,
copyFlow,
sourceMaps = true,
Expand All @@ -33,7 +33,7 @@ export default async function compile({
cwd: source,
absolute: true,
nodir: true,
ignore: ignorePattern,
ignore: exclude,
});

report.info(
Expand Down

0 comments on commit 3af641b

Please sign in to comment.