You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The errors generated by globalize-compiler are pretty cryptic and not useful when it fails to parse a file.
time.js
importGlobalizefrom'globalize';/** * Intl Format a short time string e.g. "9:30 AM" in en-US */exportconstformatTime=Globalize.dateFormatter({date: 'short'});
globalize-compiler -l en -o en.js time.js
Gives the following result:
{...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:5702
throw e;
^
Error: Line 1: Unexpected token
at constructError ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:2407:21)
at createError ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:2426:17)
at unexpectedTokenError ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:2500:13)
at tolerateUnexpectedToken ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:2509:21)
at parseStatementListItem ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:3973:21)
at parseScriptBody ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:5490:25)
at parseProgram ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:5506:16)
at Object.parse ({...}/node_modules/globalize-compiler/node_modules/esprima/esprima.js:5690:23)
at Object.extractor [as extract] ({...}/node_modules/globalize-compiler/lib/extract.js:39:17)
at {...}/node_modules/globalize-compiler/bin/globalize-compiler.js:84:27 {
lineNumber: 1,
description: 'Unexpected token',
index: 0
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
In this example it's clear that globalize-compiler doesn't support ES20153. But It doesn't tell you what file the failure is. And if the error was somewhere in the middle of the file it wouldn't necessarily be easy to discover what the issue is.
The text was updated successfully, but these errors were encountered:
Agreed it should have better error handling/messages. Any PRs addressing that will be welcome.
Using the compiler API (instead of the CLI) gives you better options for example to pass the AST directly (where you can use babel to understand ES2015 or newer). Another approach worth using is https://github.com/rxaviers/globalize-webpack-plugin/ (that will handle exactly that for you).
The errors generated by globalize-compiler are pretty cryptic and not useful when it fails to parse a file.
time.js
Gives the following result:
In this example it's clear that globalize-compiler doesn't support ES20153. But It doesn't tell you what file the failure is. And if the error was somewhere in the middle of the file it wouldn't necessarily be easy to discover what the issue is.
The text was updated successfully, but these errors were encountered: