Skip to content

Commit f308a69

Browse files
committed
chore: remote script load changes
1 parent 97db68b commit f308a69

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/extensionsIntegrated/phoenix-pro/remote-script-provider.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ define(function (require, exports, module) {
5353
console.error(`Script name ${scriptFunctionName} should be a valid function name.`);
5454
return false;
5555
}
56-
scriptText = `(function ${scriptFunctionName}(){${scriptText}})();`;
57-
scriptText = `eval(${JSON.stringify(scriptText)});`;
56+
if(Phoenix.config.environment !== "dev") {
57+
// obfuscate run time environment for private code to be less debug friendly
58+
scriptText = `(function (){${scriptText}})();`;
59+
scriptText = `eval(${JSON.stringify(scriptText)});`;
60+
} else {
61+
// only dev builds have plain code
62+
scriptText = `(function ${scriptFunctionName}(){${scriptText}})();`;
63+
}
5864
remoteFunctionsScripts.set(scriptFunctionName, scriptText);
5965
if(!RemoteFunctions.includes("// DONT_STRIP_MINIFY:REPLACE_WITH_ADDED_REMOTE_SCRIPTS")){
6066
throw new Error("RemoteFunctions script is missing the placeholder // REPLACE_WITH_ADDED_REMOTE_SCRIPTS");
@@ -78,6 +84,10 @@ define(function (require, exports, module) {
7884
LiveDevProtocol.setCustomRemoteFunctionProvider(()=>{
7985
const effectiveScript = "window._LD=(" + effectiveRemoteFunctionsScripts +
8086
"(" + JSON.stringify(LiveDevMultiBrowser.getConfig()) + "))";
87+
if(Phoenix.config.environment === "dev") {
88+
return effectiveScript;
89+
}
90+
// obfuscate run time environment for private code to be less debug friendly
8191
return `eval(${JSON.stringify(effectiveScript)})`;
8292
});
8393

0 commit comments

Comments
 (0)