@tsrx/vite-plugin-react 0.0.42 → 0.0.43
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/package.json +1 -1
- package/src/index.js +17 -9
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -62,25 +62,33 @@ export function tsrxReact(options = {}) {
|
|
|
62
62
|
async transform(/** @type {string} */ code, /** @type {string} */ id) {
|
|
63
63
|
if (!TSRX_EXTENSION_PATTERN.test(id)) return null;
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
let { code: tsx_code, css, map } = compile(code, id);
|
|
66
66
|
|
|
67
67
|
let source = tsx_code;
|
|
68
68
|
if (css) {
|
|
69
69
|
css_cache.set(id, css);
|
|
70
70
|
source = `import ${JSON.stringify(id + CSS_QUERY)};\n${tsx_code}`;
|
|
71
|
+
if (map && typeof map.mappings === 'string') {
|
|
72
|
+
map = { ...map, mappings: ';' + map.mappings };
|
|
73
|
+
}
|
|
71
74
|
} else {
|
|
72
75
|
css_cache.delete(id);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
const result = await transformWithOxc(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const result = await transformWithOxc(
|
|
79
|
+
source,
|
|
80
|
+
id,
|
|
81
|
+
{
|
|
82
|
+
lang: 'tsx',
|
|
83
|
+
sourcemap: true,
|
|
84
|
+
jsx: {
|
|
85
|
+
runtime: 'automatic',
|
|
86
|
+
importSource: jsxImportSource,
|
|
87
|
+
},
|
|
88
|
+
target: 'esnext',
|
|
81
89
|
},
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
map,
|
|
91
|
+
);
|
|
84
92
|
|
|
85
93
|
return { code: result.code, map: result.map };
|
|
86
94
|
},
|