Skip to content

Commit

Permalink
chore: Adding flag & docs for jsxFragment (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian authored Mar 3, 2022
1 parent 392d63e commit fb0a437
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-mayflies-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'microbundle': patch
---

Documenting --jsxFragment flag
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ Options
--sourcemap Generate source map (default true)
--raw Show raw byte size (default false)
--jsx A custom JSX pragma like React.createElement (default: h)
--jsxFragment A custom JSX fragment pragma like React.Fragment (default: Fragment)
--jsxImportSource Declares the module specifier to be used for importing jsx factory functions
--tsconfig Specify the path to a custom tsconfig.json
--generateTypes Whether or not to generate types, if `types` or `typings` is set in `package.json` then it will default to be `true`
Expand Down
12 changes: 4 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,8 @@ function createConfig(options, entry, format, writeMeta) {
declarationDir: getDeclarationDir({ options, pkg }),
}),
jsx: 'preserve',
jsxFactory:
// TypeScript fails to resolve Fragments when jsxFactory
// is set, even when it's the same as the default value.
options.jsx === 'React.createElement'
? undefined
: options.jsx || 'h',
jsxFactory: options.jsx,
jsxFragmentFactory: options.jsxFragment,
},
files: options.entries,
},
Expand Down Expand Up @@ -578,8 +574,8 @@ function createConfig(options, entry, format, writeMeta) {
modern,
compress: options.compress !== false,
targets: options.target === 'node' ? { node: '8' } : undefined,
pragma: options.jsx || 'h',
pragmaFrag: options.jsxFragment || 'Fragment',
pragma: options.jsx,
pragmaFrag: options.jsxFragment,
typescript: !!useTypescript,
jsxImportSource: options.jsxImportSource || false,
},
Expand Down
5 changes: 5 additions & 0 deletions src/prog.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export default handler => {
.example("watch --no-sourcemap # don't generate sourcemaps")
.option('--raw', 'Show raw byte size', false)
.option('--jsx', 'A custom JSX pragma like React.createElement', 'h')
.option(
'--jsxFragment',
'A custom JSX fragment pragma like React.Fragment',
'Fragment',
)
.option(
'--jsxImportSource',
'Declares the module specifier to be used for importing jsx factory functions',
Expand Down

0 comments on commit fb0a437

Please sign in to comment.