////
// build process helpers

export function rewriteJsImports(code: string): string {
    if (process.env.NODE_ENV === "production") {
        return code
            .replace(/import\s+\*\s+as\s+(\w+)\s+from\s+["']@\/js\/\w+["']/g, 'const $1 = window.__pluto_modules.$1')
            .replace(/import\s+{([^}]+)}\s+from\s+["']@\/js\/(\w+)["']/g, 'const {$1} = window.__pluto_modules.$2')
    } else {
        return code.replace(/from (["'])@\/js\//g, "from $1../js/")
    }
}