Skip to content

Commit

Permalink
fix: replace direct eval with indirect eval fixes: #31
Browse files Browse the repository at this point in the history
  • Loading branch information
imranbarbhuiya committed May 30, 2023
1 parent c9e57ff commit db9b7e5
Show file tree
Hide file tree
Showing 7 changed files with 74,205 additions and 358 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
"require": "./dist/index.js"
},
"sideEffects": false,
"license": "MIT",
Expand All @@ -34,6 +34,9 @@
"esbuild-plugin",
"polyfill"
],
"dependencies": {
"modern-node-polyfills": "^0.1.3"
},
"devDependencies": {
"@commitlint/cli": "^17.6.3",
"@commitlint/config-conventional": "^17.6.3",
Expand Down Expand Up @@ -81,8 +84,5 @@
"ansi-regex": "^5.0.1",
"minimist": "^1.2.8"
},
"packageManager": "yarn@3.5.1",
"dependencies": {
"modern-node-polyfills": "^0.1.3"
}
"packageManager": "yarn@3.5.1"
}
3 changes: 2 additions & 1 deletion src/lib/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const loader = async (args: esbuild.OnLoadArgs): Promise<esbuild.OnLoadResult> =
const isCommonjs = args.namespace.endsWith('commonjs');

const resolved = await polyfillPath(removeEndingSlash(args.path));
const contents = await polyfillContent(removeEndingSlash(args.path));
const contents = (await polyfillContent(removeEndingSlash(args.path))).replaceAll('eval(', '(0,eval)(');

const resolveDir = path.dirname(resolved);

if (isCommonjs) {
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/input/directEval.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line unicorn/prefer-node-protocol
import { getHashes } from 'crypto';

const result = getHashes();

console.log(result);
Loading

0 comments on commit db9b7e5

Please sign in to comment.