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
augmentChunkHash plugin hook #2921
Changes from 13 commits
5561b69
55bbad4
3550bde
1657402
49a1670
52ae7ff
cb4475d
35053bd
237254c
b9ad5d1
e2aac9a
d4dcc58
5800c03
373f6e9
57ccc8c
74f8305
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = { | ||
description: 'augmentChunkHash updates hashes across all modules when returning something', | ||
options1: { | ||
input: 'main', | ||
output: { | ||
format: 'esm', | ||
entryFileNames: '[name]-[hash].js', | ||
chunkFileNames: '[name]-[hash].js' | ||
}, | ||
plugins: [ | ||
{ | ||
augmentChunkHash(chunk) { | ||
if (chunk.name === 'dep') { | ||
return 'adfasdf'; | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
options2: { | ||
input: 'main', | ||
output: { | ||
format: 'esm', | ||
entryFileNames: '[name]-[hash].js', | ||
chunkFileNames: '[name]-[hash].js' | ||
}, | ||
plugins: [ | ||
{ | ||
augmentChunkHash() {} | ||
} | ||
] | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = 'foo'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import('./dep').then(({foo})=>{ | ||
console.log(foo); | ||
console.log('main'); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1014,6 +1014,36 @@ describe('hooks', () => { | |
}); | ||
}); | ||
|
||
it('supports augmentChunkHash hook', () => { | ||
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. I think it might be interesting to convert some of those tests to 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. done |
||
let augmentChunkHashCalls = 0; | ||
return rollup | ||
.rollup({ | ||
input: 'input', | ||
plugins: [ | ||
loader({ | ||
input: `alert('hello')` | ||
}), | ||
{ | ||
augmentChunkHash(update) { | ||
augmentChunkHashCalls++; | ||
assert(this.meta); | ||
assert(this.meta.rollupVersion); | ||
} | ||
} | ||
] | ||
}) | ||
.then(bundle => | ||
bundle.generate({ | ||
format: 'esm', | ||
dir: 'dist', | ||
entryFileNames: '[name]-[hash].js' | ||
}) | ||
) | ||
.then(output => { | ||
assert.equal(augmentChunkHashCalls, 1); | ||
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. I do not think this is too important to test as calling is implicitly tested with any test that also tests that the hash is changed, which is what is actually important to us. 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. In the end I left this one inside hook tests and created a file-hashes one with tests the rest of them |
||
}); | ||
}); | ||
|
||
describe('deprecated', () => { | ||
it('passes bundle & output object to ongenerate & onwrite hooks, with deprecation warnings', () => { | ||
let deprecationCnt = 0; | ||
|
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.
👍