lilact 0.26.13 → 0.26.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lilact",
3
- "version": "0.26.13",
3
+ "version": "0.26.15",
4
4
  "description": "A Little React/JSX Runtime Implementation for Browser",
5
5
  "repository": "github:arashkazemi/lilact",
6
6
  "homepage": "https://arashkazemi.github.io/lilact/",
@@ -43,6 +43,7 @@ function createLilactJsxPlugin({ mode }) {
43
43
  const out = transpileJSX(source, {
44
44
  path: args.path,
45
45
  appendSourcemap: DEBUG,
46
+ logErrors: true
46
47
  });
47
48
 
48
49
  return { contents: out, loader: "js" };
package/src/errors.jsx CHANGED
@@ -137,7 +137,7 @@ export function scanBlockLabels(code, path)
137
137
  * @returns A new object that includes `path`, `row`, `col`, `msg`, `name`, and optional `stack`.
138
138
  * The exception itself is stored as `err`.
139
139
  */
140
- export function traceError(error)
140
+ export function traceError(error, run_path)
141
141
  {
142
142
  if(error?.is_traced) {
143
143
  return error;
@@ -146,7 +146,7 @@ export function traceError(error)
146
146
  const loc = parseEvalLocationFromStack(error.stack);
147
147
 
148
148
  const obj = {
149
- fileName: loc.url?.slice(6) || error.fileName,
149
+ fileName: loc.url?.slice(6) || run_path || error.fileName,
150
150
 
151
151
  lineNumber: loc.line,
152
152
  columnNumber: loc.col,
@@ -173,37 +173,44 @@ export function traceError(error)
173
173
  obj.lineNumber = mloc.line;
174
174
  obj.columnNumber = mloc.col;
175
175
  }
176
- else if( error.lilact_trace!==undefined) {
176
+ else {
177
177
 
178
178
  let loc = getErrorLocation(error);
179
179
 
180
- let mps;
181
- let blk;
180
+ if( error.lilact_trace!==undefined) {
181
+ let mps;
182
+ let blk;
182
183
 
183
- if(typeof(error.lilact_trace)==='object') {
184
- blk = Lilact.blocks_info.labels[error.lilact_trace[0]];
185
- }
186
- else {
187
- blk = Lilact.blocks_info.labels[error.lilact_trace];
188
- }
189
-
190
- if(blk) {
191
- obj.fileName = blk.path;
192
- obj.label = blk.label;
184
+ if(typeof(error.lilact_trace)==='object') {
185
+ blk = Lilact.blocks_info.labels[error.lilact_trace[0]];
186
+ }
187
+ else {
188
+ blk = Lilact.blocks_info.labels[error.lilact_trace];
189
+ }
193
190
 
194
- mps = required_scripts[blk.path].mappings;
191
+ if(blk) {
192
+ obj.fileName = blk.path;
193
+ obj.label = blk.label;
195
194
 
196
- loc = mapLocation(mps, loc.line-1, loc.col-1);
195
+ mps = required_scripts[blk.path].mappings;
197
196
 
198
- obj.lineNumber = loc.line;
199
- obj.columnNumber = loc.col;
197
+ loc = mapLocation(mps, loc.line-1, loc.col-1);
198
+ }
200
199
  }
200
+
201
+ obj.lineNumber = loc.line;
202
+ obj.columnNumber = loc.col;
201
203
  }
202
204
 
203
205
  }
204
206
  else {
205
207
  const loc = getErrorLocation(error);
206
- if(error.fileName) obj.fileName = error.fileName;
208
+
209
+ //if(!obj.fileName) {
210
+ if(error.fileName) obj.fileName = error.fileName;
211
+ else if(run_path) obj.fileName = run_path;
212
+ //}
213
+
207
214
  obj.lineNumber = loc.line;
208
215
  obj.columnNumber = loc.col;
209
216
  }
package/src/jsx.js CHANGED
@@ -976,6 +976,7 @@ export function transpileJSX( jsx, {
976
976
  discardComments = false,
977
977
 
978
978
  produceCJS = false,
979
+ logErrors = false,
979
980
 
980
981
  // lilact internal
981
982
  blocks_info = {
@@ -992,9 +993,12 @@ export function transpileJSX( jsx, {
992
993
  const eols = scanEOLs(jsx);
993
994
 
994
995
  raiseError = ((eols, msg, index)=>{
996
+ const rc = getRowCol(eols, index);
997
+
995
998
  const er = new Error(msg);
999
+ if(logErrors) console.error(`JSXParserError: ${msg} [file ${path} at line ${rc[0]}]`);
1000
+ [er.lineNumber, er.columnNumber] = rc;
996
1001
  er.name = 'JSXParseError';
997
- [er.lineNumber, er.columnNumber] = getRowCol(eols, index);
998
1002
  er.fileName = path;
999
1003
  er.lilact_trace = 'parse';
1000
1004
  throw er;
package/src/run.jsx CHANGED
@@ -129,7 +129,7 @@ if(DEBUG) {
129
129
  return res;
130
130
  }
131
131
  catch(e) {
132
- e = Lilact.traceError(e);
132
+ e = Lilact.traceError(e, path);
133
133
  throw e;
134
134
  }
135
135
  }