-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c27b748
commit 8d33650
Showing
12 changed files
with
169 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# TODO | ||
|
||
* Blocks in serializer code rename internal vars which aren't frozen, even in prescence of `eval()` | ||
* No point setting `isFrozenName` on external vars passed to serializer? (as it depends entirely on `containsEval` anyway) | ||
* `serialize/blocks` + `serialize/functions` + `serialize/parseFunction` could have changes stripped out if so. | ||
* TODO comment in `visitors/eval` | ||
* TODO comment in `serialize/blocks` | ||
* TODO comment in `serialize/functions` | ||
* TODO comment in `serialize/parseFunction` | ||
* Deal with duplicate bindings - `for (let x of x)` and `x => { var x; }` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable no-console */ | ||
|
||
'use strict'; | ||
|
||
const options = { | ||
cache: false, | ||
esm: false, | ||
jsx: false, | ||
minify: false, | ||
mangle: true, | ||
inline: true, | ||
comments: true, | ||
format: 'cjs', | ||
strictEnv: undefined | ||
}; | ||
|
||
const {cache, esm, jsx, ...serializeOpts} = options; | ||
|
||
require('../register.js')({cache, esm, jsx}); | ||
|
||
const {serialize} = require('../index.js'); | ||
|
||
let fn = require('./src/index.js'); | ||
|
||
if (esm) fn = fn.default; | ||
|
||
console.log(serialize(fn, serializeOpts)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable no-console */ | ||
|
||
'use strict'; | ||
|
||
const {readFileSync} = require('fs'), | ||
pathJoin = require('path').join, | ||
{instrumentCodeImpl} = require('../lib/instrument/instrument.js'); | ||
|
||
const filename = pathJoin(__dirname, 'src/index.js'); | ||
const codeIn = readFileSync(filename, 'utf8'); | ||
|
||
// eeslint-disable-next-line no-unused-vars | ||
const options = { | ||
isEsm: false, | ||
isCommonJs: true, | ||
isJsx: false, | ||
isStrict: false, | ||
sourceMaps: true, | ||
retainLines: false | ||
}; | ||
|
||
const startTime = new Date(); | ||
const codeOut = instrumentCodeImpl( | ||
codeIn, filename, options.isEsm, options.isCommonJs, options.isJsx, options.isStrict, | ||
options.sourceMaps, undefined, options.retainLines | ||
).code; | ||
const endTime = new Date(); | ||
console.log(codeOut); | ||
console.log(`-----\nInstrumented in ${endTime - startTime} ms`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable no-eval, no-unused-vars */ | ||
|
||
'use strict'; | ||
|
||
class S {} | ||
class X extends S { | ||
constructor(module, exports) { | ||
super(); | ||
eval('0'); | ||
this.x = X; | ||
} | ||
} | ||
|
||
{ | ||
const Klass = X; | ||
X = 1; // eslint-disable-line no-class-assign | ||
module.exports = Klass; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters