@wuchale/jsx 0.7.3 → 0.7.4
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/dist/transformer.d.ts +1 -1
- package/dist/transformer.js +4 -3
- package/package.json +1 -1
package/dist/transformer.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type * as Estree from 'acorn';
|
|
|
4
4
|
import { Transformer } from 'wuchale/adapter-vanilla';
|
|
5
5
|
import type { IndexTracker, HeuristicFunc, TransformOutput, RuntimeConf, CatalogExpr } from 'wuchale';
|
|
6
6
|
import { MixedVisitor, type CommentDirectives } from "wuchale/adapter-utils";
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function parseScriptJSX(content: string): [Estree.Program, Estree.Comment[][]];
|
|
8
8
|
type MixedNodesTypes = JX.JSXElement | JX.JSXFragment | JX.JSXText | JX.JSXExpressionContainer | JX.JSXSpreadChild;
|
|
9
9
|
export type JSXLib = 'default' | 'solidjs';
|
|
10
10
|
export declare class JSXTransformer extends Transformer {
|
package/dist/transformer.js
CHANGED
|
@@ -2,10 +2,10 @@ import MagicString from 'magic-string';
|
|
|
2
2
|
import { Parser } from 'acorn';
|
|
3
3
|
import { Message } from 'wuchale';
|
|
4
4
|
import { tsPlugin } from '@sveltejs/acorn-typescript';
|
|
5
|
-
import { Transformer, scriptParseOptionsWithComments } from 'wuchale/adapter-vanilla';
|
|
5
|
+
import { Transformer, scriptParseOptionsWithComments, parseScript } from 'wuchale/adapter-vanilla';
|
|
6
6
|
import { nonWhitespaceText, MixedVisitor, processCommentDirectives } from "wuchale/adapter-utils";
|
|
7
7
|
const JsxParser = Parser.extend(tsPlugin({ jsx: true }));
|
|
8
|
-
export function
|
|
8
|
+
export function parseScriptJSX(content) {
|
|
9
9
|
const [opts, comments] = scriptParseOptionsWithComments();
|
|
10
10
|
return [JsxParser.parse(content, opts), comments];
|
|
11
11
|
}
|
|
@@ -218,7 +218,8 @@ export class JSXTransformer extends Transformer {
|
|
|
218
218
|
return msgs;
|
|
219
219
|
};
|
|
220
220
|
transformJx = (lib) => {
|
|
221
|
-
|
|
221
|
+
// jsx vs type casting is not ambiguous in all files except .ts files
|
|
222
|
+
const [ast, comments] = (this.filename.endsWith('.ts') ? parseScript : parseScriptJSX)(this.content);
|
|
222
223
|
this.comments = comments;
|
|
223
224
|
this.mstr = new MagicString(this.content);
|
|
224
225
|
this.mixedVisitor = this.initMixedVisitor();
|