• R/O
  • SSH

fcf: Commit

FCF - Full Stack Javascript Framework

OpenSource is a full stack development framework designed to simplify the development of WEB projects of various complexity levels.

It is based on unique technologies that open up new opportunities in development approaches with NODEJS.


Commit MetaInfo

Revisionb499417dd9ca332e4d8f56a272f80739f6d1dae3 (tree)
Zeit2021-06-12 00:49:28
Autorv.o.markin
Commiterv.o.markin

Log Message

Defining an error string in a server-side template

Ändern Zusammenfassung

Diff

diff -r 8f6ebb11719e -r b499417dd9ca NSystem/babel.js
--- a/NSystem/babel.js Fri Jun 11 16:17:41 2021 +0300
+++ b/NSystem/babel.js Fri Jun 11 18:49:28 2021 +0300
@@ -181,6 +181,44 @@
181181 })
182182 }
183183
184+ transformSync(a_code){
185+ let result = libBabel.transformSync(
186+ a_code,
187+ {
188+ code: true,
189+ sourceType: "script",
190+ root: fcf.getPath(":"),
191+ cwd: fcf.getPath(":"),
192+ presets: [],
193+ plugins: [
194+ "@babel/plugin-transform-block-scoped-functions",
195+ "@babel/plugin-transform-arrow-functions",
196+ "@babel/plugin-transform-duplicate-keys",
197+ "@babel/plugin-transform-block-scoping",
198+ "@babel/plugin-transform-classes",
199+ "@babel/plugin-transform-for-of",
200+ "@babel/plugin-transform-destructuring",
201+ "@babel/plugin-transform-computed-properties",
202+ "@babel/plugin-transform-function-name",
203+ "@babel/plugin-transform-instanceof",
204+ "@babel/plugin-transform-object-super",
205+ "@babel/plugin-transform-literals",
206+ "@babel/plugin-transform-parameters",
207+ "@babel/plugin-transform-shorthand-properties",
208+ "@babel/plugin-transform-spread",
209+ "@babel/plugin-transform-sticky-regex",
210+ "@babel/plugin-transform-template-literals",
211+ "@babel/plugin-transform-typeof-symbol",
212+ "@babel/plugin-transform-unicode-regex",
213+ "@babel/plugin-transform-async-to-generator",
214+ "@babel/plugin-transform-regenerator",
215+ "@babel/plugin-transform-property-mutators",
216+ "@babel/plugin-transform-member-expression-literals",
217+ ],
218+ }
219+ );
220+ return result.code;
221+ }
184222 };
185223
186224 Namespace.babel = new Babel();
diff -r 8f6ebb11719e -r b499417dd9ca fcf.js
--- a/fcf.js Fri Jun 11 16:17:41 2021 +0300
+++ b/fcf.js Fri Jun 11 18:49:28 2021 +0300
@@ -3420,31 +3420,26 @@
34203420 }
34213421
34223422 if (fcf.isServer() && line === undefined){
3423- let path = fcf.getPath(":cache/errors/" + fcf.uuid() + ".js");
3423+ let babel;
3424+ fcf.require(["fcf:NSystem/babel.js"]).then((a_modules)=>{ babel = a_modules[0] });
34243425 try {
3425- libFS.writeFileSync(path, handlerResult.code);
3426- try{
3427- libChildProcess.execSync("fcfnode " + process.cwd() + "/"+ path);
3428- }catch(e){
3429- let beg = e.message.indexOf("js:");
3430- if (beg != -1) {
3431- let end = e.message.indexOf("\n", beg);
3432- let strinfo = e.message.substr(beg+3, end - beg-3);
3433- strinfo = fcf.trim(strinfo, ")");
3434- if (strinfo)
3435- line = parseInt(strinfo) + a_startLine;
3436- }
3437- }
3438- try { libFS.unlinkSync(path) } catch(e) { }
3439- }catch(e){
3426+ babel.transformSync(a_code);
3427+ } catch(e){
3428+ let match = e.toString().match(/\(([0-9]*)/)
3429+ if (match)
3430+ line = parseInt(match[1]) + a_startLine;
3431+ line = !line && !a_startLine ? 0 :
3432+ !line ? a_startLine :
3433+ line;
3434+ throw new fcf.Exception("ERROR_EVAL_SCRIPT", [a_file, line], handlerResult.error);
34403435 }
34413436 }
34423437
3443-
34443438 line = !line && !a_startLine ? 0 :
34453439 !line ? a_startLine :
34463440 line;
3447- throw new fcf.Exception("ERROR_EVAL_SCRIPT", [a_file, line, ], handlerResult.error);
3441+ throw new fcf.Exception("ERROR_EVAL_SCRIPT", [a_file, line], handlerResult.error);
3442+
34483443 }
34493444 return handlerResult.result;
34503445 }
Show on old repository browser