Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception committed Nov 1, 2023
1 parent b1eb6e8 commit 6df528b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/core/src/cli/compileWalletSetupFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,34 @@ import { glob } from 'glob'
import { build } from 'tsup'
import { ensureCacheDirExists } from '../ensureCacheDirExists'

// Error: Dynamic require of "fs" is not supported
const DYNAMIC_REQUIRE_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);
`.trim()

// Error: Cannot find module '../package.json'
const PLAYWRIGHT_RELATIVE_PACKAGE_IMPORT_FIX = `
var originalRequireResolve = require.resolve;
require.resolve = (id, ...args) => {
if (id === "../package.json") {
id = require("node:path").join(process.cwd(), "package.json");
}
return originalRequireResolve(id, ...args);
}
`.trim()

const BANNER = `
/// ---- BANNER START ----
${DYNAMIC_REQUIRE_FIX}
${PLAYWRIGHT_RELATIVE_PACKAGE_IMPORT_FIX}
/// ---- BANNER END ----
`.trimStart()

const OUT_DIR_NAME = 'wallet-setup-dist'

const createGlobPattern = (walletSetupDir: string) => path.join(walletSetupDir, '**', '*.{js,ts}')
Expand All @@ -22,6 +50,10 @@ export async function compileWalletSetupFunctions(walletSetupDir: string) {
splitting: true,
sourcemap: false,
config: false,
keepNames: true,
banner: {
js: BANNER
},
esbuildOptions(options) {
options.drop = ['console', 'debugger']
}
Expand Down

0 comments on commit 6df528b

Please sign in to comment.