Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@preact/signals-react-transform ignoring .tsx files #563

Closed
zthng opened this issue May 14, 2024 · 4 comments
Closed

@preact/signals-react-transform ignoring .tsx files #563

zthng opened this issue May 14, 2024 · 4 comments

Comments

@zthng
Copy link

zthng commented May 14, 2024

Hello, the babel transform modules seems to evaluate all of my .tsx files as hasJSX: false for some reason.
Is there anywhere I should check with my configuration?

signals:react-transform:skipped SomeComponent (src/modules/myModule/SomeComponent.tsx:2) { hasSignals: false, hasJSX: false } +13ms

Example of SomeComponent.tsx:

export default function SomeComponent() {
	return (
		<div>
			<h1>Some Component</h1>
		</div>
	);
}

To add more information: I'm using babel + webpack to transpile a project with a mixture of JS/JSX/TS/TSX files

Currently using /** @useSignals */ to manually force the transformation, but would be great to better understand what's going on - not sure where to start.

@JoviDeCroock
Copy link
Member

JoviDeCroock commented May 14, 2024

Hmm, that's odd, are you using any special babel rules/transforms? https://github.com/preactjs/signals/blob/main/packages/react-transform/src/index.ts#L545-L550 all it looks for is an element/fragment

@rschristian
Copy link
Member

As you only mention .tsx, does it work correctly on .js/.jsx?

If so, the problem is likely an ordering problem, and you've told your TS Babel plugin to transpile JSX. You'll need to persist the JSX for this plugin.

@XantreDev
Copy link
Contributor

Can you provide order of babel plugins in your config?

@zthng
Copy link
Author

zthng commented May 15, 2024

Hey guys, thanks for the response! Darned timezones...

Here's my babel.config.json:

{
	"presets": [
		["@babel/preset-env", { "targets": { "node": "current" } }],
		["@babel/preset-react", { "runtime": "automatic" }],
		"@babel/preset-typescript"
	],
	"plugins": [
		["@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true }],
		"@babel/plugin-transform-class-properties",
		"module:@preact/signals-react-transform",
		"babel-plugin-styled-components"
	]
}

@rschristian - you're right, it's working perfectly fine for .js and .jsx files, only .tsx files affected.
Doing this in TSConfig allowed the components to be found:

{
	"compilerOptions": {
		"jsx": "preserve",
		// ...otherCompilerOptions
	},
	// ...otherOptions
}

@zthng zthng closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants