Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Strips jsxFactory from tsconfig if--importSource is set#988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rschristian wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromfix/jsx-import-source-tsconfig

Conversation

rschristian
Copy link
Collaborator

Closes#857

If a user supplies--jsxImportSource we should removejsxFactory andjsxFragmentFactory from the defaulttsconfig as they're mutually exclusive withjsx: 'react-jsx'.

trajano and danguilherme reacted with thumbs up emoji
@changeset-bot
Copy link

changeset-botbot commentedAug 10, 2022
edited
Loading

🦋 Changeset detected

Latest commit:e4d8db3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
microbundlePatch

Not sure what this means?Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rschristianrschristian changed the titlefix: Strips jsxFactory from tsconfig if --imporSource is setfix: Strips jsxFactory from tsconfig if--importSource is setAug 10, 2022
@github-actions
Copy link
Contributor

github-actionsbot commentedAug 10, 2022
edited
Loading

Size Change: 0 B

Total Size: 63.4 kB

ℹ️View Unchanged
FilenameSize
test/fixtures/alias-external/dist/alias-external.esm.mjs85 B
test/fixtures/alias-external/dist/alias-external.js80 B
test/fixtures/alias-external/dist/alias-external.umd.js140 B
test/fixtures/alias/dist/alias-mapping.esm.mjs62 B
test/fixtures/alias/dist/alias-mapping.js62 B
test/fixtures/alias/dist/alias-mapping.umd.js118 B
test/fixtures/async-iife-ts/dist/async-iife-ts.esm.mjs114 B
test/fixtures/async-iife-ts/dist/async-iife-ts.js111 B
test/fixtures/async-iife-ts/dist/async-iife-ts.umd.js161 B
test/fixtures/async-iife-ts/dist/index.d.ts20 B
test/fixtures/async-ts/dist/async-ts.esm.mjs159 B
test/fixtures/async-ts/dist/async-ts.js149 B
test/fixtures/async-ts/dist/async-ts.umd.js247 B
test/fixtures/async-ts/dist/index.d.ts75 B
test/fixtures/basic-babelrc/dist/basic-babelrc.esm.mjs160 B
test/fixtures/basic-babelrc/dist/basic-babelrc.js157 B
test/fixtures/basic-babelrc/dist/basic-babelrc.umd.js198 B
test/fixtures/basic-compress-false/dist/basic-compress-false.esm.mjs302 B
test/fixtures/basic-compress-false/dist/basic-compress-false.js300 B
test/fixtures/basic-compress-false/dist/basic-compress-false.umd.js422 B
test/fixtures/basic-css/dist/basic-css.css106 B
test/fixtures/basic-css/dist/basic-css.esm.mjs143 B
test/fixtures/basic-css/dist/basic-css.js139 B
test/fixtures/basic-css/dist/basic-css.umd.js227 B
test/fixtures/basic-dashed-external/dist/basic-dashed-external.esm.mjs256 B
test/fixtures/basic-dashed-external/dist/basic-dashed-external.js312 B
test/fixtures/basic-dashed-external/dist/basic-dashed-external.umd.js395 B
test/fixtures/basic-flow/dist/basic-lib-flow.esm.mjs104 B
test/fixtures/basic-flow/dist/basic-lib-flow.js100 B
test/fixtures/basic-flow/dist/basic-lib-flow.umd.js206 B
test/fixtures/basic-json/dist/basic-json.esm.mjs128 B
test/fixtures/basic-json/dist/basic-json.js125 B
test/fixtures/basic-json/dist/basic-json.umd.js217 B
test/fixtures/basic-multi-source-css/dist/a.css97 B
test/fixtures/basic-multi-source-css/dist/a.esm.mjs135 B
test/fixtures/basic-multi-source-css/dist/a.js130 B
test/fixtures/basic-multi-source-css/dist/a.umd.js226 B
test/fixtures/basic-multi-source-css/dist/b.css96 B
test/fixtures/basic-multi-source-css/dist/b.esm.mjs135 B
test/fixtures/basic-multi-source-css/dist/b.js131 B
test/fixtures/basic-multi-source-css/dist/b.umd.js227 B
test/fixtures/basic-multi-source/dist/a.esm.mjs78 B
test/fixtures/basic-multi-source/dist/a.js73 B
test/fixtures/basic-multi-source/dist/a.umd.js133 B
test/fixtures/basic-multi-source/dist/b.esm.mjs78 B
test/fixtures/basic-multi-source/dist/b.js73 B
test/fixtures/basic-multi-source/dist/b.umd.js133 B
test/fixtures/basic-no-compress/dist/basic-no-compress.esm.mjs300 B
test/fixtures/basic-no-compress/dist/basic-no-compress.js298 B
test/fixtures/basic-no-compress/dist/basic-no-compress.umd.js422 B
test/fixtures/basic-no-pkg-main/dist/basic-no-pkg-main.js315 B
test/fixtures/basic-node-internals/dist/basic-node-internals.js232 B
test/fixtures/basic-ts/dist/basic-lib-ts.esm.mjs156 B
test/fixtures/basic-ts/dist/basic-lib-ts.js153 B
test/fixtures/basic-ts/dist/basic-lib-ts.umd.js235 B
test/fixtures/basic-ts/dist/car.d.ts117 B
test/fixtures/basic-ts/dist/index.d.ts83 B
test/fixtures/basic-tsx/dist/basic-lib-tsx.esm.mjs254 B
test/fixtures/basic-tsx/dist/basic-lib-tsx.js246 B
test/fixtures/basic-tsx/dist/basic-lib-tsx.umd.js331 B
test/fixtures/basic-tsx/dist/index.d.ts69 B
test/fixtures/basic-with-cwd/basic/dist/basic.esm.mjs224 B
test/fixtures/basic-with-cwd/basic/dist/basic.js221 B
test/fixtures/basic-with-cwd/basic/dist/basic.umd.js301 B
test/fixtures/basic/dist/basic-lib.esm.mjs227 B
test/fixtures/basic/dist/basic-lib.js224 B
test/fixtures/basic/dist/basic-lib.umd.js307 B
test/fixtures/class-decorators-ts/dist/class-decorators-ts.esm.mjs388 B
test/fixtures/class-decorators-ts/dist/class-decorators-ts.js386 B
test/fixtures/class-decorators-ts/dist/class-decorators-ts.umd.js451 B
test/fixtures/class-decorators-ts/dist/index.d.ts123 B
test/fixtures/class-properties/dist/class-properties.esm.mjs140 B
test/fixtures/class-properties/dist/class-properties.js135 B
test/fixtures/class-properties/dist/class-properties.umd.js235 B
test/fixtures/css-modules--false/dist/css-modules--false.css114 B
test/fixtures/css-modules--false/dist/css-modules--false.esm.mjs52 B
test/fixtures/css-modules--false/dist/css-modules--false.js49 B
test/fixtures/css-modules--false/dist/css-modules--false.umd.js156 B
test/fixtures/css-modules--null/dist/css-modules--null.css118 B
test/fixtures/css-modules--null/dist/css-modules--null.esm.mjs112 B
test/fixtures/css-modules--null/dist/css-modules--null.js110 B
test/fixtures/css-modules--null/dist/css-modules--null.umd.js200 B
test/fixtures/css-modules--string/dist/css-modules--string.css144 B
test/fixtures/css-modules--string/dist/css-modules--string.esm.mjs168 B
test/fixtures/css-modules--string/dist/css-modules--string.js166 B
test/fixtures/css-modules--string/dist/css-modules--string.umd.js263 B
test/fixtures/css-modules--true/dist/css-modules--true.css115 B
test/fixtures/css-modules--true/dist/css-modules--true.esm.mjs141 B
test/fixtures/css-modules--true/dist/css-modules--true.js139 B
test/fixtures/css-modules--true/dist/css-modules--true.umd.js230 B
test/fixtures/custom-babelrc/dist/custom-babelrc.esm.mjs259 B
test/fixtures/custom-babelrc/dist/custom-babelrc.js252 B
test/fixtures/custom-babelrc/dist/custom-babelrc.umd.js343 B
test/fixtures/custom-source-with-cwd/custom-source/dist/custom-src.esm.mjs227 B
test/fixtures/custom-source-with-cwd/custom-source/dist/custom-src.js224 B
test/fixtures/custom-source-with-cwd/custom-source/dist/custom-src.umd.js306 B
test/fixtures/custom-source/dist/custom-source.esm.mjs227 B
test/fixtures/custom-source/dist/custom-source.js224 B
test/fixtures/custom-source/dist/custom-source.umd.js307 B
test/fixtures/default-named/dist/default-named.esm.mjs116 B
test/fixtures/default-named/dist/default-named.js97 B
test/fixtures/default-named/dist/default-named.umd.js201 B
test/fixtures/define-expression/dist/define-expression.esm.mjs56 B
test/fixtures/define/dist/define.esm.mjs55 B
test/fixtures/define/dist/define.js55 B
test/fixtures/define/dist/define.umd.js108 B
test/fixtures/esnext-ts/dist/esnext-ts.esm.mjs1.05 kB
test/fixtures/esnext-ts/dist/esnext-ts.js1.04 kB
test/fixtures/esnext-ts/dist/esnext-ts.umd.js1.11 kB
test/fixtures/esnext-ts/dist/index.d.ts68 B
test/fixtures/inline-source-map/dist/inline-source-map.esm.mjs740 B
test/fixtures/inline-source-map/dist/inline-source-map.js739 B
test/fixtures/inline-source-map/dist/inline-source-map.umd.js827 B
test/fixtures/jsx/dist/jsx.esm.mjs267 B
test/fixtures/jsx/dist/jsx.js264 B
test/fixtures/jsx/dist/jsx.umd.js341 B
test/fixtures/macro/dist/macro-lib.esm.mjs88 B
test/fixtures/macro/dist/macro-lib.js84 B
test/fixtures/macro/dist/macro-lib.umd.js187 B
test/fixtures/mangle-json-file/dist/mangle-json-file.esm.mjs148 B
test/fixtures/mangle-json-file/dist/mangle-json-file.js143 B
test/fixtures/mangle-json-file/dist/mangle-json-file.umd.js235 B
test/fixtures/minify-config-boolean/dist/minify-config-boolean.esm.mjs161 B
test/fixtures/minify-config-boolean/dist/minify-config-boolean.js152 B
test/fixtures/minify-config-boolean/dist/minify-config-boolean.umd.js254 B
test/fixtures/minify-config/dist/minify-config.esm.mjs143 B
test/fixtures/minify-config/dist/minify-config.js137 B
test/fixtures/minify-config/dist/minify-config.umd.js226 B
test/fixtures/minify-path-config/dist/minify-path-config.esm.mjs151 B
test/fixtures/minify-path-config/dist/minify-path-config.js145 B
test/fixtures/minify-path-config/dist/minify-path-config.umd.js237 B
test/fixtures/minify-path-parent-dir-with-cwd/minify-path-parent-dir/dist/minify-path-parent-dir.esm.mjs153 B
test/fixtures/minify-path-parent-dir-with-cwd/minify-path-parent-dir/dist/minify-path-parent-dir.js149 B
test/fixtures/minify-path-parent-dir-with-cwd/minify-path-parent-dir/dist/minify-path-parent-dir.umd.js242 B
test/fixtures/modern-generators/dist/modern-generators.esm.mjs282 B
test/fixtures/modern-generators/dist/modern-generators.js279 B
test/fixtures/modern-generators/dist/modern-generators.modern.mjs159 B
test/fixtures/modern-generators/dist/modern-generators.umd.js358 B
test/fixtures/modern/dist/modern-lib.modern.mjs152 B
test/fixtures/name-custom-amd/dist/name-custom-amd.esm.mjs230 B
test/fixtures/name-custom-amd/dist/name-custom-amd.js226 B
test/fixtures/name-custom-amd/dist/name-custom-amd.umd.js312 B
test/fixtures/name-custom-cli/dist/name-custom.esm.mjs227 B
test/fixtures/name-custom-cli/dist/name-custom.js224 B
test/fixtures/name-custom-cli/dist/name-custom.umd.js311 B
test/fixtures/no-pkg-name/dist/no-pkg-name.esm.mjs229 B
test/fixtures/no-pkg-name/dist/no-pkg-name.js225 B
test/fixtures/no-pkg-name/dist/no-pkg-name.umd.js311 B
test/fixtures/no-pkg/dist/no-pkg.esm.mjs225 B
test/fixtures/no-pkg/dist/no-pkg.js222 B
test/fixtures/no-pkg/dist/no-pkg.umd.js303 B
test/fixtures/optional-chaining-ts/dist/index.d.ts107 B
test/fixtures/optional-chaining-ts/dist/optional-chaining-ts.esm.mjs154 B
test/fixtures/optional-chaining-ts/dist/optional-chaining-ts.js148 B
test/fixtures/optional-chaining-ts/dist/optional-chaining-ts.umd.js247 B
test/fixtures/parameters-rest-closure/dist/parameters-rest-closure.esm.mjs202 B
test/fixtures/parameters-rest-closure/dist/parameters-rest-closure.js191 B
test/fixtures/parameters-rest-closure/dist/parameters-rest-closure.umd.js283 B
test/fixtures/pretty/dist/pretty.esm.mjs6.39 kB
test/fixtures/pretty/dist/pretty.js6.37 kB
test/fixtures/pretty/dist/pretty.umd.js6.5 kB
test/fixtures/publish-config/dist/bar.js87 B
test/fixtures/publish-config/dist/foo.d.ts60 B
test/fixtures/pure/dist/pure.esm.mjs108 B
test/fixtures/pure/dist/pure.js98 B
test/fixtures/pure/dist/pure.umd.js197 B
test/fixtures/raw/dist/raw.esm.mjs1.43 kB
test/fixtures/raw/dist/raw.js1.42 kB
test/fixtures/raw/dist/raw.umd.js1.53 kB
test/fixtures/shebang/dist/shebang.esm.mjs125 B
test/fixtures/shebang/dist/shebang.js118 B
test/fixtures/shebang/dist/shebang.umd.js216 B
test/fixtures/terser-annotations/dist/terser-annotations.esm.mjs179 B
test/fixtures/terser-annotations/dist/terser-annotations.js171 B
test/fixtures/terser-annotations/dist/terser-annotations.umd.js258 B
test/fixtures/ts-custom-declaration/dist/index.esm.mjs100 B
test/fixtures/ts-custom-declaration/dist/index.js89 B
test/fixtures/ts-custom-declaration/dist/index.umd.js206 B
test/fixtures/ts-declaration/dist/index.esm.mjs100 B
test/fixtures/ts-declaration/dist/index.js89 B
test/fixtures/ts-declaration/dist/index.umd.js202 B
test/fixtures/ts-jsx/dist/index.d.ts52 B
test/fixtures/ts-jsx/dist/ts-jsx.esm.mjs164 B
test/fixtures/ts-jsx/dist/ts-jsx.js159 B
test/fixtures/ts-jsx/dist/ts-jsx.umd.js252 B
test/fixtures/ts-mixed-exports/dist/car.d.ts117 B
test/fixtures/ts-mixed-exports/dist/index.d.ts89 B
test/fixtures/ts-mixed-exports/dist/ts-mixed-exports.esm.mjs168 B
test/fixtures/ts-mixed-exports/dist/ts-mixed-exports.js159 B
test/fixtures/ts-mixed-exports/dist/ts-mixed-exports.umd.js261 B
test/fixtures/ts-module/dist/foo.d.ts60 B
test/fixtures/ts-module/dist/index.d.ts63 B
test/fixtures/ts-module/dist/ts-module.esm.mjs108 B
test/fixtures/ts-module/dist/ts-module.js97 B
test/fixtures/ts-module/dist/ts-module.umd.js197 B
test/fixtures/visualizer/dist/visualizer.esm.mjs119 B
test/fixtures/visualizer/dist/visualizer.js177 B
test/fixtures/visualizer/dist/visualizer.umd.js260 B
test/fixtures/worker-loader/dist/worker-35b22e56.js125 B
test/fixtures/worker-loader/dist/worker-7e1b9921.js107 B
test/fixtures/worker-loader/dist/worker-loader.esm.mjs180 B
test/fixtures/worker-loader/dist/worker-loader.modern.mjs174 B

