aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--integration/snippets/jsx-top-level.tsx21
-rw-r--r--src/js_parser/js_parser.zig5
2 files changed, 26 insertions, 0 deletions
diff --git a/integration/snippets/jsx-top-level.tsx b/integration/snippets/jsx-top-level.tsx
new file mode 100644
index 000000000..2b49b5959
--- /dev/null
+++ b/integration/snippets/jsx-top-level.tsx
@@ -0,0 +1,21 @@
+const isDropdown = true;
+const iconName = "";
+const adjustedPadding = 5;
+
+const Icon = ({ name, size, color }) => {
+ return name;
+};
+
+const Foo = <Icon name="arrow-down" size="1.5em" color="currentColor" />;
+const yoooo = [<Icon name="arrow-down" size="1.5em" color="currentColor" />];
+const iconProps = {
+ // This regression test is to ensure that the JSX value here does not print as an e_missing (nothing)
+ rightIcon: <Icon name="arrow-down" size="1.5em" color="currentColor" />,
+ paddingRight: adjustedPadding,
+};
+
+export function test() {
+ const foo = iconProps.rightIcon;
+ yoooo[0];
+ return testDone(import.meta.url);
+}
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index 290c48ce1..e35bfcce5 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -2351,6 +2351,7 @@ pub const Parser = struct {
// We do not mark this as .require becuase we are already wrapping it manually.
const import_record_id = p.addImportRecord(.internal, loc, p.options.jsx.import_source);
+ p.import_records.items[import_record_id].tag = .jsx_import;
// When everything is CommonJS
// We import JSX like this:
// var {jsxDev} = require("react/jsx-dev")
@@ -2446,6 +2447,7 @@ pub const Parser = struct {
.is_single_line = true,
.import_record_index = import_record_id,
}, loc);
+ p.import_records.items[import_record_id].tag = .jsx_classic;
stmt_i += 1;
p.named_imports.put(
classic_namespace_ref,
@@ -2472,6 +2474,7 @@ pub const Parser = struct {
declared_symbols_i += 1;
const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.refresh_runtime);
+ p.import_records.items[import_record_id].tag = .react_refresh;
jsx_part_stmts[stmt_i] = p.s(S.Import{
.namespace_ref = p.jsx_refresh_runtime.ref,
.star_name_loc = loc,
@@ -2515,6 +2518,8 @@ pub const Parser = struct {
var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, 1);
const loc = logger.Loc.Empty;
const import_record_id = p.addImportRecord(.require, loc, p.options.jsx.refresh_runtime);
+ p.import_records.items[import_record_id].tag = .react_refresh;
+
var import_stmt = p.s(S.Import{
.namespace_ref = p.jsx_refresh_runtime.ref,
.star_name_loc = loc,