Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Add support for untransforming import.meta and non-strict eval use.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Mar 24, 2019
1 parent 6611f9f commit 38a6b7d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/util/untransform-runtime.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import shared from "../shared.js"

function init() {
const evalExpRegExp = /\(eval===(\w+\u200D)\.v\?$1\.e:eval\)/g
const evalCallExpRegExp = /\(eval===(\w+\u200D)\.v\?\1\.c:\1\.k\)/g
const indirectEvalRegExp = /\(eval===(\w+\u200D)\.v\?\1\.e:eval\)/g
const runtimeRegExp = /\w+\u200D\.(\w+)(\.)?/g

function untransformRuntime(string) {
Expand All @@ -10,11 +11,16 @@ function init() {
}

return string
.replace(evalExpRegExp, replaceEvalExp)
.replace(evalCallExpRegExp, replaceEvalCallExp)
.replace(indirectEvalRegExp, replaceIndirectEval)
.replace(runtimeRegExp, replaceRuntime)
}

function replaceEvalExp() {
function replaceEvalCallExp() {
return ""
}

function replaceIndirectEval() {
return "eval"
}

Expand All @@ -23,7 +29,8 @@ function init() {
return "eval" + dot
}

if (name === "i") {
if (name === "_" ||
name === "i") {
return "import" + dot
}

Expand Down

0 comments on commit 38a6b7d

Please sign in to comment.