diff --git a/Processor/File.js b/Processor/File.js index 371c523..a27ac6f 100644 --- a/Processor/File.js +++ b/Processor/File.js @@ -30,13 +30,14 @@ File.prototype.isRequiredRebuild = function(content){ }; File.prototype.execute = function(memoriable){ let output = []; - let t = new vm.Script(this.parsedContent,{ + let t = new vm.Script(this.parsedContent.ast,{ cachedData: this.cachedData, }); let content = vm.createContext({ ...memoriable, output, - echo:(...args) => output.push(...args) + echo:(...args) => output.push(...args), + _external: e => {} }); t.runInContext(content); this.cachedData = t.createCachedData(); diff --git a/Processor/Parse.js b/Processor/Parse.js index dddf075..2bf3e68 100644 --- a/Processor/Parse.js +++ b/Processor/Parse.js @@ -7,6 +7,7 @@ function ParseEngine(file) { let content = []; let buffer = []; + let requiredImports = []; let hmx = new Hemex(); hmx.setText(file.content); function flushBuffer() @@ -319,7 +320,8 @@ function ParseEngine(file) break; } case "import":{ - jsContent.push(`output.push(${JSON.stringify(``)});\n`); + requiredImports.push(value); + jsContent.push(`_external(${value});\n`); break; } case "js-if-block":{ @@ -341,7 +343,10 @@ function ParseEngine(file) } return jsContent.join(''); } - return useAST(content); + return { + ast:useAST(content), + requiredImports + }; }; module.exports = ParseEngine; \ No newline at end of file diff --git a/source/abc.blade.php.cache b/source/abc.blade.php.cache index d191d40..2b1b19f 100644 Binary files a/source/abc.blade.php.cache and b/source/abc.blade.php.cache differ diff --git a/source/abc.blade.php.js b/source/abc.blade.php.js index 2480b78..986a8b3 100644 --- a/source/abc.blade.php.js +++ b/source/abc.blade.php.js @@ -1,5 +1,5 @@ output.push("\r\n\r\n
\r\n \r\n \r\n \r\n