Skip to content

refactor: Add debug flag and skip missing deps from the importmap #18

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

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

JayaKrishnaNamburu
Copy link
Member

This PR allows to skip any missing dependencies from the importmap.

And adds a debug flag which disables the logs by default. Much needed since it’s flossing the CI with lot of logs if enabled by default 😅

@JayaKrishnaNamburu JayaKrishnaNamburu self-assigned this Sep 7, 2023
@JayaKrishnaNamburu
Copy link
Member Author

The reason for writing a custom parseArgs is, the default one from node:until will throw a error for any flag that is not configured in options. But that’s not the case here. Users can pass flag to the loader and flags to their node tasks. So we can’t define all possible flags so a custom one 👍🏽

options: { "debug-node-loader": { alias: "d", type: "boolean", default: false } },
});

export const isDebuggingEnabled = (): boolean => values["debug-node-loader"] as boolean;
Copy link
Member

@yowainwright yowainwright Sep 7, 2023

Choose a reason for hiding this comment

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

--debug is standard, right?
I think we can capture this differently as well (no computeds).

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 wrote the explanation here
#18 (comment)

And the reason for not using --debug is. Users can pass flags similar to this to their own apps. So, --debug is quite generic. If the main app uses it, it can clash with that

Copy link
Member

@yowainwright yowainwright Sep 9, 2023

Choose a reason for hiding this comment

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

That makes a ton of sense! And we prefer dashes vs camelcase?

But it is still not widely adopted yet.
*/
log.debug(`Failed in resolving ${specifier} in ${cacheMapPath}`);
return null;
Copy link
Member

Choose a reason for hiding this comment

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

What 'value" does null provide here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This line here know, that the specifier is failed to resolve from the map and can be skipped.
https://github.com/jspm/node-importmap-http-loader/blob/skip-missing-dependency-from-importmap/src/loader.ts#L39

Copy link
Member

Choose a reason for hiding this comment

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

I mean that I don't see a reason why returning null is better than nothing. 😬 Sorry I wasn't clearer! 😃

@yowainwright
Copy link
Member

yowainwright commented Sep 7, 2023

@JayaKrishnaNamburu crushing as usual! 💪
Before implementing the cli portion, I'd like to consider it with you a bit.

It might be nice to "wrap" the node command itself so we can account for node loader changes down the road. 🤔

Thoughts?

@JayaKrishnaNamburu JayaKrishnaNamburu merged commit dde1e78 into main Sep 14, 2023
@yowainwright yowainwright deleted the skip-missing-dependency-from-importmap branch January 14, 2024 22:50
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

Successfully merging this pull request may close these issues.

2 participants