-
Notifications
You must be signed in to change notification settings - Fork 9
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
enhancement/issue 629 cache unchanged assets in development #760
Changes from all commits
c8b4607
0a9ec42
13452b0
5f2c512
bd159ef
7de60a5
311e9a5
f272b02
3bda7ef
9f5286c
1ee4f54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0#gistcomment-2775538 | ||
function hashString(inputString) { | ||
let h = 0; | ||
|
||
for (let i = 0; i < inputString.length; i += 1) { | ||
h = Math.imul(31, h) + inputString.charCodeAt(i) | 0; // eslint-disable-line no-bitwise | ||
} | ||
|
||
return Math.abs(h).toString(); | ||
} | ||
|
||
export { | ||
hashString | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,7 +306,9 @@ class NodeModulesResource extends ResourceInterface { | |
// for each entry found in dependencies, find its entry point | ||
// then walk its entry point (e.g. index.js) for imports / exports to add to the importMap | ||
// and then walk its package.json for transitive dependencies and all those import / exports | ||
await walkPackageJson(userPackageJson); | ||
if (Object.keys(importMap).length === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if there is something more elegant other than initializing Another thought, if we only need to do this once, then in theory we should also be able to include this in the should intercept logic instead? async shouldIntercept(url, body, headers) {
return Promise.resolve(Object.keys(importMap).length === 0 && headers.response['content-type'] === 'text/html');
} |
||
await walkPackageJson(userPackageJson); | ||
} | ||
|
||
// apply import map and shim for users | ||
newContents = newContents.replace('<head>', ` | ||
|
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.
Not sure if there's a reason to not ever to set the
ETag
, or what the implications of setting it all the time would be? 🤔