Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-builder-bob

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-builder-bob - npm Package Compare versions

Comparing version 0.21.3 to 0.22.0

37

lib/index.js

@@ -21,4 +21,2 @@ "use strict";

var _aar = _interopRequireDefault(require("./targets/aar"));
var _commonjs = _interopRequireDefault(require("./targets/commonjs"));

@@ -44,3 +42,3 @@

const explorer = (0, _cosmiconfig.cosmiconfigSync)(name, {
searchPlaces: ['package.json', `bob.config.js`]
searchPlaces: ['package.json', `bob.config.js`, 'bob.config.cjs']
});

@@ -50,4 +48,2 @@ const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m; // eslint-disable-next-line babel/no-unused-expressions

_yargs.default.command('init', 'configure the package to use bob', {}, async () => {
var _pkg$scripts;
if ((0, _isGitDirty.default)()) {

@@ -77,3 +73,3 @@ const {

if (result !== null && result !== void 0 && result.config && pkg.devDependencies && name in pkg.devDependencies) {
if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {
const {

@@ -140,6 +136,2 @@ shouldContinue

selected: /\.tsx?$/.test(entryFile)
}, {
title: 'aar - bundle android code to a binary',
value: 'aar',
selected: false
}],

@@ -166,3 +158,4 @@ validate: input => Boolean(input.length)

'main': target ? _path.default.join(output, target, 'index.js') : _path.default.join(source, entryFile),
'react-native': _path.default.join(source, entryFile)
'react-native': _path.default.join(source, entryFile),
'source': _path.default.join(source, entryFile)
};

@@ -190,2 +183,3 @@

compilerOptions: {
rootDir: '.',
allowUnreachableCode: false,

@@ -241,3 +235,3 @@ allowUnusedLabels: false,

if ((_pkg$scripts = pkg.scripts) !== null && _pkg$scripts !== void 0 && _pkg$scripts.prepack && pkg.scripts.prepack !== prepack) {
if (pkg.scripts?.prepack && pkg.scripts.prepack !== prepack) {
const {

@@ -336,7 +330,5 @@ replace

}).command('build', 'build files for publishing', {}, async argv => {
var _options$targets;
const result = explorer.search();
if (!(result !== null && result !== void 0 && result.config)) {
if (!result?.config) {
logger.exit(`No configuration found. Run '${argv.$0} init' to create one automatically.`);

@@ -347,3 +339,3 @@ }

if (!((_options$targets = options.targets) !== null && _options$targets !== void 0 && _options$targets.length)) {
if (!options.targets?.length) {
logger.exit(`No targets found in the configuration in '${_path.default.relative(root, result.filepath)}'.`);

@@ -364,2 +356,3 @@ }

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

@@ -378,12 +371,2 @@ info: logger.info,

switch (targetName) {
case 'aar':
await (0, _aar.default)({
root,
source: _path.default.resolve(root, source),
output: _path.default.resolve(root, output, 'aar'),
options: targetOptions,
report
});
break;
case 'commonjs':

@@ -394,2 +377,3 @@ await (0, _commonjs.default)({

output: _path.default.resolve(root, output, 'commonjs'),
exclude,
options: targetOptions,

@@ -405,2 +389,3 @@ report

output: _path.default.resolve(root, output, 'module'),
exclude,
options: targetOptions,

@@ -407,0 +392,0 @@ report

@@ -22,2 +22,3 @@ "use strict";

output,
exclude,
options,

@@ -32,2 +33,3 @@ report

output,
exclude,
modules: 'commonjs',

@@ -34,0 +36,0 @@ report,

@@ -22,2 +22,3 @@ "use strict";

output,
exclude,
options,

@@ -32,2 +33,3 @@ report

output,
exclude,
modules: false,

@@ -34,0 +36,0 @@ report,

@@ -27,2 +27,3 @@ "use strict";

async function build({
source,
root,

@@ -36,3 +37,3 @@ output,

report.info(`Generating type definitions with ${_kleur.default.blue('tsc')}`);
const project = options !== null && options !== void 0 && options.project ? options.project : 'tsconfig.json';
const project = options?.project ? options.project : 'tsconfig.json';

@@ -78,3 +79,3 @@ const tsconfig = _path.default.join(root, project);

if (options !== null && options !== void 0 && options.tsc) {
if (options?.tsc) {
tsc = _path.default.resolve(root, options.tsc);

@@ -86,26 +87,14 @@

} else {
var _execpath$split$pop;
const execpath = process.env.npm_execpath;
const cli = execpath !== null && execpath !== void 0 && (_execpath$split$pop = execpath.split('/').pop()) !== null && _execpath$split$pop !== void 0 && _execpath$split$pop.includes('yarn') ? 'yarn' : 'npm';
const cli = execpath?.split('/').pop()?.includes('yarn') ? 'yarn' : 'npm';
try {
if (cli === 'yarn') {
const result = _crossSpawn.default.sync('yarn', ['bin', 'tsc'], {
stdio: 'pipe',
encoding: 'utf-8',
cwd: root
});
if (cli === 'yarn') {
const result = _crossSpawn.default.sync('yarn', ['bin', 'tsc'], {
stdio: 'pipe',
encoding: 'utf-8',
cwd: root
});
tsc = result.stdout.trim();
} else {
const result = _crossSpawn.default.sync('npm', ['bin'], {
stdio: 'pipe',
encoding: 'utf-8',
cwd: root
});
tsc = _path.default.resolve(result.stdout.trim(), 'tsc');
}
} catch (e) {
tsc = result.stdout.trim();
} else {
tsc = _path.default.resolve(root, 'node_modules', '.bin', 'tsc');

@@ -124,3 +113,3 @@ }

if (await _fsExtra.default.pathExists(tsc)) {
report.warn(`Failed to locate 'tsc' in the workspace. Falling back to the globally installed version. Consider adding ${_kleur.default.blue('typescript')} to your ${_kleur.default.blue('devDependencies')} or specifying the ${_kleur.default.blue('tsc')} option for the typescript target.`);
report.warn(`Failed to locate ${_kleur.default.blue('tsc')} in the workspace. Falling back to the binary found in ${_kleur.default.blue('PATH')} at ${_kleur.default.blue(tsc)}. Consider adding ${_kleur.default.blue('typescript')} to your ${_kleur.default.blue('devDependencies')} or specifying the ${_kleur.default.blue('tsc')} option for the typescript target.`);
}

@@ -152,16 +141,33 @@ } catch (e) {// Ignore

if ('types' in pkg) {
if (!pkg.types.endsWith('.d.ts')) {
report.error(`The ${_kleur.default.blue('types')} field in ${_kleur.default.blue('package.json')} doesn't point to a definition file. Verify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}.`);
throw new Error("Found incorrect path in 'types' field.");
const getGeneratedTypesPath = async () => {
if (pkg.source) {
const indexDTsName = _path.default.basename(pkg.source).replace(/\.(jsx?|tsx?)$/, '') + '.d.ts';
const potentialPaths = [_path.default.join(output, _path.default.dirname(pkg.source), indexDTsName), _path.default.join(output, _path.default.dirname(_path.default.relative(source, _path.default.join(root, pkg.source))), indexDTsName)];
for (const potentialPath of potentialPaths) {
if (await _fsExtra.default.pathExists(potentialPath)) {
return _path.default.relative(root, potentialPath);
}
}
}
return null;
};
if ('types' in pkg) {
const typesPath = _path.default.join(root, pkg.types);
if (!(await _fsExtra.default.pathExists(typesPath))) {
report.error(`The ${_kleur.default.blue('types')} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(pkg.types)}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}.`);
const generatedTypesPath = await getGeneratedTypesPath();
if (!generatedTypesPath) {
report.warn(`Failed to detect the entry point for the generated types. Make sure you have a valid ${_kleur.default.blue('source')} field in your ${_kleur.default.blue('package.json')}.`);
}
report.error(`The ${_kleur.default.blue('types')} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(pkg.types)}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}${generatedTypesPath ? ` (found ${_kleur.default.blue(generatedTypesPath)}).` : '.'}`);
throw new Error("Found incorrect path in 'types' field.");
}
} else {
report.warn(`No ${_kleur.default.blue('types')} field found in ${_kleur.default.blue('package.json')}.\nConsider adding it so consumers can use the types.`);
const generatedTypesPath = await getGeneratedTypesPath();
report.warn(`No ${_kleur.default.blue('types')} field found in ${_kleur.default.blue('package.json')}.\nConsider ${generatedTypesPath ? `pointing it to ${_kleur.default.blue(generatedTypesPath)}` : 'adding it'} so that consumers of your package can use the types.`);
}

@@ -168,0 +174,0 @@ } else {

@@ -32,2 +32,3 @@ "use strict";

configFile = false,
exclude,
modules,

@@ -43,3 +44,3 @@ copyFlow,

nodir: true,
ignore: '**/{__tests__,__fixtures__,__mocks__}/**'
ignore: exclude
});

@@ -81,3 +82,3 @@

browsers: ['>1%', 'last 2 chrome versions', 'last 2 edge versions', 'last 2 firefox versions', 'last 2 safari versions', 'not dead', 'not ie <= 11', 'not op_mini all', 'not android <= 4.4', 'not samsung <= 4'],
node: '16'
node: '18'
},

@@ -113,2 +114,16 @@ useBuiltIns: false,

const getGeneratedEntryPath = async () => {
if (pkg.source) {
const indexName = _path.default.basename(pkg.source).replace(/\.(jsx?|tsx?)$/, '') + '.js';
const potentialPath = _path.default.join(output, _path.default.dirname(_path.default.relative(source, _path.default.join(root, pkg.source))), indexName);
if (await _fsExtra.default.pathExists(potentialPath)) {
return _path.default.relative(root, potentialPath);
}
}
return null;
};
if (field in pkg) {

@@ -119,3 +134,9 @@ try {

if (e != null && typeof e === 'object' && 'code' in e && e.code === 'MODULE_NOT_FOUND') {
report.error(`The ${_kleur.default.blue(field)} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(pkg[field])}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}.`);
const generatedEntryPath = await getGeneratedEntryPath();
if (!generatedEntryPath) {
report.warn(`Failed to detect the entry point for the generated files. Make sure you have a valid ${_kleur.default.blue('source')} field in your ${_kleur.default.blue('package.json')}.`);
}
report.error(`The ${_kleur.default.blue(field)} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(pkg[field])}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}${generatedEntryPath ? ` (found ${_kleur.default.blue(generatedEntryPath)}).` : '.'}`);
throw new Error(`Found incorrect path in '${field}' field.`);

@@ -127,5 +148,6 @@ }

} else {
report.warn(`No ${_kleur.default.blue(field)} field found in ${_kleur.default.blue('package.json')}. Add it to your ${_kleur.default.blue('package.json')} so that consumers of your package can use it.`);
const generatedEntryPath = await getGeneratedEntryPath();
report.warn(`No ${_kleur.default.blue(field)} field found in ${_kleur.default.blue('package.json')}. Consider ${generatedEntryPath ? `pointing it to ${_kleur.default.blue(generatedEntryPath)}` : 'adding it'} so that consumers of your package can use it.`);
}
}
//# sourceMappingURL=compile.js.map
{
"name": "react-native-builder-bob",
"version": "0.21.3",
"version": "0.22.0",
"description": "CLI to build JavaScript files for React Native libraries",

@@ -29,3 +29,3 @@ "keywords": [

"engines": {
"node": ">= 16.0.0"
"node": ">= 18.0.0"
},

@@ -60,5 +60,2 @@ "publishConfig": {

},
"optionalDependencies": {
"jetifier": "^2.0.0"
},
"devDependencies": {

@@ -79,3 +76,3 @@ "@babel/cli": "^7.17.10",

},
"gitHead": "44df3f943f7c96bb022150348cfdfaa79a8fdca0"
"gitHead": "2a92f26b642637b853c0dfe7f59e2d561d6394af"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc