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

[APM] Make typescript optimization process compatible with NP #58984

Merged
merged 4 commits into from
Mar 4, 2020

Conversation

dgieselaar
Copy link
Member

Rather than creating an extra tsconfig.json file in the APM folder, simply change the one in x-pack root, and include APM files from both legacy + NP.


await writeFile(
xpackTsConfig,
JSON.stringify(assign(config, template), null, 2),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa, haven't seen _.assign used since the ancient es5 times :D I must admit, I thought it was only a legacy Object.assign.

Would this not work?

Suggested change
JSON.stringify(assign(config, template), null, 2),
JSON.stringify({...config, ...template}, null, 2),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye, I was changing it from merge, so lodash was still living in my head 😬 will change.

Rather than creating an extra tsconfig.json file in the APM folder, simply change the one in x-pack root, and include APM files from both legacy + NP.
@dgieselaar dgieselaar added release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Mar 2, 2020
@dgieselaar dgieselaar marked this pull request as ready for review March 2, 2020 12:37
@dgieselaar dgieselaar requested a review from a team as a code owner March 2, 2020 12:37
Copy link
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work! Had one suggestion on replacing console.log with console.error.

optimizeTsConfig();
optimizeTsConfig().catch(err => {
// eslint-disable-next-line no-console
console.log(err);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do console.error here will ESLint not complain? You would want this on stderr anyway I presume.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I'll move it to console.error (regardless of whether it will complain)

unoptimizeTsConfig: async () => {
await unoptimizeTsConfig();
// eslint-disable-next-line no-console
console.log('Removed APM TypeScript optimizations');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go to stderr too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an error though, am I misunderstanding what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.error logs to stderr instead of stdout. stdout is meant for output that can be piped around, and stderr for messages like this.

https://www.jstorimer.com/blogs/workingwithcode/7766119-when-to-use-stderr-instead-of-stdout

it's probably a controversial point though against "console.error is for errors" so either way I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got that, but you might have commented in the wrong file? Did you meant to comment on scripts/unoptimize-tsconfig.js? (I've changed it to console.error there as well).

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dgieselaar dgieselaar merged commit 114c4cb into elastic:master Mar 4, 2020
@dgieselaar dgieselaar deleted the apm-tsconfig-np branch March 4, 2020 10:25
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Mar 4, 2020
…c#58984)

* [APM] Make typescript optimization process compatible with NP

Rather than creating an extra tsconfig.json file in the APM folder, simply change the one in x-pack root, and include APM files from both legacy + NP.

* Update dev_docs/typescript.md

* Use spread op instead of assign

* Use console.error instead of console.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants