@@ -80,7 +80,7 @@ EXPORTS_DOT_ASSIGN: EXPORTS_IDENTIFIER `.` IDENTIFIER `=` |
80 | 80 |
|
81 | 81 | EXPORTS_LITERAL_COMPUTED_ASSIGN: EXPORTS_IDENTIFIER `[` IDENTIFIER_STRING `]` `=` |
82 | 82 |
|
83 | | -EXPORTS_LITERAL_PROP: (IDENTIFIER `:` IDENTIFIER)?) | (IDENTIFIER_STRING `:` IDENTIFIER) |
| 83 | +EXPORTS_LITERAL_PROP: (IDENTIFIER (`:` IDENTIFIER)?) | (IDENTIFIER_STRING `:` IDENTIFIER) |
84 | 84 |
|
85 | 85 | EXPORTS_SPREAD: `...` (IDENTIFIER | REQUIRE) |
86 | 86 |
|
@@ -92,31 +92,34 @@ EXPORTS_DEFINE_VALUE: EXPORTS_DEFINE `, {` |
92 | 92 | (`enumerable: true,`)? |
93 | 93 | ( |
94 | 94 | `value:` | |
95 | | - `get` (`: function` IDENTIFIER? )? `()` {` return IDENTIFIER (`.` IDENTIFIER | `[` IDENTIFIER_STRING `]`)? `;`? `}` |
| 95 | + `get` (`: function` IDENTIFIER? )? `() {` return IDENTIFIER (`.` IDENTIFIER | `[` IDENTIFIER_STRING `]`)? `;`? `}` `,`? |
96 | 96 | ) |
97 | 97 | `})` |
98 | 98 |
|
99 | 99 | EXPORTS_LITERAL: MODULE_EXPORTS `=` `{` (EXPORTS_LITERAL_PROP | EXPORTS_SPREAD) `,`)+ `}` |
100 | 100 |
|
101 | 101 | REQUIRE: `require` `(` STRING_LITERAL `)` |
102 | 102 |
|
103 | | -EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` REQUIRE |
| 103 | +EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` (`_interopRequireWildcard (`)? REQUIRE |
104 | 104 |
|
105 | 105 | MODULE_EXPORTS_ASSIGN: MODULE_EXPORTS `=` REQUIRE |
106 | 106 |
|
107 | 107 | EXPORT_STAR: (`__export` | `__exportStar`) `(` REQUIRE |
108 | 108 |
|
109 | 109 | EXPORT_STAR_LIB: `Object.keys(` IDENTIFIER$1 `).forEach(function (` IDENTIFIER$2 `) {` |
110 | 110 | ( |
111 | | - `if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? | |
112 | | - `if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) `)` |
| 111 | + ( |
| 112 | + `if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? |
| 113 | + ( |
| 114 | + (`if (Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER `, ` IDENTIFIER$2 `)) return` `;`?)? |
| 115 | + (`if (` IDENTIFIER$2 `in` EXPORTS_IDENTIFIER `&&` EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] ===` IDENTIFIER$1 `[` IDENTIFIER$2 `]) return` `;`)? |
| 116 | + )? |
| 117 | + ) | |
| 118 | + `if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) (`&& !` (`Object` `.prototype`? `.hasOwnProperty.call(` IDENTIFIER$1 `, ` IDENTIFIER$2 `)` | IDENTIFIER$1 `.hasOwnProperty(` IDENTIFIER$2 `)`))? `)` |
113 | 119 | ) |
114 | | - ( |
115 | | - `if (` IDENTIFIER$2 `in` EXPORTS_IDENTIFIER `&&` EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] ===` IDENTIFIER$1 `[` IDENTIFIER$2 `]) return` `;`? |
116 | | - )? |
117 | 120 | ( |
118 | 121 | EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? | |
119 | | - `Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get: function () { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? } })` `;`? |
| 122 | + `Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get` (`: function` IDENTIFIER? )? `() { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? `}` `,`? `})` `;`? |
120 | 123 | ) |
121 | 124 | `})` |
122 | 125 | ``` |
@@ -126,7 +129,7 @@ Spacing between tokens is taken to be any ECMA-262 whitespace, ECMA-262 block co |
126 | 129 | * The returned export names are taken to be the combination of: |
127 | 130 | 1. All `IDENTIFIER` and `IDENTIFIER_STRING` slots for `EXPORTS_MEMBER` and `EXPORTS_LITERAL` matches. |
128 | 131 | 2. The first `IDENTIFIER_STRING` slot for all `EXPORTS_DEFINE_VALUE` matches where that same string is not an `EXPORTS_DEFINE` match that is not also an `EXPORTS_DEFINE_VALUE` match. |
129 | | -* The reexport specifiers are taken to be the the combination of: |
| 132 | +* The reexport specifiers are taken to be the combination of: |
130 | 133 | 1. The `REQUIRE` matches of the last matched of either `MODULE_EXPORTS_ASSIGN` or `EXPORTS_LITERAL`. |
131 | 134 | 2. All _top-level_ `EXPORT_STAR` `REQUIRE` matches and `EXPORTS_ASSIGN` matches whose `IDENTIFIER` also matches the first `IDENTIFIER` in `EXPORT_STAR_LIB`. |
132 | 135 |
|
@@ -194,13 +197,23 @@ Object.defineProperty(exports, 'd', { value: 'd' }); |
194 | 197 | Object.defineProperty(exports, '__esModule', { value: true }); |
195 | 198 | ``` |
196 | 199 |
|
| 200 | +Value properties are also detected specifically: |
| 201 | + |
| 202 | +```js |
| 203 | +Object.defineProperty(exports, 'a', { |
| 204 | + value: 'no problem' |
| 205 | +}); |
| 206 | +``` |
| 207 | + |
197 | 208 | To avoid matching getters that have side effects, any getter for an export name that does not support the forms above will |
198 | 209 | opt-out of the getter matching: |
199 | 210 |
|
200 | 211 | ```js |
201 | 212 | // DETECTS: NO EXPORTS |
202 | 213 | Object.defineProperty(exports, 'a', { |
203 | | - value: 'no problem' |
| 214 | + get () { |
| 215 | + return 'nope'; |
| 216 | + } |
204 | 217 | }); |
205 | 218 |
|
206 | 219 | if (false) { |
|