-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
replace imports with new aliases #2934
Conversation
I like this, but it will break some third-party modules because they use the module aliases. Here is an example: https://github.com/KristjanESPERANTO/MMM-PublicTransportHafas/blob/fafe3a369ae1e356d36d82030d56ffba499024bf/node_helper.js#L1 |
I got to agree with @KristjanESPERANTO : As much as I like replacing 3rd-party-packages with build-in-fucntionality, breaking compatibility with modules is something that should be avoided at all costs. I cant imagine that there is some backward compatible way to replace |
"logger": "js/logger.js", | ||
"fetch": "js/fetch.js" | ||
"imports": { | ||
"#logger": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it also work if we omit the #?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://nodejs.org/api/packages.html#packages_imports the imports must start with a # :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it is done to avoid conflicts with real npm modules. Using fetch
and logger
aliases while real modules already exist seems risky.
I guess one could create real npm modules named |
That sounds very hacky and hard to maintain... But whats the problem with bun and module-alias? Maybe there is something we can fix otherwise.... |
What if we switch MagicMirror and its built-in modules but still leave |
and additionally this: ilearnio/module-alias#113 |
I'm really new to the project and wasn't aware that many 3rd party plugins are relying on this module, so, as you said, won't fix the problem, but ofc it would improve a bit the project. |
After few hours on this my original goal (make it run on |
note that we added the package.json alias because npm implemented some security checking for modules found in node_modules, but not in package-lock. it removes them so it kept being deleted. an alternative was to make a GitHub repo and then reference that as a dependency Mich decided on the alias. I think think was I 2.10 timeframe |
To fix issue caused by #3071 In order to still fulfill the new linter rule `import/order`, I replaced the alias with the path. I also see two other approaches, but I opted for the simplest one here for now. The other approaches: 1. Also create an alias for `app`. 2. Use new `imports` (like in PR #2934), but let `_moduleAliases` untouched to stay compatible to 3rd party modules. **Edit**: Oh, I thought of another option: - Add `require("module-alias/register");`
still appreciate the idea but the mentioned problems in the comments are not solved and no prgress since 11 months so closing this. |
Replace deprecated
module-alias
with built-in imports map. It is present since node v12 and will be soon available inbun
(it works inbun-canary
). My goal is to make this app runnable with bun and that's the first step to make it happen.