-
Notifications
You must be signed in to change notification settings - Fork 916
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
aliases as a separate config object #249
aliases as a separate config object #249
Conversation
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.
This is great! One thing that's missing: our auto import scanning will detect the use of the alias, but installTargets needs the actual package. So just make sure that you're checking aliases inside the import scanner, and properly adding them to installTargets.
I'm not entirely sure what is meant by this with respect to the auto-import scanner. For example: it doesn't seem like dependencies-of-dependencies get scanned for imports, even without aliases. So react-helmet imports react but react never ends up in the import-map anyway. |
Okay here's the use-case I'm picturing. I haven't run this PR yet, so there's also a chance that this just isn't an issue:
|
since |
@ChristopherBiscardi just fixed merge conflicts for you, although you may need to run There's still just that one outstanding question about the import scanner to get this over the line. Let me know if you'd like any help. |
"snowpack": {
"aliases": {
"react": "preact/compat",
"react-dom": "preact/compat"
}
} |
Awesome! This looks good to merge, failing tests are on master which I'm in the middle of cleaning up now |
@FredKSchott Any chance of this getting released in the 1.7.x line? or is this going to be a 2.0 only thing now? |
@FredKSchott This doesn't handle aliases for local imports, right? It's quite a common thing to do with webpack/rollup and TypeScript, e.g: Aliasing Looks like snowpack assumes it's a node_modules package and must have a |
@ChristopherBiscardi whoops, missed your message. Yes, happy to get this out in the v1.x branch if you'd like. @AlexGalays currently it's only for dependencies. I'm not opposed to adding some sort of simple 'baseUrl' type behavior for developers who want this, but we also have to be careful about how much 'sugar' like this that we support, since Is there some way to write this sort of import that wouldn't be interpreted as an npm package? |
I'm seeing good results with |
@ChristopherBiscardi just tried to cherry-pick, but there were more conflicts than expected. happy to look at a PR that merges this work into the v1.x branch, but otherwise i'm going to need to focus my time on getting v2 out the door later this week / early next week. |
@AlexGalays I tried to use babel
Crash:
|
This is an alternate version of #237 that reflects the object changes discussed in #236 . It is smaller and more distinct, so as to not overlap functionality with
webDependencies
. Instead of modifying the type signature forwebDependencies
, this PR adds a new, distinctaliases
key. Thealiases
key is almost a verbatim passthrough to rollup-plugin-alias. The additional logic is for adding aliases to theimportMap
with the proper names.TODO: add alias tests if this object approach is preferred over the arrays/webDependencies one.