Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better exception context when adding --throws flag to extraction #2044

Closed
AustinBratcher opened this issue Aug 29, 2020 · 1 comment
Closed

Comments

@AustinBratcher
Copy link

Which package?
cli

Is your feature request related to a problem? Please describe.
When running formatjs extract with the --throws option, it would appear TypeScript fails in some way, but what it fails on is unclear.

Example CLI call:

formatjs extract 'src/**/*.js*' --out-file src/locales/extracted/en.json --ignore 'src/.eslintrc.js' --id-interpolation-pattern '[sha512:contenthash:base64:6]' --format smartling --throws

Example output of thrown exception:

Error: Debug Failure. Output generation failed
    at Object.transpileModule (/Users/austinbratcher/Development/Projects/ShipStation/shipstation-ui/node_modules/typescript/lib/typescript.js:123670:29)
    at processFile (/Users/austinbratcher/Development/Projects/ShipStation/shipstation-ui/node_modules/@formatjs/cli/src/extract.js:104:26)
    at /Users/austinbratcher/Development/Projects/ShipStation/shipstation-ui/node_modules/@formatjs/cli/src/extract.js:151:59
    at step (/Users/austinbratcher/Development/Projects/ShipStation/shipstation-ui/node_modules/@formatjs/cli/src/extract.js:44:23)
    at Object.next (/Users/austinbratcher/Development/Projects/ShipStation/shipstation-ui/node_modules/@formatjs/cli/src/extract.js:25:53)
    at fulfilled (/Users/austinbratcher/Development/Projects/ShipStation/shipstation-ui/node_modules/@formatjs/cli/src/extract.js:16:58)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Describe the solution you'd like
When an exception is thrown from TypeScript failing to transpile a module, it would be helpful if the exception included more actionable information to help debug the issue. Something along the line of including the specific file that failed if that's possible.

Describe alternatives you've considered
Such a problem could be solved "manually" by writing a script to parse each file in the project individually and seeing what fails. This is a less that desirable solution in my opinion.

Additional context
If I do not include the --throws flag, extraction simply completes with warnings, but those warnings also do not include actionable information.

@reaktivo
Copy link

For anyone having issues after migrating to v2. I noticed that the cli tool only worked after adding ".d.ts" to the ignored files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants