Skip to content
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

Querystring support #278

Open
guybedford opened this issue Mar 19, 2023 · 2 comments
Open

Querystring support #278

guybedford opened this issue Mar 19, 2023 · 2 comments

Comments

@guybedford
Copy link
Member

For cache invalidations, a common pattern is to add query strings - ?q=asdfhjkl with a random timestamp or hash.

When using the generator, we could enable an option to include "querystrings" in the map, something like the following:

new Generator({
  querystring: 'q=asdfjkll'
});

await generator.install('pkg');

// includes "pkg": "/path/to/pkg?q=asdfjkl"
// ALSO includes "/path/to/pkg/dep.js": "path/to/pkg/dep.js?q=asdfjkl" for non-mapped deps!
console.log(generator.getMap());
@guybedford
Copy link
Member Author

Ideally one would want to scope the querystring stuff to specific domains / parents though. Eg you likely don't want it for the JSPM CDN, just the local package code... not sure how best to define that part.

@guybedford
Copy link
Member Author

Perhaps querystrings is an object configuration:

type QueryStrings: Record<String, String>

where

new Generator({
  queryStrings: {
    '/': 'timestamp=asdf',
    'https://esm.sh/': 'dev'
  }
});

Then when processing URLs we would always strip all querystrings, but then add them back at the very end of the import map construction process as a post-processing of the import map, possibly even after the import map has been serialized into JSON. like a const map = importMap.getMap(); const mapWithQueryStrings = postProcess(map) step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant