-
Notifications
You must be signed in to change notification settings - Fork 189
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
Mark import as external #880
base: master
Are you sure you want to change the base?
Conversation
resolver: { | ||
resolve(specifier, originatingFile) { | ||
if (specifier === './does_not_exist.css' || specifier.startsWith('https:')) { | ||
return true; |
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.
For now, I made resolve
to accept string | true
to focus on the rough design. I think string | { specifier: string, external?: boolean }
would be nice here. What do you think?
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); | ||
@import './does_not_exist.css'; | ||
@import './b.css'; |
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 case can be bundled without any semantics change, but for the following case, it's difficult to keep the semantics.
@import './b.css'; // bundled
@import "https://fonts.googleapis.com/css2?family=Roboto&display=swap"; // externalized
related: postcss/postcss-import#536, parcel-bundler/parcel#5840 (comment), evanw/esbuild#465 (comment)
Maybe it's fine to simply change the semantics in this case? (both postcss-import and esbuild seems to do that)
@@ -102,7 +123,7 @@ pub trait SourceProvider: Send + Sync { | |||
|
|||
/// Resolves the given import specifier to a file path given the file | |||
/// which the import originated from. | |||
fn resolve(&self, specifier: &str, originating_file: &Path) -> Result<PathBuf, Self::Error>; | |||
fn resolve(&self, specifier: &str, originating_file: &Path) -> Result<ResolveResult, Self::Error>; |
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.
I'm not familiar with the rust libraries' semver compat, but I guess changing the return value of a public trait is a breaking change. Is it fine to introduce a breaking change? If not, I'll try to add resolve_advanced
method with a default implementation so that it won't be a breaking change.
(On the JS side, it's not a breaking change)
This PR adds a way to mark an
import
as external withresolver
.closes #479
closes #555