feat: scope inheritance support + tests + global #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As consola was not assigned to the global scope by default, the 'require twice' test failed.
If you want all consola statements, also in other modules, to use a scope you cannot use withScope as that returns a new consola instance. If you try to set that new consola instance to global then it doesnt work for all modules (both internal as external) that where already imported.
By adding this.scope to the Object.assign you can just override the scope by importing consola and then setting
consola.scope = 'my new scope'
during runtime. Eg in nuxt-generate-cluster I want to set the scope to eg 'worker 1' for the first worker etc. But without this feat I have to set the scope in each of my modules again, and then still the consola statements from within Nuxt are logged without a scope.This is also in regards to https://cmty.app/nuxt/consola/issues/c35