compressed-size-action

@rschristianrschristianforce-pushed thefix/jsx-import-source-tsconfig branch from2f6f13f to74de373CompareAugust 10, 2022 07:37
@rschristianrschristianforce-pushed thefix/jsx-import-source-tsconfig branch from74de373 toe4d8db3CompareAugust 10, 2022 19:32
Comment on lines +553 to +562
...(options.jsxImportSource
? {
jsx: 'react-jsx',
jsxImportSource: options.jsxImportSource,
}
: {
jsx: 'preserve',
jsxFactory: options.jsx,
jsxFragmentFactory: options.jsxFragment,
}),
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Theoretically we would be fine to leavejsx untouched & remove that first piece of the ternary, however, that relies on the assumption that the user does have atsconfig.json and that it's correctly set.

Conditionally addingjsxFactory (andjsxFragmentFactory) is enough to quell the errors we were getting in the linked issue, but when using--jsxImportSource with TS, thetsconfig.json will need to have different values. While users in all likelihood will have atsconfig.json that's correctly configured in that case, if they do not, their typings will containany where JSX references should be.

Setting these configurations ourselves, at least as defaults, allows us to make fewer assumptions about users' configs that are external to Microbundle (and hopefully will raise fewer issues).

jsxImportSource: options.jsxImportSource,
}
: {
jsx: 'preserve',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should this bepreserve, orreact?

Copy link
CollaboratorAuthor

@rschristianrschristianAug 11, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

preserve should be correct, though from my quick tests I don't think it makes a difference either way.

preserve is to be used when having another tool transpile JSX (e.g., babel), which is what we do.react on the other hand has TSC transpile it itself.TS Docs

I think, at best,react would do nothing, and at worst, it'd slow down type generation due to trying to handle JSX which we don't need. No one's raised any issues regardingpreserve so I'd assume it's fine.

Edit: Depends on what we want, I suppose. I'd prefer to have TS handle as little as possible andpreserve is already the default behavior. I didn't originally realize we did have TS handle JSX.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@developitdevelopitdevelopit left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

react-jsx does not work with Preact
2 participants
@rschristian@developit

[8]ページ先頭

©2009-2025 Movatter.jp