-
Notifications
You must be signed in to change notification settings - Fork 72
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
Package main sugar #44
Conversation
This doesn't seem like it's implementing #3, but instead #4. We should be sure to note that correctly in the commit message. I think the main thing we should also include here is what happens for submodules? Let us discuss that in #4 to keep things a bit focused. But I'd like to include tests for whatever we decide before merging this feature. |
I guess we already know what the submodule behavior should be; I got confused. But, I'd like us to add a few tests for it :) |
Sure, I've made those changes. Not the submodule behaviour will depend on #43 here. |
It seems like the type system is complaining now; not sure how to fix exactly. We should also add tests for empty objects to this PR, I think. |
Another question that comes up here, is should subpaths be supported for string mains? {
packages: {
pkg: '/path/to/main.js'
}
} In such a case we could:
I'm tempted to say throwing seems the most well-defined, but it does involve treating packages as strings or objects deeper down into the codebase, unless we add a flag property to package "isMainSugar: true" or similar. |
(I've got the typing fixes and test cases ready to go if we can clarify some of the above first) |
Hmm my take is we'd do the transformations in this way: {
packages: {
pkg: '/path/to/main.js'
}
} -> {
packages: {
pkg: {
main: '/path/to/main.js'
}
}
} -> {
packages: {
pkg: {
path: 'pkg'
main: '/path/to/main.js'
}
}
} WDYT? |
My worry here is the unintuitive split between URL mains and package names as paths. For example, perhaps few would expect this to work when it would: {
path_prefix: 'node_modules'
packages: {
pkg: 'index.js'
}
} where,
|
I’m not sure who would be using package name maps that would be entirely unfamiliar with node’s module system, or, who wouldn’t be able to rely on copious documentation explaining how name maps works. |
@guybedford Yeah, I see the problem. It seems like this is inherent in any solution that has implicit paths though. Or maybe it's just worse because of the string-valued version? Maybe let's step back a bit. {
"package1": {
"path": "path1",
"main": "main1.js"
},
"package2": {
"main": "main2.js"
},
"package3": {
"path": "path3"
},
"package4": { },
"package5": "main5.js"
} Then, according to our current plan, I think these are the results, right?
(For the parse errors, actually just including those in the name map breaks the whole name map. But for illustrative purposes I listed these all separately.) Which of these seem like maybe we're making the wrong decision? |
The main throwing errors are currently left out, I've added these in #45. To go over the cases: {
"package1": {
"path": "path1",
"main": "main1.js"
},
"package2": {
"main": "main2.js"
},
"package3": {
"path": "path3"
},
"package4": { },
"package5": "main5.js"
} Then the corrected cases are:
All of the cases do seem mostly sensible to me though, it's perhaps some of the main as a URL edge cases that get odd, but it's a super tough design space. |
OK, in that case I think we should either:
|
I've updated to the original case here of setting |
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.
Looks great, thanks for working through all this.
This adds the package main sugar case from #3, as well as testing some URL main cases which aren't currently tested.
Note if these types of feature PRs are too early, it's no problem to close and focus purely on the validation and test coverage diffs. This stuff is easy to add anytime.