resources/nodejs/bare-imports.js
// null if there was a parse error.
null if there was a parse error.
null if there was a parse error .
async function parseFile(filename) {
  const code = await util.promisify(fs.readFile)(filename, {
    encoding: "utf-8"
  });
  let ast;
  try {
    ast = babelParser.parse(code, {
      allowImportExportEverywhere: true,
      allowAwaitOutsideFunction: true,
      allowReturnOutsideFunction: true,
      allowSuperOutsideMethod: true,
      allowUndeclaredExports: true,
      sourceType: "unambiguous",
      plugins: [
        "asyncGenerators",
        "bigInt",
        "classProperties",
        "classPrivateProperties",
        "classPrivateMethods",
        "doExpressions",
        "dynamicImport",
        "exportDefaultFrom",
        "exportNamespaceFrom",
        "functionBind",
        "functionSent",
        "importMeta",
        "logicalAssignment",
        "nullishCoalescingOperator",
        "numericSeparator",
        "objectRestSpread",
        "optionalCatchBinding",
        "optionalChaining",
        "partialApplication",
        "throwExpressions"
      ]
    });
  } catch (err) {
    return null;
  }
  return parseNode(ast);
}
async function parseFile ( filename ) { const code = await util . promisify ( fs . readFile ) ( filename , { encoding : "utf-8" } ) ; let ast ; try { ast = babelParser . parse ( code , { allowImportExportEverywhere : true , allowAwaitOutsideFunction : true , allowReturnOutsideFunction : true , allowSuperOutsideMethod : true , allowUndeclaredExports : true , sourceType : "unambiguous" , plugins : [ "asyncGenerators" , "bigInt" , "classProperties" , "classPrivateProperties" , "classPrivateMethods" , "doExpressions" , "dynamicImport" , "exportDefaultFrom" , "exportNamespaceFrom" , "functionBind" , "functionSent" , "importMeta" , "logicalAssignment" , "nullishCoalescingOperator" , "numericSeparator" , "objectRestSpread" , "optionalCatchBinding" , "optionalChaining" , "partialApplication" , "throwExpressions" ] } ) ; } catch ( err ) { return null ; } return parseNode ( ast ) ; }
null if there was a parse error.
null if there was a parse error .
// Maximum permissibility because the bare imports search is // just to try to help out the user; we don't need the code to // be totally valid. See // <https://babeljs.io/docs/en/next/babel-parser.html>.