How to use parcel - 7 common examples

To help you get started, we’ve selected a few parcel 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 commercetools / nodejs / packages / csv-parser-orders / src / parsers / deliveries.js View on Github external
static _parseParcelInfo(data) {
    const transitionMap = {
      'parcel.height': 'measurements.heightInMillimeter',
      'parcel.length': 'measurements.lengthInMillimeter',
      'parcel.width': 'measurements.widthInMillimeter',
      'parcel.weight': 'measurements.weightInGram',
      'parcel.trackingId': 'trackingData.trackingId',
      'parcel.providerTransaction': 'trackingData.providerTransaction',
      'parcel.provider': 'trackingData.provider',
      'parcel.carrier': 'trackingData.carrier',
      'parcel.isReturn': 'trackingData.isReturn',
      'parcel.items': 'items',
    }

    const parcel = {
      id: data['parcel.id'],
    }

    // Build parcel object
    Object.keys(data).forEach(fieldName => {
      if (!transitionMap[fieldName]) return

      // All values are loaded as a string
      let fieldValue = data[fieldName]

      // do not set empty values
      if (fieldValue === '') return

      // Cast measurements to Number
      if (/^measurements/.test(transitionMap[fieldName]))
        fieldValue = Number(fieldValue)
github commercetools / nodejs / packages / csv-parser-orders / src / parsers / deliveries.js View on Github external
// Basic delivery object with delivery item
    const delivery = {
      id: data['delivery.id'],
      items: [
        {
          // there can be multiple delivery items with same item.id and
          // item.quantity therefore we use unique identifier _itemGroupId
          _groupId: data._itemGroupId,
          id: data['item.id'],
          quantity: parseInt(data['item.quantity'], 10),
        },
      ],
    }

    // Add parcel info if it is present
    if (data['parcel.id']) {
      const parcel = DeliveriesParser._parseParcelInfo(data)

      if (parcel.measurements && Object.keys(parcel.measurements).length !== 4)
        return Promise.reject(new Error('All measurement fields are mandatory'))

      delivery.parcels = [parcel]
    }

    const order = {
      orderNumber: data.orderNumber,
      shippingInfo: {
        deliveries: [delivery],
      },
    }
    return Promise.resolve(order)
  }
github zeit / next.js / packages / next-build / index.js View on Github external
function getPageFiles({dir, config, isClient, entrypoint}) {
  let result = []
  if(entrypoint) {
    if(isClient) {
      result = glob.sync(`pages(_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })      
    } else {
      result = glob.sync(`pages(_document|_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })            
    }
    result = [...result, ...glob.sync(entrypoint, { cwd: dir, absolute: true })]
  } else {
    result = glob.sync(`pages/**/${isClient ? '!(_document)' : ''}*.+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })
  }
  const appPath = path.join(dir, 'pages', '_app.js')
  if(!result.some((item) => item === appPath)) {
    result.push(require.resolve('next/dist/pages/_app.js'))
  }

  const errorPath = path.join(dir, 'pages', '_error.js')
  if(!result.some((item) => item === errorPath)) {
    result.push(require.resolve('next/dist/pages/_error.js'))
  }
github zeit / next.js / packages / next-build / index.js View on Github external
function getPageFiles({dir, config, isClient, entrypoint}) {
  let result = []
  if(entrypoint) {
    if(isClient) {
      result = glob.sync(`pages(_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })      
    } else {
      result = glob.sync(`pages(_document|_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })            
    }
    result = [...result, ...glob.sync(entrypoint, { cwd: dir, absolute: true })]
  } else {
    result = glob.sync(`pages/**/${isClient ? '!(_document)' : ''}*.+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })
  }
  const appPath = path.join(dir, 'pages', '_app.js')
  if(!result.some((item) => item === appPath)) {
    result.push(require.resolve('next/dist/pages/_app.js'))
  }

  const errorPath = path.join(dir, 'pages', '_error.js')
  if(!result.some((item) => item === errorPath)) {
    result.push(require.resolve('next/dist/pages/_error.js'))
  }

  if(!isClient) {
    const documentPath = path.join(dir, 'pages', '_document.js')
    if(!result.some((item) => item === documentPath)) {
github zeit / next.js / packages / next-build / index.js View on Github external
function getPageFiles({dir, config, isClient, entrypoint}) {
  let result = []
  if(entrypoint) {
    if(isClient) {
      result = glob.sync(`pages(_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })      
    } else {
      result = glob.sync(`pages(_document|_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })            
    }
    result = [...result, ...glob.sync(entrypoint, { cwd: dir, absolute: true })]
  } else {
    result = glob.sync(`pages/**/${isClient ? '!(_document)' : ''}*.+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })
  }
  const appPath = path.join(dir, 'pages', '_app.js')
  if(!result.some((item) => item === appPath)) {
    result.push(require.resolve('next/dist/pages/_app.js'))
  }

  const errorPath = path.join(dir, 'pages', '_error.js')
  if(!result.some((item) => item === errorPath)) {
    result.push(require.resolve('next/dist/pages/_error.js'))
  }

  if(!isClient) {
github zeit / next.js / packages / next-build / index.js View on Github external
function getPageFiles({dir, config, isClient, entrypoint}) {
  let result = []
  if(entrypoint) {
    if(isClient) {
      result = glob.sync(`pages(_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })      
    } else {
      result = glob.sync(`pages(_document|_app|_error).+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })            
    }
    result = [...result, ...glob.sync(entrypoint, { cwd: dir, absolute: true })]
  } else {
    result = glob.sync(`pages/**/${isClient ? '!(_document)' : ''}*.+(${config.pageExtensions.join('|')})`, { cwd: dir, absolute: true })
  }
  const appPath = path.join(dir, 'pages', '_app.js')
  if(!result.some((item) => item === appPath)) {
    result.push(require.resolve('next/dist/pages/_app.js'))
  }

  const errorPath = path.join(dir, 'pages', '_error.js')
  if(!result.some((item) => item === errorPath)) {
    result.push(require.resolve('next/dist/pages/_error.js'))
  }

  if(!isClient) {
    const documentPath = path.join(dir, 'pages', '_document.js')
    if(!result.some((item) => item === documentPath)) {
      result.push(require.resolve('next/dist/pages/_document.js'))
    }
github DeMoorJasper / parcel-plugin-svelte / packages / parcel-plugin-svelte / lib / utils.js View on Github external
function getAssetClass() {
  try {
    return require('parcel').Asset;
  } catch (e) {
    return require('parcel-bundler').Asset;
  }
}

parcel

Blazing fast, zero configuration web application bundler

MIT
Latest version published 8 months ago

Package Health Score

87 / 100
Full package analysis