Skip to content

Commit fb0a437

Browse files
authored
chore: Adding flag & docs for jsxFragment (#930)
1 parent 392d63e commit fb0a437

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

.changeset/odd-mayflies-clap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'microbundle': patch
3+
---
4+
5+
Documenting --jsxFragment flag

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ Options
335335
--sourcemap Generate source map (default true)
336336
--raw Show raw byte size (default false)
337337
--jsx A custom JSX pragma like React.createElement (default: h)
338+
--jsxFragment A custom JSX fragment pragma like React.Fragment (default: Fragment)
338339
--jsxImportSource Declares the module specifier to be used for importing jsx factory functions
339340
--tsconfig Specify the path to a custom tsconfig.json
340341
--generateTypes Whether or not to generate types, if `types` or `typings` is set in `package.json` then it will default to be `true`

src/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,8 @@ function createConfig(options, entry, format, writeMeta) {
536536
declarationDir: getDeclarationDir({ options, pkg }),
537537
}),
538538
jsx: 'preserve',
539-
jsxFactory:
540-
// TypeScript fails to resolve Fragments when jsxFactory
541-
// is set, even when it's the same as the default value.
542-
options.jsx === 'React.createElement'
543-
? undefined
544-
: options.jsx || 'h',
539+
jsxFactory: options.jsx,
540+
jsxFragmentFactory: options.jsxFragment,
545541
},
546542
files: options.entries,
547543
},
@@ -578,8 +574,8 @@ function createConfig(options, entry, format, writeMeta) {
578574
modern,
579575
compress: options.compress !== false,
580576
targets: options.target === 'node' ? { node: '8' } : undefined,
581-
pragma: options.jsx || 'h',
582-
pragmaFrag: options.jsxFragment || 'Fragment',
577+
pragma: options.jsx,
578+
pragmaFrag: options.jsxFragment,
583579
typescript: !!useTypescript,
584580
jsxImportSource: options.jsxImportSource || false,
585581
},

src/prog.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export default handler => {
5959
.example("watch --no-sourcemap # don't generate sourcemaps")
6060
.option('--raw', 'Show raw byte size', false)
6161
.option('--jsx', 'A custom JSX pragma like React.createElement', 'h')
62+
.option(
63+
'--jsxFragment',
64+
'A custom JSX fragment pragma like React.Fragment',
65+
'Fragment',
66+
)
6267
.option(
6368
'--jsxImportSource',
6469
'Declares the module specifier to be used for importing jsx factory functions',

0 commit comments

Comments
 (0)