@veryfront/ext-parser-babel 0.1.1256-rc.17847 → 0.1.1256-rc.17860
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.js +12 -12
- package/package.json +3 -3
package/esm/parser-only.js
CHANGED
|
@@ -12,22 +12,22 @@ import * as parser from "@babel/parser";
|
|
|
12
12
|
/**
|
|
13
13
|
* The path the plugin choice reasons about.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* as
|
|
18
|
-
* them onto a
|
|
19
|
-
* value, and `.ts` keeps `<T>x` a type assertion
|
|
20
|
-
* are rewritten.
|
|
15
|
+
* Embedded framework sources add a terminal `.src` to the original extension,
|
|
16
|
+
* so remove that wrapper before selecting syntax. Markdown and MDX can reach
|
|
17
|
+
* this parser as compiled JSX, and their authored extension would switch JSX
|
|
18
|
+
* off, so map them onto a JSX-capable path after unwrapping. Nothing else reads
|
|
19
|
+
* this value, and `.ts` keeps `<T>x` as a type assertion.
|
|
21
20
|
*/
|
|
22
21
|
function parseablePath(filePath, syntax) {
|
|
23
22
|
if (filePath === undefined)
|
|
24
23
|
return undefined;
|
|
25
|
-
return filePath
|
|
24
|
+
return filePath
|
|
25
|
+
.replace(/\.src$/i, "")
|
|
26
|
+
.replace(/\.mdx?$/i, syntax === "typescript" ? ".tsx" : ".jsx");
|
|
26
27
|
}
|
|
27
28
|
function pickPlugins(filePath, syntax) {
|
|
28
|
-
const normalizedPath = filePath?.toLowerCase() ?? "";
|
|
29
29
|
const supportsJsx = !filePath ||
|
|
30
|
-
/\.(?:tsx|jsx|js|mjs|cjs)$/.test(
|
|
30
|
+
/\.(?:tsx|jsx|js|mjs|cjs)$/.test(filePath);
|
|
31
31
|
const plugins = [
|
|
32
32
|
"classProperties",
|
|
33
33
|
"classPrivateProperties",
|
|
@@ -69,14 +69,14 @@ function isAstNode(value) {
|
|
|
69
69
|
*/
|
|
70
70
|
export class BabelParseOnlyParser {
|
|
71
71
|
async parse(options) {
|
|
72
|
-
const filePath = options.filePath?.toLowerCase() ?? "";
|
|
73
72
|
const decoratorMode = options.decoratorMode ?? "compatible";
|
|
74
73
|
const syntax = options.syntax ?? "typescript";
|
|
74
|
+
const filePath = parseablePath(options.filePath, syntax)?.toLowerCase() ?? "";
|
|
75
75
|
const parseOptions = {
|
|
76
76
|
sourceType: "unambiguous",
|
|
77
77
|
allowReturnOutsideFunction: options.allowReturnOutsideFunction === true ||
|
|
78
78
|
/\.(?:cjs|js)$/.test(filePath),
|
|
79
|
-
plugins: pickPlugins(
|
|
79
|
+
plugins: pickPlugins(filePath, syntax),
|
|
80
80
|
};
|
|
81
81
|
const ast = (() => {
|
|
82
82
|
try {
|
|
@@ -89,7 +89,7 @@ export class BabelParseOnlyParser {
|
|
|
89
89
|
try {
|
|
90
90
|
return parser.parse(options.code, {
|
|
91
91
|
...parseOptions,
|
|
92
|
-
plugins: pickLegacyDecoratorPlugins(
|
|
92
|
+
plugins: pickLegacyDecoratorPlugins(filePath, syntax),
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-parser-babel",
|
|
3
|
-
"version": "0.1.1256-rc.
|
|
3
|
+
"version": "0.1.1256-rc.17860",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-parser-babel",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@babel/types": "7.29.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"veryfront": "^0.1.1256-rc.
|
|
57
|
+
"veryfront": "^0.1.1256-rc.17860"
|
|
58
58
|
},
|
|
59
59
|
"type": "module",
|
|
60
60
|
"types": "./esm/index.d.ts",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"NOTICE",
|
|
65
65
|
"README.md"
|
|
66
66
|
],
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "d13137fa64274e63f1f63de9d0cdecac2c1aafa4"
|
|
68
68
|
}
|