Skip to content

Commit 7d5a2f9

Browse files
guybedfordrichardlau
authored andcommitted
deps: update to cjs-module-lexer@1.1.1
PR-URL: #37992 Backport-PR-URL: #38003 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent 906b43e commit 7d5a2f9

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
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

+4-4
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
```
@@ -129,7 +129,7 @@ Spacing between tokens is taken to be any ECMA-262 whitespace, ECMA-262 block co
129129
* The returned export names are taken to be the combination of:
130130
1. All `IDENTIFIER` and `IDENTIFIER_STRING` slots for `EXPORTS_MEMBER` and `EXPORTS_LITERAL` matches.
131131
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.
132-
* The reexport specifiers are taken to be the the combination of:
132+
* The reexport specifiers are taken to be the combination of:
133133
1. The `REQUIRE` matches of the last matched of either `MODULE_EXPORTS_ASSIGN` or `EXPORTS_LITERAL`.
134134
2. All _top-level_ `EXPORT_STAR` `REQUIRE` matches and `EXPORTS_ASSIGN` matches whose `IDENTIFIER` also matches the first `IDENTIFIER` in `EXPORT_STAR_LIB`.
135135

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
@@ -1284,7 +1284,7 @@ success!
12841284
[`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
12851285
[dynamic instantiate hook]: #esm_code_dynamicinstantiate_code_hook
12861286
[`util.TextDecoder`]: util.md#util_class_util_textdecoder
1287-
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/1.1.0
1287+
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/1.1.1
12881288
[special scheme]: https://url.spec.whatwg.org/#special-scheme
12891289
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules
12901290
[transpiler loader example]: #esm_transpiler_loader

0 commit comments

Comments
 (0)