examples/webpack/example-builder.js
function getDependencies(jsSource) {
  const lines = jsSource.split('\n');
  const dependencies = {
    ol: pkg.version
  };
  for (let i = 0, ii = lines.length; i < ii; ++i) {
    const line = lines[i];
    const importMatch = line.match(importRegEx);
    if (importMatch) {
      const imp = importMatch[1];
      if (!imp.startsWith('ol/') && imp != 'ol') {
        const parts = imp.split('/');
        let dep;
        if (imp.startsWith('@')) {
          dep = parts.slice(0, 2).join('/');
        } else {
          dep = parts[0];
        }
        if (dep in pkg.devDependencies) {
          dependencies[dep] = pkg.devDependencies[dep];
        }
      }
    }
  }
  return dependencies;
}
function getDependencies(jsSource) {
  const lines = jsSource.split('\n');
  const dependencies = {
    ol: pkg.version
  };
  for (let i = 0, ii = lines.length; i < ii; ++i) {
    const line = lines[i];
    const importMatch = line.match(importRegEx);
    if (importMatch) {
      const imp = importMatch[1];
      if (!imp.startsWith('ol/') && imp != 'ol') {
        const parts = imp.split('/');
        let dep;
        if (imp.startsWith('@')) {
          dep = parts.slice(0, 2).join('/');
        } else {
          dep = parts[0];
        }
        if (dep in pkg.devDependencies) {
          dependencies[dep] = pkg.devDependencies[dep];
        }
      }
    }
  }
  return dependencies;
}
function getDependencies ( jsSource ) { const lines = jsSource . split ( '\n' ) ; const dependencies = { ol : pkg . version } ; for ( let i = 0 , ii = lines . length ; i < ii ; ++ i ) { const line = lines [ i ] ; const importMatch = line . match ( importRegEx ) ; if ( importMatch ) { const imp = importMatch [ 1 ] ; if ( ! imp . startsWith ( 'ol/' ) && imp != 'ol' ) { const parts = imp . split ( '/' ) ; let dep ; if ( imp . startsWith ( '@' ) ) { dep = parts . slice ( 0 , 2 ) . join ( '/' ) ; } else { dep = parts [ 0 ] ; } if ( dep in pkg . devDependencies ) { dependencies [ dep ] = pkg . devDependencies [ dep ] ; } } } } return dependencies ; }
Gets dependencies from the js source.
@param {string} jsSource Source.
@return {Object<string, string>} dependencies
Gets dependencies from the js source .