Skip to content

Commit

Permalink
meta: add support for Fragment short syntax (#4953)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Feb 26, 2024
1 parent 1fe7297 commit 3e796e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = (api) => {
}],
],
plugins: [
['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
['@babel/plugin-transform-react-jsx', { pragma: 'h', pragmaFrag: 'Fragment' }],
process.env.NODE_ENV !== 'dev' && 'babel-plugin-inline-package-json',
].filter(Boolean),
}
Expand Down
9 changes: 8 additions & 1 deletion bin/build-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@ async function buildLib () {
},
}]
const isTSX = file.endsWith('.tsx')
if (isTSX || file.endsWith('.ts')) { plugins.push(['@babel/plugin-transform-typescript', { disallowAmbiguousJSXLike: true, isTSX, jsxPragma: 'h' }]) }
if (isTSX || file.endsWith('.ts')) {
plugins.push(['@babel/plugin-transform-typescript', {
disallowAmbiguousJSXLike: true,
isTSX,
jsxPragma: 'h',
jsxPragmaFrag: 'Fragment',
}])
}

const { code, map } = await babel.transformFileAsync(file, {
sourceMaps: true,
Expand Down
8 changes: 4 additions & 4 deletions packages/@uppy/dashboard/src/components/AddFiles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ class AddFiles extends Component {
const lastTwoAcquirers = acquirersWithoutLastTwo.splice(acquirers.length - 2, acquirers.length)

return (
<Fragment>
<>
{acquirersWithoutLastTwo.map((acquirer) => this.renderAcquirer(acquirer))}
<span role="presentation" style={{ 'white-space': 'nowrap' }}>
{lastTwoAcquirers.map((acquirer) => this.renderAcquirer(acquirer))}
</span>
</Fragment>
</>
)
}

Expand Down Expand Up @@ -258,7 +258,7 @@ class AddFiles extends Component {
const renderList = (l) => l.map(({ key, elements }) => <Fragment key={key}>{elements}</Fragment>)

return (
<Fragment>
<>
{this.renderDropPasteBrowseTagline(list.length)}

<div className="uppy-Dashboard-AddFiles-list" role="tablist">
Expand All @@ -268,7 +268,7 @@ class AddFiles extends Component {
{renderList(lastTwo)}
</span>
</div>
</Fragment>
</>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ const renderAuthor = (props) => {
{truncateString(author.name, 13)}
</a>
{providerName ? (
<Fragment>
<>
{` ${dot} `}
{providerName}
{` ${dot} `}
</Fragment>
</>
) : null}
</div>
)
Expand Down

0 comments on commit 3e796e2

Please sign in to comment.