packages/bsb-js/index.js
function compileFile(
  buildDir /*: string */,
  moduleType /*: BsModuleFormat | 'js' */,
  path /*: string */,
  id /*: ?string */ = null,
) /*: Promise<Compilation> */ {
  if (id && buildRuns[id] !== undefined) {
    buildRuns[id] = runBuild(buildDir)
  }

  const buildProcess = id ? buildRuns[id] : runBuild(buildDir)

  return buildProcess
    .then(
      output =>
        new Promise((resolve, reject) => {
          readFile(path, (err, res) => {
            if (err) {
              resolve({
                src: undefined,
                warnings: [],
                errors: [err],
              })
            } else {
              const src = utils.transformSrc(moduleType, res.toString())

              resolve({
                src,
                warnings: utils.processBsbWarnings(output),
                errors: [],
              })
            }
          })
        }),
    )
    .catch(err => ({
      src: undefined,
      warnings: [],
      errors: utils.processBsbError(err),
    }))
}
function compileFile(
  buildDir /*: string */,
  moduleType /*: BsModuleFormat | 'js' */,
  path /*: string */,
  id /*: ?string */ = null,
) /*: Promise<Compilation> */ {
  if (id && buildRuns[id] !== undefined) {
    buildRuns[id] = runBuild(buildDir)
  }

  const buildProcess = id ? buildRuns[id] : runBuild(buildDir)

  return buildProcess
    .then(
      output =>
        new Promise((resolve, reject) => {
          readFile(path, (err, res) => {
            if (err) {
              resolve({
                src: undefined,
                warnings: [],
                errors: [err],
              })
            } else {
              const src = utils.transformSrc(moduleType, res.toString())

              resolve({
                src,
                warnings: utils.processBsbWarnings(output),
                errors: [],
              })
            }
          })
        }),
    )
    .catch(err => ({
      src: undefined,
      warnings: [],
      errors: utils.processBsbError(err),
    }))
}
function compileFile ( buildDir /*: string */ , moduleType /*: BsModuleFormat | 'js' */ , path /*: string */ , id /*: ?string */ = null , ) /*: Promise<Compilation> */ { if ( id && buildRuns [ id ] !== undefined ) { buildRuns [ id ] = runBuild ( buildDir ) } const buildProcess = id ? buildRuns [ id ] : runBuild ( buildDir ) return buildProcess . then ( output => new Promise ( ( resolve , reject ) => { readFile ( path , ( err , res ) => { if ( err ) { resolve ( { src : undefined , warnings : [ ] , errors : [ err ] , } ) } else { const src = utils . transformSrc ( moduleType , res . toString ( ) ) resolve ( { src , warnings : utils . processBsbWarnings ( output ) , errors : [ ] , } ) } } ) } ) , ) . catch ( err => ( { src : undefined , warnings : [ ] , errors : utils . processBsbError ( err ) , } ) ) }
Compiles a Reason file to JS
Compiles a Reason file to JS