developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8k stars 361 forks source link

Microbundle 0.15.1 #1009

Closed daniele-zurico closed 1 year ago

daniele-zurico commented 1 year ago

I use microbundle with react and typescript. My build command is the following:

    "build": "microbundle --jsx React.createElement --css-modules true",

It works perfectly fine with 0.14.x

but when I update on 0.15.x it raise the following error:

semantic error TS2304: Cannot find name 'Fragment'
rschristian commented 1 year ago

Please provide your input, else we're left guessing on how to accurately reproduce.

daniele-zurico commented 1 year ago

@rschristian I linked the project ... btw it's https://github.com/Capgemini/dcx-react-library

rschristian commented 1 year ago

You referenced this issue from another project but that's not a minimal reproduction.

Just copy/paste the input that triggers this please.

daniele-zurico commented 1 year ago

the full error is:

danielezurico@Danieles-MacBook-Pro dcx-react-library % yarn dev
yarn run v1.22.10
$ microbundle watch --jsx React.createElement
Watching source, compiling to dist:
(rpt2 plugin) Error: /Users/danielezurico/Documents/Projects/dcx-react-library/src/autocomplete/Autocomplete.tsx(369,5): semantic error TS2304: Cannot find name 'Fragment'.
Error: /Users/danielezurico/Documents/Projects/dcx-react-library/src/autocomplete/Autocomplete.tsx(369,5): semantic error TS2304: Cannot find name 'Fragment'.
    at error (/Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/rollup/dist/shared/rollup.js:198:30)
    at throwPluginError (/Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/rollup/dist/shared/rollup.js:21894:12)
    at Object.error (/Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/rollup/dist/shared/rollup.js:22616:20)
    at Object.error (/Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/rollup/dist/shared/rollup.js:22071:42)
    at RollupContext.error (/Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20259:30)
    at /Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29527:23
    at Array.forEach (<anonymous>)
    at printDiagnostics (/Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29500:17)
    at Object.transform (/Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/microbundle/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29785:17)
    at /Users/danielezurico/Documents/Projects/dcx-react-library/node_modules/rollup/dist/shared/rollup.js:22825:37

same error if I run:

yarn build
rschristian commented 1 year ago

You'll need to use --jsxFragment to set a custom fragment pragma.

You were (unknowingly) relying upon our workaround for a TS bug regarding resolving fragments when the jsxFactory was set.

Microbundle defaults to Preact's JSX practices, which essentially is --jsx h --jsxFragment Fragment. Like with --jsx, you'll need to correct the fragment pragma to React.