Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v2.0.0] Avoid empty imports from side-effect-free chunks (#3369)
* Respect moduleSideEffects when inlining empty imports * Make dependencies a Set * Also handle side-effect free reexports correctly without generating separate chunks * Infer side-effect free modules and hoist side-effects * Simplify some logic * Better encapsulate chunk assignment * Get rid of colouring hashes * Improve coverage * Store the build output as artifact and post an automated comment
- Loading branch information
1 parent
15a4cd4
commit 467d666
Showing
202 changed files
with
1,203 additions
and
547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const fetch = require('node-fetch'); | ||
|
||
const authToken = process.env.GH_AUTH_TOKEN; | ||
if (!authToken) { | ||
throw new Error('Could not find auth token.'); | ||
} | ||
|
||
const prNumber = path.basename( | ||
process.env.CIRCLE_PULL_REQUEST || process.env.CI_PULL_REQUEST || '' | ||
); | ||
if (!prNumber) { | ||
console.log('No pull request number found'); | ||
process.exit(0); | ||
} | ||
|
||
const headline = '### Thank you for your contribution! ❤️'; | ||
|
||
postComment(); | ||
|
||
async function postComment() { | ||
const existingId = await findExistingComment(); | ||
console.log(existingId ? `Update comment ${existingId}` : 'Create new comment.'); | ||
const installPath = await getInstallPath(); | ||
const path = existingId ? `issues/comments/${existingId}` : `issues/${prNumber}/comments`; | ||
const method = existingId ? 'PATCH' : 'POST'; | ||
await fetch(getApiUrl(path), { | ||
method, | ||
body: JSON.stringify({ | ||
body: `${headline} | ||
You can try out this pull request locally via | ||
\`\`\` | ||
npm install ${installPath} | ||
\`\`\` | ||
or load it into the REPL: | ||
https://rollupjs.org/repl/?circleci=${process.env.CIRCLE_BUILD_NUM} | ||
` | ||
}) | ||
}); | ||
} | ||
|
||
async function findExistingComment() { | ||
const comments = await (await fetch(getApiUrl(`issues/${prNumber}/comments`), {})).json(); | ||
const existingComment = comments.find(comment => comment.body.startsWith(headline)); | ||
return existingComment && existingComment.id; | ||
} | ||
|
||
async function getInstallPath() { | ||
const prInfo = await (await fetch(getApiUrl(`pulls/${prNumber}`), {})).json(); | ||
return `${prInfo.head.repo.full_name}#${prInfo.head.ref}`; | ||
} | ||
|
||
function getApiUrl(path) { | ||
return `https://${authToken}:x-oauth-basic@api.github.com/repos/rollup/rollup/${path}`; | ||
} |
Oops, something went wrong.