How to use es-module-lexer - 1 common examples

To help you get started, we’ve selected a few es-module-lexer 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 open-wc / open-wc / packages / es-dev-server / src / utils / resolve-module-imports.js View on Github external
export async function resolveModuleImports(rootDir, sourceFilePath, source, config) {
  let imports;
  try {
    [imports] = await parse(source, sourceFilePath);
  } catch (error) {
    await createSyntaxError(sourceFilePath, source, error);
  }

  let resolvedSource = '';
  let lastIndex = 0;

  for (const imp of imports) {
    const { s: start, e: end, d: dynamicImportIndex } = imp;

    if (dynamicImportIndex === -1) {
      // static import
      const [importPath, importPathSuffix] = getImportPath(source.substring(start, end));
      const resolvedImportPath = await resolveImport(rootDir, sourceFilePath, importPath, config);

      resolvedSource += `${source.substring(

es-module-lexer

Lexes ES modules returning their import/export metadata

MIT
Latest version published 5 months ago

Package Health Score

81 / 100
Full package analysis

Popular es-module-lexer functions