Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/plugin/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export interface RNRBConfig {
web?: boolean;
}

export const ESCAPE = "REACT_NATIVE_REACT_BRIDGE_ESCAPE"

/** @internal */
export const escape = (src: string) => src.replace(/([`])/g, "\\$1");
export const escape = (src: string) => src.replace(/`/g, ESCAPE);

const injectString = async (path: string): Promise<string> => {
const src = await readFile(path, "utf8");
Expand Down
5 changes: 3 additions & 2 deletions src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import type { BuildOptions } from "esbuild";
import { isEntryFile } from "./babel";
import { RNRBConfig, bundle, escape } from "./bundler";
import { ESCAPE, RNRBConfig, bundle, escape } from "./bundler";
import { join } from "path";

const metroTransformer = (() => {
Expand Down Expand Up @@ -45,7 +45,8 @@ export const createTransformer = (
src:
"export default String.raw`" +
escape(res).replace(/\$/g, '\\$') +
"`.replace(/\\\\([`$])/g, '\\$1')",
"`.replace(/\\\\([`$])/g, '\\$1')" +
`.replace('${ESCAPE}','\`')`
});
}

Expand Down
Loading