File tree Expand file tree Collapse file tree 7 files changed +18
-23
lines changed Expand file tree Collapse file tree 7 files changed +18
-23
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,6 @@ jspm_packages
35
35
36
36
# Optional REPL history
37
37
.node_repl_history
38
+
39
+ # reify cache for allowing import export in node
40
+ .reify-cache
Original file line number Diff line number Diff line change 6
6
"module" : " src/index.js" ,
7
7
"scripts" : {
8
8
"build" : " rollup src/index.js -f cjs -o dist/compiler.js" ,
9
- "test" : " npm run build && mocha test" ,
9
+ "test" : " nyc --reporter=lcov --reporter=text mocha test" ,
10
10
"lint" : " standard src/* test/*"
11
11
},
12
12
"author" : {
34
34
"devDependencies" : {
35
35
"chai" : " 3.5.0" ,
36
36
"mocha" : " 2.5.3" ,
37
+ "nyc" : " ^10.3.2" ,
37
38
"pre-push" : " 0.1.1" ,
39
+ "reify" : " ^0.11.0" ,
38
40
"rollup" : " ^0.41.6" ,
39
41
"standard" : " 7.1.2"
40
42
},
48
50
},
49
51
"pre-push" : [
50
52
" lint" ,
51
- " test"
53
+ " test" ,
54
+ " build"
52
55
]
53
56
}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ else if (typeof global !== 'undefined') globalObj = global // eslint-disable-lin
9
9
else if ( typeof self !== 'undefined' ) globalObj = self // eslint-disable-line
10
10
globalObj . $nxCompileToSandbox = toSandbox
11
11
globalObj . $nxClearSandbox = clearSandbox
12
+ globalObj . $nxGlobals = globals
12
13
13
14
export function expose ( ...globalNames ) {
14
15
for ( let globalName of globalNames ) {
Original file line number Diff line number Diff line change 1
- const isSimple = / ^ ( \w | \. ) + $ /
2
-
3
1
export function compileRawExpression ( src ) {
4
- return isSimple . test ( src ) ? compileSimpleExpression ( src ) : compileComplexExpression ( src )
5
- }
6
-
7
- function compileSimpleExpression ( src ) {
8
- return new Function ( 'context' , 'tempVars' , // eslint-disable-line
9
- `if (tempVars) {
10
- try { return tempVars.${ src } } catch (err) {
11
- if (!(err instanceof TypeError)) throw err
12
- }
13
- }
14
- try { return context.${ src } } catch (err) {
15
- if (!(err instanceof TypeError)) throw err
16
- }` )
17
- }
18
-
19
- function compileComplexExpression ( src ) {
20
2
return new Function ( 'context' , 'tempVars' , // eslint-disable-line
21
3
`const sandbox = $nxCompileToSandbox(context, tempVars)
22
4
try { with (sandbox) { return ${ src } } } catch (err) {
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ require ( 'reify' )
4
+
3
5
const expect = require ( 'chai' ) . expect
4
- const compiler = require ( '../dist/compiler ' )
6
+ const compiler = require ( '../src/index ' )
5
7
6
8
const localProp = 'localProp'
7
9
global . globalProp = 'globalProp'
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ require ( 'reify' )
4
+
3
5
const expect = require ( 'chai' ) . expect
4
- const compiler = require ( '../dist/compiler ' )
6
+ const compiler = require ( '../src/index ' )
5
7
6
8
describe ( 'context' , ( ) => {
7
9
afterEach ( ( ) => compiler . hideAll ( ) )
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ require ( 'reify' )
4
+
3
5
const expect = require ( 'chai' ) . expect
4
- const compiler = require ( '../dist/compiler ' )
6
+ const compiler = require ( '../src/index ' )
5
7
6
8
describe ( 'context' , ( ) => {
7
9
afterEach ( ( ) => compiler . hideAll ( ) )
You can’t perform that action at this time.
0 commit comments