Skip to content

Commit 4ef102d

Browse files
guybedfordMylesBorins
authored andcommittedApr 4, 2021
deps: update to cjs-module-lexer@1.1.1
PR-URL: #37992 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent a94cc27 commit 4ef102d

File tree

7 files changed

+35
-15
lines changed

7 files changed

+35
-15
lines changed
 

‎deps/cjs-module-lexer/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.1.1
2+
- Better support for Babel reexport getter function forms (https://github.com/guybedford/cjs-module-lexer/issues/50)
3+
- Support Babel interopRequireWildcard reexports patterns (https://github.com/guybedford/cjs-module-lexer/issues/52)
4+
15
1.1.0
26
- Support for Babel reexport conflict filter (https://github.com/guybedford/cjs-module-lexer/issues/36, @nicolo-ribaudo)
37
- Support trailing commas in getter patterns (https://github.com/guybedford/cjs-module-lexer/issues/31)

‎deps/cjs-module-lexer/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ EXPORTS_DEFINE_VALUE: EXPORTS_DEFINE `, {`
9292
(`enumerable: true,`)?
9393
(
9494
`value:` |
95-
`get` (`: function` IDENTIFIER? )? `()` {` return IDENTIFIER (`.` IDENTIFIER | `[` IDENTIFIER_STRING `]`)? `;`? `}` `,`?
95+
`get` (`: function` IDENTIFIER? )? `() {` return IDENTIFIER (`.` IDENTIFIER | `[` IDENTIFIER_STRING `]`)? `;`? `}` `,`?
9696
)
9797
`})`
9898
9999
EXPORTS_LITERAL: MODULE_EXPORTS `=` `{` (EXPORTS_LITERAL_PROP | EXPORTS_SPREAD) `,`)+ `}`
100100
101101
REQUIRE: `require` `(` STRING_LITERAL `)`
102102
103-
EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` REQUIRE
103+
EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` (`_interopRequireWildcard (`)? REQUIRE
104104
105105
MODULE_EXPORTS_ASSIGN: MODULE_EXPORTS `=` REQUIRE
106106
@@ -119,7 +119,7 @@ EXPORT_STAR_LIB: `Object.keys(` IDENTIFIER$1 `).forEach(function (` IDENTIFIER$2
119119
)
120120
(
121121
EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? |
122-
`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 `]` `;`? `}` `,`? `})` `;`?
123123
)
124124
`})`
125125
```

‎deps/cjs-module-lexer/dist/lexer.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/cjs-module-lexer/dist/lexer.mjs

+2-2
Large diffs are not rendered by default.

‎deps/cjs-module-lexer/lexer.js

+23-7
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,18 @@ function parseSource (cjsSource) {
9797
lastTokenPos = pos;
9898
continue;
9999
case 95/*_*/:
100-
if (source.startsWith('_export', pos + 1) && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) {
100+
if (source.startsWith('interopRequireWildcard', pos + 1) && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) {
101+
const startPos = pos;
102+
pos += 23;
103+
if (source.charCodeAt(pos) === 40/*(*/) {
104+
pos++;
105+
openTokenPosStack[openTokenDepth++] = lastTokenPos;
106+
if (tryParseRequire(Import) && keywordStart(startPos)) {
107+
tryBacktrackAddStarExportBinding(startPos - 1);
108+
}
109+
}
110+
}
111+
else if (source.startsWith('_export', pos + 1) && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) {
101112
pos += 8;
102113
if (source.startsWith('Star', pos))
103114
pos += 4;
@@ -724,12 +735,17 @@ function tryParseObjectDefineOrKeys (keys) {
724735
if (ch !== 103/*g*/ || !source.startsWith('et', pos + 1)) break;
725736
pos += 3;
726737
ch = commentWhitespace();
727-
if (ch !== 58/*:*/) break;
728-
pos++;
729-
ch = commentWhitespace();
730-
if (ch !== 102/*f*/ || !source.startsWith('unction', pos + 1)) break;
731-
pos += 8;
732-
ch = commentWhitespace();
738+
if (ch === 58/*:*/) {
739+
pos++;
740+
ch = commentWhitespace();
741+
if (ch !== 102/*f*/) break;
742+
if (!source.startsWith('unction', pos + 1)) break;
743+
pos += 8;
744+
let lastPos = pos;
745+
ch = commentWhitespace();
746+
if (ch !== 40 && (lastPos === pos || !identifier())) break;
747+
ch = commentWhitespace();
748+
}
733749
if (ch !== 40/*(*/) break;
734750
pos++;
735751
ch = commentWhitespace();

‎deps/cjs-module-lexer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cjs-module-lexer",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Lexes CommonJS modules, returning their named exports metadata",
55
"main": "lexer.js",
66
"exports": {

‎doc/api/esm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ success!
13241324
[`transformSource` hook]: #esm_transformsource_source_context_defaulttransformsource
13251325
[`string`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
13261326
[`util.TextDecoder`]: util.md#util_class_util_textdecoder
1327-
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/1.1.0
1327+
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/1.1.1
13281328
[custom https loader]: #esm_https_loader
13291329
[special scheme]: https://url.spec.whatwg.org/#special-scheme
13301330
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules

0 commit comments

Comments
 (0)
Please sign in to comment.