-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 chore(core): Add compilation files fixes
- Loading branch information
1 parent
45b4976
commit 2f51a9b
Showing
2 changed files
with
37 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Fixes -> Error: Dynamic require of "fs" is not supported | ||
// Issue link: https://github.com/evanw/esbuild/issues/1921 | ||
const DYNAMIC_REQUIRE_FS_FIX = ` | ||
// ---- DYNAMIC_REQUIRE_FS_FIX ---- | ||
var require = (await import("node:module")).createRequire(import.meta.url); | ||
var __filename = (await import("node:url")).fileURLToPath(import.meta.url); | ||
var __dirname = (await import("node:path")).dirname(__filename); | ||
// ---- DYNAMIC_REQUIRE_FS_FIX ---- | ||
`.trim() | ||
|
||
// Fixes -> Error: Cannot find module '../package.json' | ||
// This issue is related to the Playwright test runner. | ||
const PLAYWRIGHT_RELATIVE_PACKAGE_IMPORT_FIX = ` | ||
// ---- PLAYWRIGHT_RELATIVE_PACKAGE_IMPORT_FIX ---- | ||
var originalRequireResolve = require.resolve; | ||
require.resolve = (id, ...args) => { | ||
if (id.endsWith("/package.json")) { | ||
id = require("node:path").join(process.cwd(), "package.json"); | ||
} | ||
return originalRequireResolve(id, ...args); | ||
} | ||
// ---- PLAYWRIGHT_RELATIVE_PACKAGE_IMPORT_FIX ---- | ||
`.trim() | ||
|
||
export const FIXES_BANNER = ` | ||
/// ######## BANNER WITH FIXES START ######## | ||
${DYNAMIC_REQUIRE_FS_FIX} | ||
${PLAYWRIGHT_RELATIVE_PACKAGE_IMPORT_FIX} | ||
/// ######## BANNER WITH FIXES END ######## | ||
`.trimStart() |
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