@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.
Files changed (2) hide show
  1. package/esm/parser-only.js +12 -12
  2. package/package.json +3 -3
@@ -12,22 +12,22 @@ import * as parser from "@babel/parser";
12
12
  /**
13
13
  * The path the plugin choice reasons about.
14
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.
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.replace(/\.mdx?$/i, syntax === "typescript" ? ".tsx" : ".jsx");
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(normalizedPath);
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(parseablePath(options.filePath, syntax), syntax),
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(parseablePath(options.filePath, syntax), syntax),
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.17847",
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.17847"
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": "5c8223d6e19d70cd18adb973bb9292dcf9a654aa"
67
+ "gitHead": "d13137fa64274e63f1f63de9d0cdecac2c1aafa4"
68
68
  }