-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broccoli esm import to not break node 22.
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/.eslintcache | ||
/.vscode | ||
/build | ||
/node_modules | ||
/brave | ||
|
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,37 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const filePath = path.join("node_modules/broccoli/dist/load_brocfile.js"); | ||
|
||
try { | ||
let content = fs.readFileSync(filePath, "utf8"); | ||
const originalContent = content; | ||
|
||
// Comment out ESM-related lines | ||
content = content.replace( | ||
/^\s*(const esm_1 = __importDefault\(require\("esm"\)\));/m, | ||
"// $1;" | ||
); | ||
content = content.replace( | ||
/^\s*(const esmRequire = esm_1\.default\(module\));/m, | ||
"// $1;" | ||
); | ||
|
||
// Replace esmRequire with require | ||
content = content.replace( | ||
/brocfile = esmRequire\(brocfilePath\);/, | ||
"brocfile = require(brocfilePath);" | ||
); | ||
|
||
if (content !== originalContent) { | ||
fs.writeFileSync(filePath, content); | ||
console.log("Successfully patched load_brocfile.js"); | ||
} | ||
} catch (error) { | ||
console.error("Error patching load_brocfile.js:", error); | ||
process.exit(1); | ||
} |