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
fix srcset parsing #8671
fix srcset parsing #8671
Conversation
We don't really use unit tests, so please create an integration test instead (see #7918). |
import * as srcset from 'srcset';
function collectSrcSetDependencies(asset, v, opts) {
let parsed = srcset.parse(v).map(({url, ...v}) => ({
url: asset.addURLDependency(url, opts),
...v,
}));
return srcset.stringify(parsed);
}
// @flow
declare module 'srcset' {
declare type SrcSetDefinition = {|
url: string,
width?: number,
density?: number,
|};
declare type Options = {|
strict?: boolean,
|};
declare export function parse(
srcset: string,
options?: Options,
): SrcSetDefinition[];
declare export function stringify(
srcSetDefinitions: SrcSetDefinition[],
options?: Options,
): string;
} |
Thank you for the review Niklas! |
Looks like you have some npm registry override configured for Yarn. There shouldn't be that many changed lines in the lockfile |
It took me hours to fix this 😵 |
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.
Thanks!
↪️ Pull Request
When I was using some URLs with a comma separated query param to a srcset,
my parcel tried to resolve the wrong url.
It was splitting the srcset string on the wrong comma.
@parcel/resolver-default: Cannot load file './9.739075709034898&markers=size:tiny|52.345519011208346' in './src/content
I found a package which is parsing the srcset correctly.
I added a test for the affected method.