fix importing solidity files

pull/4018/head
yann300 1 year ago committed by Aniket
parent 3678c8c16e
commit aa7bb9aeaf
  1. 14
      libs/remix-solidity/src/compiler/compiler.ts

@ -367,20 +367,6 @@ export class Compiler {
gatherImports(files: Source, importHints?: string[], cb?: gatherImportsCallbackInterface): void {
importHints = importHints || []
// FIXME: This will only match imports if the file begins with one '.'
// It should tokenize by lines and check each.
const importRegex = /^\s*import\s*['"]([^'"]+)['"];/g
for (const fileName in files) {
let match: RegExpExecArray | null
while ((match = importRegex.exec(files[fileName].content))) {
let importFilePath = match[1]
if (importFilePath.startsWith('./')) {
const path: RegExpExecArray | null = /(.*\/).*/.exec(fileName)
importFilePath = path ? importFilePath.replace('./', path[1]) : importFilePath.slice(2)
}
if (!importHints.includes(importFilePath)) importHints.push(importFilePath)
}
}
while (importHints.length > 0) {
const m: string = importHints.pop() as string
if (m && m in files) continue

Loading…
Cancel
Save