Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bob): add ignore pattern to config #450

Merged
merged 5 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -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`
satya164 marked this conversation as resolved.
Show resolved Hide resolved

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 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 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are use the pattern of passing top-level options in the argument object (like source, output) and target specific options in the options field. So lets do the same for 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
1 change: 1 addition & 0 deletions packages/react-native-builder-bob/src/targets/commonjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Options = Input & {
configFile?: string | false | null;
sourceMaps?: boolean;
copyFlow?: boolean;
exclude?: string;
};
};

Expand Down
1 change: 1 addition & 0 deletions packages/react-native-builder-bob/src/targets/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Options = Input & {
configFile?: string | false | null;
sourceMaps?: boolean;
copyFlow?: boolean;
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;
};
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 @@ -11,6 +11,7 @@ type Options = Input & {
configFile?: string | false | null;
sourceMaps?: boolean;
copyFlow?: boolean;
exclude?: string;
modules: 'commonjs' | false;
field: 'main' | 'module';
};
Expand All @@ -21,6 +22,7 @@ export default async function compile({
output,
babelrc = false,
configFile = false,
exclude = '**/{__tests__,__fixtures__,__mocks__}/**',
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
Loading