Open justinfagnani opened 2 years ago
We namely leverage the Resolve plug-in from Rollup to power this in dev server. Have you raised this question there?
I also use @web/dev-server
to check if a build output of an app actually would work on a "default web server".
So I do
web-dev-server --node-resolve ./page
rollup ...
web-dev-server ./_site
it usually comes back to the question... do we wanna have a "magical" thing that just works... and you may have a surprise as you push it to a real server (e.g. if it "just" works - you may be inclined to just push your source)
so as you provide the option you are at least aware that your server will need to have the same option/functionality or you need to transform your code so that this functionality is no longer needed...
always a balancing act 😅
here is a crazy idea - ship "2 clis/servers"?
web-dev-server
comes with some default options like node resolveweb-server
comes with no default optionsI hit this again today when I forgot that Web Dev Server does not set the development
condition by default. I think a lot of other developer tools are doing this by default now (Vite and Next?) and it's a bit weird that a "dev" server isn't.
It's also cumbersome to have to write a config file to set the option. I think for a dev server this should just happen out of the box.
What do people think about adding "development" by default as I did in #2109?
I think if you're trying to use the dev server as a stand-in for a prod server there's already so many things that are different - you're not using your same build pipeline! - that using the development condition is just one small thing. Also most libraries that bother publishing a development export should be assuring that the behavior is the same or more strict in dev builds.
If something doesn't work, the user can make a config file with the development condition omitted.
I think it'd be really helpful to have a default resolution mode for
@web/dev-server
, and for that default to be a new mode closer to Node module and browser w/ import maps resolution.There are two main reasons I'd like a default mode:
--node-resolution
every time I use WDS. Basically no project I've ever had works without it, so it's pure boilerplate.development
export condition. This is a dev server after all :) and it would greatly improve DX for users to get our more extensive development build warnings. I hope this will be true of more projects that adopt export conditions of time too.As for the mode, I really want a mode that resolves bare specifiers and package names, but not the rest of the path (except for when package exports are available). Node doesn't do path searching for modules, and import maps can't do suffix mappings, so the current node resolution can hide subtle mistakes where you intended to use a file extension, but forgot.