-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): update to esbuild 0.14.14, with patched dist (#6639)
- Loading branch information
Showing
4 changed files
with
39 additions
and
4 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,31 @@ | ||
// esbuild 0.14.4 https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#0144 introduced a | ||
// change that breaks the "overwrite for cjs require('...')() usage" hack used in plugin-vue | ||
// and plugin-react. For the moment, we can remove the extra exports code added in 0.14.4 to | ||
// continue using it. | ||
|
||
import { bold, red } from 'picocolors' | ||
import { readFileSync, writeFileSync } from 'fs' | ||
|
||
const indexPath = process.argv[2] | ||
const varName = process.argv[3] | ||
|
||
let code = readFileSync(indexPath, 'utf-8') | ||
|
||
const moduleExportsLine = `module.exports = __toCommonJS(src_exports);` | ||
|
||
if (code.includes(moduleExportsLine)) { | ||
// overwrite for cjs require('...')() usage | ||
code = code.replace( | ||
moduleExportsLine, | ||
`module.exports = ${varName}; | ||
${varName}['default'] = ${varName};` | ||
) | ||
|
||
writeFileSync(indexPath, code) | ||
|
||
console.log( | ||
bold(`${indexPath} patched with overwrite for cjs require('...')()`) | ||
) | ||
} else { | ||
console.error(red(`${indexPath} post-esbuild bundling patch failed`)) | ||
} |