How to use @haul-bundler/core - 10 common examples

To help you get started, we’ve selected a few @haul-bundler/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github callstack / haul / packages / haul-preset-0.59 / src / index.ts View on Github external
// 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);
github callstack / haul / packages / haul-preset-0.59 / src / index.ts View on Github external
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);
github callstack / haul / packages / haul-core-legacy / src / commands / bundle.js View on Github external
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
github callstack / haul / packages / haul-core-legacy / src / commands / bundle.js View on Github external
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);
  }
github callstack / haul / packages / haul-cli / src / main.ts View on Github external
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);
  }

  [
github callstack / haul / packages / haul-cli / src / commands / init.ts View on Github external
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 '
github callstack / haul / packages / haul-preset-0.59 / src / defaultConfig.ts View on Github external
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',
github callstack / haul / packages / haul-preset-0.60 / src / defaultConfig.ts View on Github external
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',
github callstack / haul / packages / haul-cli / src / commands / multiBundle.ts View on Github external
'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);
              }
github callstack / haul / packages / haul-cli / src / main.ts View on Github external
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,