我尝试使用 solidjs
+包裹
+模板启动器项目:
https://github.com/tiagocavalcante/solidts-parcel--
@suid/材料
,例如按钮
,构建失败。
以下是重现的方法:
- 查看项目模板从关于about URL。
-
npm i -save @suid/材料
- 将以下内容放在
index.tsx
中:
import { render } from "solid-js/web";
import SuidButton from '@suid/material/Button'
function App() {
return <>
<SuidButton>Testing</SuidButton>
</>;
}
render(App, document.getElementById("app")!);
您将获得错误输出:
I've tried to use the SolidJS
+Parcel
+TypeScript
template starter project from here:
https://github.com/TiagoCavalcante/solidts-parcel
And once I import any element from @suid/material
, such as Button
, build fails.
Here's how to reproduce:
- Checkout project template from the about URL.
npm i --save @suid/material
- Put the following in
index.tsx
:
import { render } from "solid-js/web";
import SuidButton from '@suid/material/Button'
function App() {
return <>
<SuidButton>Testing</SuidButton>
</>;
}
render(App, document.getElementById("app")!);
You will get an error output:
???? Build failed.
@parcel/transformer-js: Expected ',', got 'ownerState'
C:\Users\alona\dev\parcel\node_modules\@suid\material\Button\Button.jsx:307:25
306 | const contextProps = useContext(ButtonGroupContext);
> 307 | Root ownerState={allProps} className={clsx(classes.root, otherProps.className, contextProps.className)} disabled={props.disabled} focusRipp
> | ^^^^^^^^^^
308 | <Show when={!!props.startIcon}>
309 | <ButtonStartIcon className={classes.startIcon} ownerState={allProps}>
My question is, how can I make it play well with @suid/material
?
it works fine when using ViteJS
instead of Parcel
This issue seems related:
https://github.com/parcel-bundler/parcel/issues/6176
I asked on their discord, and apparently Parcel
doesn't really support non-standard JS syntax in node_modules (like Typescript or JSX).
This means, that @suid/material
cannot be used with Parcel
, as well as others such as https://github.com/LXSMNSYC/solid-headless
发布评论
评论(1)
没有官方支持的包裹模板,但您不需要一个。
这是一个基本设置,它使用打字稿并支持热模块更换。我没有对
@suid/材料
进行测试,但是在您添加必要的依赖项之后,它应该有效。babel-preset-solid
和@babel/core
。包裹会自动拾取Babel配置,但最好坚持使用基于JSON的配置。由于包裹提供了自己的替代方案,因此无需
Babel-Transform-runtime
和Preset-env
我知道的一个小问题是Parceljs尚不支持有条件的出口,这使得Parceljs加载了SolidJ的生产而不是Solidjs,而不是它的发展建设。 https://github.com/solidjs/solidjs/solid-solid-refresh#other-dev-photh-dev----------------------------------------------------------------------------------------------------------------- dev--dother-dev--dev---the服务器
这不是包裹部分的缺点,而是由于Nodejs对某些常见兼容性问题的任意解决方案而引起的问题,该解决方案可以用插件解决。
您可以检查内容和文件结构的链接: htttps://stackover.com/a/a/a/75641238/7134134/7134134
There is no officially supported parcel template but you don't need one.
Here is a basic setup that uses typescript and supports Hot Module Replacement. I did not tested for
@suid/material
but with it should work after you add necessary dependencies.babel-preset-solid
and@babel/core
.Parcel automatically picks up babel configuration but it is best to stick to the json based configuration. There is no need for
babel-transform-runtime
andpreset-env
since parcel provides its own alternatives:One minor issue I know of is ParcelJS doesn't support conditional exports yet, which makes ParcelJS load the production build of SolidJS instead of its development build. https://github.com/solidjs/solid-refresh#other-dev-servers
This is not a shortcoming on Parcel's part but an issue due to NodeJS's arbitrary solutions to some common compatibility problems, which can be solved with a plugin.
You can check the link for contents and file structures: https://stackoverflow.com/a/75641238/7134134