Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ The name of the folder with the source code which should be compiled. The folder

The name of the folder where the compiled files should be output to. It will contain separate folder for each target.

#### `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/**"
}
```

#### `targets`

Various targets to build for. The available targets are:
Expand Down
5 changes: 5 additions & 0 deletions packages/react-native-builder-bob/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ yargs
);
}

const exclude =
options.exclude ?? '**/{__tests__,__fixtures__,__mocks__}/**';

const report = {
info: logger.info,
warn: logger.warn,
Expand Down Expand Up @@ -418,6 +421,7 @@ yargs
root,
source: path.resolve(root, source as string),
output: path.resolve(root, output as string, 'commonjs'),
exclude,
options: targetOptions,
report,
});
Expand All @@ -427,6 +431,7 @@ yargs
root,
source: path.resolve(root, source as string),
output: path.resolve(root, output as string, 'module'),
exclude,
options: targetOptions,
report,
});
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native-builder-bob/src/targets/commonjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ type Options = Input & {
sourceMaps?: boolean;
copyFlow?: boolean;
};
exclude: string;
};

export default async function build({
root,
source,
output,
exclude,
options,
report,
}: Options) {
Expand All @@ -31,6 +33,7 @@ export default async function build({
root,
source,
output,
exclude,
modules: 'commonjs',
report,
field: 'main',
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native-builder-bob/src/targets/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ type Options = Input & {
sourceMaps?: boolean;
copyFlow?: boolean;
};
exclude: string;
};

export default async function build({
root,
source,
output,
exclude,
options,
report,
}: Options) {
Expand All @@ -31,6 +33,7 @@ export default async function build({
root,
source,
output,
exclude,
modules: false,
report,
field: 'module',
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;
};
4 changes: 3 additions & 1 deletion packages/react-native-builder-bob/src/utils/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Options = Input & {
copyFlow?: boolean;
modules: 'commonjs' | false;
field: 'main' | 'module';
exclude: string;
};

export default async function compile({
Expand All @@ -21,6 +22,7 @@ export default async function compile({
output,
babelrc = false,
configFile = false,
exclude,
modules,
copyFlow,
sourceMaps = true,
Expand All @@ -31,7 +33,7 @@ export default async function compile({
cwd: source,
absolute: true,
nodir: true,
ignore: '**/{__tests__,__fixtures__,__mocks__}/**',
ignore: exclude,
});

report.info(
Expand Down