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

Usage as a library #241

Open
P4 opened this issue Aug 18, 2021 · 0 comments
Open

Usage as a library #241

P4 opened this issue Aug 18, 2021 · 0 comments

Comments

@P4
Copy link

P4 commented Aug 18, 2021

Hi, I've been using @biesbjerg/ngx-translate-extract in my project at work for several years now. However, we needed to make enough changes to the resulting files that we ended up writing our own custom script that's using the parsers and collections provided by the package, essentially treating the tool as a library.

We're currently using @biesbjerg/ngx-translate-extract version 7.0.4

A small problem we have right now is that any attempt to import something from the package's main entrypoint causes the CLI task to execute and kill the process. I suspect this is caused by the index.ts file re-exporting another file which defines and executes the task:

export * from './cli/cli';

// Run task
try {
extractTask.execute();
console.log(green('\nDone.\n'));
console.log(donateMessage);
process.exit(0);
} catch (e) {

We currently work around that by importing everything from internals instead of the main entrypoint:

import {JsonCompiler} from '@biesbjerg/ngx-translate-extract/dist/compilers/json.compiler';
import {ParserInterface} from '@biesbjerg/ngx-translate-extract/dist/parsers/parser.interface';
import {PipeParser} from '@biesbjerg/ngx-translate-extract/dist/parsers/pipe.parser';
...

This works, but looks messy is generally not a good practice, so I was wondering if there's any good way to solve that issue. I'm not certain why cli is re-exported as it does not seem to be used through index, and the bin script that actually runs as ngx-translate-extract imports it directly.

Thanks!

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

No branches or pull requests

1 participant