react-native-builder-bob 0.28.0 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/babel-config.js +22 -13
  2. package/package.json +2 -2
package/babel-config.js CHANGED
@@ -1,6 +1,9 @@
1
1
  /* eslint-disable import/no-commonjs */
2
2
 
3
3
  const path = require('path');
4
+ const { cosmiconfigSync } = require('cosmiconfig');
5
+ const { lstatSync } = require('fs');
6
+ const { name } = require('./package.json');
4
7
 
5
8
  /**
6
9
  * Get Babel configuration for the example project.
@@ -14,22 +17,28 @@ const path = require('path');
14
17
  * @returns {import('@babel/core').TransformOptions} Babel configuration
15
18
  */
16
19
  const getConfig = (defaultConfig, { root, pkg }) => {
17
- let src;
20
+ const explorer = cosmiconfigSync(name, {
21
+ stopDir: root,
22
+ searchPlaces: ['package.json', 'bob.config.cjs', 'bob.config.js'],
23
+ });
18
24
 
19
- if (pkg.source.includes('/')) {
20
- const segments = pkg.source.split('/');
21
-
22
- if (segments[0] === '.') {
23
- segments.shift();
24
- }
25
-
26
- src = segments[0];
27
- }
25
+ const result = explorer.search();
26
+ const src = result ? result.config.source : null;
28
27
 
29
28
  if (src == null) {
30
- throw new Error(
31
- "Couldn't determine the source directory. Does the 'source' field in your 'package.json' point to a file within a directory?"
32
- );
29
+ if (
30
+ lstatSync(path.join(root, 'bob.config.mjs'), {
31
+ throwIfNoEntry: false,
32
+ }).isFile()
33
+ ) {
34
+ throw new Error(
35
+ "Found a 'bob.config.mjs' file. However, ESM syntax is currently not supported for the Babel configuration."
36
+ );
37
+ } else {
38
+ throw new Error(
39
+ "Couldn't determine the source directory. Does your config specify a 'source' field?"
40
+ );
41
+ }
33
42
  }
34
43
 
35
44
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-builder-bob",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "CLI to build JavaScript files for React Native libraries",
5
5
  "keywords": [
6
6
  "react-native",
@@ -85,5 +85,5 @@
85
85
  "concurrently": "^7.2.2",
86
86
  "jest": "^29.7.0"
87
87
  },
88
- "gitHead": "be426bb86dd4d3576bd7bf246d77d25a4a6cc698"
88
+ "gitHead": "cc30f7f041869cf0d66e826e02b377363a9af55c"
89
89
  }