Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// JS polyfills for JSC
// Temporary backport of https://github.com/facebook/react-native/blob/v0.55.3/rn-get-polyfills.js
const polyfills = [
require.resolve('../vendor/polyfills/Object.es6.js'),
require.resolve('../vendor/polyfills/console.js'),
require.resolve('../vendor/polyfills/error-guard.js'),
require.resolve('../vendor/polyfills/Number.es6.js'),
require.resolve('../vendor/polyfills/String.prototype.es6.js'),
require.resolve('../vendor/polyfills/Array.prototype.es6.js'),
require.resolve('../vendor/polyfills/Array.es6.js'),
require.resolve('../vendor/polyfills/Object.es7.js'),
];
export const withPolyfills = withPolyfillsFactory(polyfills);
export const makeConfig = makeConfigFactory(getDefaultConfig);
import getDefaultConfig from './defaultConfig';
// JS polyfills for JSC
// Temporary backport of https://github.com/facebook/react-native/blob/v0.55.3/rn-get-polyfills.js
const polyfills = [
require.resolve('../vendor/polyfills/Object.es6.js'),
require.resolve('../vendor/polyfills/console.js'),
require.resolve('../vendor/polyfills/error-guard.js'),
require.resolve('../vendor/polyfills/Number.es6.js'),
require.resolve('../vendor/polyfills/String.prototype.es6.js'),
require.resolve('../vendor/polyfills/Array.prototype.es6.js'),
require.resolve('../vendor/polyfills/Array.es6.js'),
require.resolve('../vendor/polyfills/Object.es7.js'),
];
export const withPolyfills = withPolyfillsFactory(polyfills);
export const makeConfig = makeConfigFactory(getDefaultConfig);
async function bundle(opts: *) {
const directory = process.cwd();
// Need to add @babel/register to support ES2015+ in config file.
require('../babelRegister');
const configPath = getProjectConfigPath(directory, opts.config);
const projectConfig = getProjectConfig(configPath);
const config = getWebpackConfig(
new Runtime(),
{
platform: opts.platform,
root: directory,
dev: opts.dev,
minify: opts.minify,
bundle: true,
},
projectConfig
);
if (opts.assetsDest) {
config.output.path = path.isAbsolute(opts.assetsDest)
? opts.assetsDest
async function bundle(opts: *) {
const directory = process.cwd();
// Need to add @babel/register to support ES2015+ in config file.
require('../babelRegister');
const configPath = getProjectConfigPath(directory, opts.config);
const projectConfig = getProjectConfig(configPath);
const config = getWebpackConfig(
new Runtime(),
{
platform: opts.platform,
root: directory,
dev: opts.dev,
minify: opts.minify,
bundle: true,
},
projectConfig
);
if (opts.assetsDest) {
config.output.path = path.isAbsolute(opts.assetsDest)
? opts.assetsDest
: path.join(directory, opts.assetsDest);
}
export default async function main() {
const {
HAUL_INSPECTOR,
HAUL_INSPECTOR_PORT,
HAUL_INSPECTOR_HOST,
NODE_INSPECTOR,
} = process.env;
let { haulInspector, nodeInspector } = yargsParser(process.argv);
haulInspector = haulInspector || HAUL_INSPECTOR;
nodeInspector = nodeInspector || NODE_INSPECTOR;
const runtime = new Runtime(
haulInspector || HAUL_INSPECTOR_PORT || HAUL_INSPECTOR_HOST
? new InspectorClient(HAUL_INSPECTOR_HOST, HAUL_INSPECTOR_PORT)
: undefined
);
await runtime.ready(haulInspector === 'wait');
// Experimental
if (nodeInspector) {
const wait = nodeInspector === 'wait';
runtime.nodeInspectorStarted(wait);
const inspector = require('inspector');
inspector.open(undefined, undefined, wait);
}
[
async function checkProject(progress: Ora, cwd: string, runtime: Runtime) {
progress.start('Checking project files');
await delay(1000);
// Are we inside a React Native project?
if (getReactNativeVersion(cwd)) {
progress.succeed('Project looks good');
} else {
progress.fail(dedent`
This doesn't seem to be a React Native project.
Make sure you have a ${runtime.logger.enhanceWithModifier(
'bold',
'package.json'
)} file with ${runtime.logger.enhanceWithModifier(
'bold',
'react-native'
)} in dependencies, and you have installed these dependencies.
To generate a React Native project, run ${runtime.logger.enhanceWithModifier(
'bold',
'react-native init '
path: assetsDest || root,
publicPath: `http://${host}:${port}/`,
globalObject: 'this',
},
module: {
rules: [
{ parser: { requireEnsure: false } },
{
test: /\.[jt]sx?$/,
// eslint-disable-next-line no-useless-escape
exclude: /node_modules(?!.*[\/\\](react|@react-navigation|@react-native-community|@expo|pretty-format|@haul-bundler|metro))/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
extends: getBabelConfigPath(root),
plugins: [
require.resolve(
'@haul-bundler/core/build/utils/fixRequireIssues'
),
],
/**
* to improve the rebuild speeds
* This enables caching results in ./node_modules/.cache/babel-loader//
* This is a feature of `babel-loader` and not babel
*/
cacheDirectory: dev
? path.join(
root,
'node_modules',
'.cache',
'babel-loader',
path: assetsDest || root,
publicPath: `http://${host}:${port}/`,
globalObject: 'this',
},
module: {
rules: [
{ parser: { requireEnsure: false } },
{
test: /\.[jt]sx?$/,
// eslint-disable-next-line no-useless-escape
exclude: /node_modules(?!.*[\/\\](react|@react-navigation|@react-native-community|@expo|pretty-format|@haul-bundler|metro))/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
extends: getBabelConfigPath(root),
plugins: [
require.resolve(
'@haul-bundler/core/build/utils/fixRequireIssues'
),
],
/**
* to improve the rebuild speeds
* This enables caching results in ./node_modules/.cache/babel-loader/
* This is a feature of `babel-loader` and not babel
*/
cacheDirectory: dev
? path.join(
root,
'node_modules',
'.cache',
'babel-loader',
'gray',
bundleConfig.external.bundlePath
)
);
if (bundleConfig.dll) {
runtime.logger.info(
'Manifest path',
runtime.logger.enhanceWithColor(
'gray',
bundleConfig.external.manifestPath
)
);
}
if (bundleConfig.external.copyBundle) {
const filename = getBundleFilename(
env,
projectConfig.templates,
projectConfig.bundles[bundleName]
);
// `bundleOutput` should be a directory, but for backward-compatibility,
// we also handle the case with a filename.
let bundleOutputDirectory = bundleConfig.root;
if (env.bundleOutput) {
bundleOutputDirectory =
path.extname(env.bundleOutput) === ''
? env.bundleOutput
: path.dirname(env.bundleOutput);
bundleOutputDirectory = path.isAbsolute(bundleOutputDirectory)
? bundleOutputDirectory
: path.join(bundleConfig.root, bundleOutputDirectory);
}
export default async function main() {
const {
HAUL_INSPECTOR,
HAUL_INSPECTOR_PORT,
HAUL_INSPECTOR_HOST,
NODE_INSPECTOR,
} = process.env;
let { haulInspector, nodeInspector } = yargsParser(process.argv);
haulInspector = haulInspector || HAUL_INSPECTOR;
nodeInspector = nodeInspector || NODE_INSPECTOR;
const runtime = new Runtime(
haulInspector || HAUL_INSPECTOR_PORT || HAUL_INSPECTOR_HOST
? new InspectorClient(HAUL_INSPECTOR_HOST, HAUL_INSPECTOR_PORT)
: undefined
);
await runtime.ready(haulInspector === 'wait');
// Experimental
if (nodeInspector) {
const wait = nodeInspector === 'wait';
runtime.nodeInspectorStarted(wait);
const inspector = require('inspector');
inspector.open(undefined, undefined, wait);
}
[
initCommand,
bundleCommand,