@veryfront/ext-parser-babel 0.1.1243 → 0.1.1244
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/parser-only.d.ts.map +1 -1
- package/esm/parser-only.js +16 -1
- package/package.json +2 -2
package/esm/parser-only.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser-only.d.ts","sourceRoot":"","sources":["../src/parser-only.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEzE,wEAAwE;AACxE,MAAM,WAAW,4BAA4B;IAC3C,sEAAsE;IACtE,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD;
|
|
1
|
+
{"version":3,"file":"parser-only.d.ts","sourceRoot":"","sources":["../src/parser-only.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEzE,wEAAwE;AACxE,MAAM,WAAW,4BAA4B;IAC3C,sEAAsE;IACtE,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD;AAyCD;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,4BAA4B;IACvE,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAW/C"}
|
package/esm/parser-only.js
CHANGED
|
@@ -9,6 +9,21 @@
|
|
|
9
9
|
* @module extensions/ext-parser-babel/parser-only
|
|
10
10
|
*/
|
|
11
11
|
import * as parser from "@babel/parser";
|
|
12
|
+
/**
|
|
13
|
+
* The path the plugin choice reasons about.
|
|
14
|
+
*
|
|
15
|
+
* Markdown and MDX can reach this parser as compiled JSX, and the authored
|
|
16
|
+
* `.md` or `.mdx` extension would switch JSX off, so the emitted markup parses
|
|
17
|
+
* as a regular expression and throws "Unterminated regular expression". Map
|
|
18
|
+
* them onto a `.tsx` path for the plugin choice only. Nothing else reads this
|
|
19
|
+
* value, and `.ts` keeps `<T>x` a type assertion because only Markdown paths
|
|
20
|
+
* are rewritten.
|
|
21
|
+
*/
|
|
22
|
+
function parseablePath(filePath) {
|
|
23
|
+
if (filePath === undefined)
|
|
24
|
+
return undefined;
|
|
25
|
+
return filePath.replace(/\.mdx?$/i, ".tsx");
|
|
26
|
+
}
|
|
12
27
|
function pickPlugins(filePath) {
|
|
13
28
|
const normalizedPath = filePath?.toLowerCase() ?? "";
|
|
14
29
|
const supportsJsx = !filePath ||
|
|
@@ -44,7 +59,7 @@ export class BabelParseOnlyParser {
|
|
|
44
59
|
sourceType: "unambiguous",
|
|
45
60
|
allowReturnOutsideFunction: options.allowReturnOutsideFunction === true ||
|
|
46
61
|
/\.(?:cjs|js)$/.test(filePath),
|
|
47
|
-
plugins: pickPlugins(options.filePath),
|
|
62
|
+
plugins: pickPlugins(parseablePath(options.filePath)),
|
|
48
63
|
});
|
|
49
64
|
const node = ast;
|
|
50
65
|
return Promise.resolve(node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-parser-babel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1244",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-parser-babel",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@babel/types": "7.29.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"veryfront": "^0.1.
|
|
58
|
+
"veryfront": "^0.1.1244"
|
|
59
59
|
},
|
|
60
60
|
"type": "module",
|
|
61
61
|
"types": "./esm/index.d.ts",
|