How to use @parcel/package-manager - 4 common examples

To help you get started, we’ve selected a few @parcel/package-manager 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 parcel-bundler / parcel / packages / core / test-utils / src / utils.js View on Github external
export function bundler(
  entries: FilePath | Array<FilePath>,
  opts?: InitialParcelOptions,
) {
  return new Parcel({
    entries,
    disableCache: true,
    logLevel: 'none',
    defaultConfig,
    inputFS,
    outputFS,
    workerFarm,
    packageManager: new NodePackageManager(inputFS),
    defaultEngines: {
      browsers: ['last 1 Chrome version'],
      node: '8',
    },
    // $FlowFixMe
    ...opts,
  });
}
github parcel-bundler / parcel / packages / core / core / src / resolveOptions.js View on Github external
initialOptions: InitialParcelOptions
): Promise<ParcelOptions> {
  let entries: Array<FilePath>;
  if (initialOptions.entries == null || initialOptions.entries === '') {
    entries = [];
  } else if (Array.isArray(initialOptions.entries)) {
    entries = initialOptions.entries.map(entry => path.resolve(entry));
  } else {
    entries = [path.resolve(initialOptions.entries)];
  }

  let inputFS = initialOptions.inputFS || new NodeFS();
  let outputFS = initialOptions.outputFS || new NodeFS();

  let packageManager =
    initialOptions.packageManager || new NodePackageManager(inputFS);

  let rootDir =
    initialOptions.rootDir != null
      ? path.resolve(initialOptions.rootDir)
      : getRootDir(entries);

  let projectRootFile =
    (await resolveConfig(inputFS, path.join(rootDir, 'index'), [
      ...LOCK_FILE_NAMES,
      '.git',
      '.hg'
    ])) || path.join(inputFS.cwd(), 'index'); // ? Should this just be rootDir

  let lockFile = null;
  let rootFileName = path.basename(projectRootFile);
  if (LOCK_FILE_NAMES.includes(rootFileName)) {
github parcel-bundler / parcel / packages / core / register / src / register.js View on Github external
import {NodePackageManager} from '@parcel/package-manager';
import {NodeFS} from '@parcel/fs';
// $FlowFixMe this is untyped
import defaultConfigContents from '@parcel/config-default';
// $FlowFixMe this is untyped
import Module from 'module';
import path from 'path';
// $FlowFixMe this is untyped
import {addHook} from 'pirates';
import Parcel, {INTERNAL_RESOLVE, INTERNAL_TRANSFORM} from '@parcel/core';

import syncPromise from './syncPromise';

let hooks = {};
let lastDisposable;
let packageManager = new NodePackageManager(new NodeFS());
let defaultConfig = {
  ...defaultConfigContents,
  filePath: packageManager.resolveSync('@parcel/config-default', __filename)
    .resolved,
};

function register(inputOpts?: InitialParcelOptions): IDisposable {
  let opts: InitialParcelOptions = {
    ...defaultConfig,
    ...(inputOpts || {}),
  };

  // Replace old hook, as this one likely contains options.
  if (lastDisposable) {
    lastDisposable.dispose();
  }
github parcel-bundler / parcel / packages / core / parcel / src / cli.js View on Github external
async function run(entries: Array<string>, command: any) {
  entries = entries.map(entry => path.resolve(entry));

  if (entries.length === 0) {
    console.log('No entries found');
    return;
  }
  let Parcel = require('@parcel/core').default;
  let packageManager = new NodePackageManager(new NodeFS());
  let defaultConfig: ParcelConfigFile = await packageManager.require(
    '@parcel/config-default',
    __filename
  );
  let parcel = new Parcel({
    entries,
    packageManager,
    defaultConfig: {
      ...defaultConfig,
      filePath: (await packageManager.resolve(
        '@parcel/config-default',
        __filename
      )).resolved
    },
    patchConsole: true,
    ...(await normalizeOptions(command))

@parcel/package-manager

Blazing fast, zero configuration web application bundler

MIT
Latest version published 17 days ago

Package Health Score

94 / 100
Full package analysis

Popular @parcel/package-manager functions