Skip to content

Commit a66d478

Browse files
refactor: use rollup's parse function
1 parent c85f5df commit a66d478

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"dependencies": {
1212
"@javascript-obfuscator/escodegen": "^2.3.0",
1313
"@rollup/pluginutils": "^4.2.1",
14-
"acorn": "^8.8.0",
1514
"convert-source-map": "^1.8.0",
1615
"multi-stage-sourcemap": "^0.3.1",
1716
"unassert": "^2.0.0"

src/unassert.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import {createFilter} from '@rollup/pluginutils';
3-
import acorn from 'acorn';
43
import escodegen from '@javascript-obfuscator/escodegen';
54
import {unassertAst} from 'unassert';
65
import convert from 'convert-source-map';
@@ -58,19 +57,8 @@ export default function unassert(options = {}) {
5857
if (!filter(id)) { return null; }
5958

6059
return new Promise((resolve) => {
61-
const comments = [];
62-
const tokens = [];
60+
const ast = this.parse(code);
6361

64-
const ast = acorn.parse(code, {
65-
sourceType: 'module',
66-
ecmaVersion: 'latest',
67-
locations: true,
68-
ranges: true,
69-
onComment: comments,
70-
onToken: tokens,
71-
});
72-
73-
escodegen.attachComments(ast, comments, tokens);
7462
const unassertedAst = escodegen.generate(unassertAst(ast), {
7563
sourceMap: id,
7664
sourceContent: code,

0 commit comments

Comments
 (0)