s-KaiNet / spfx-fast-serve

Improve your SharePoint Framework development flow by speeding up the "serve" command :rocket:
MIT License
135 stars 11 forks source link

Loader for JS (non-typescript) Components #76

Closed frankmatull closed 2 years ago

frankmatull commented 2 years ago

For a React SPFx webpart, I am able to use the default gulp serve and use non-typescript components (e.g. ComponentOne.js instead of ComponentOne.tsx).

But when I add spfx-fast-serve and use npm run serve I get the error: Error in ./src/webparts/myWebPart/components/ComponentOne.js, You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. It works great if I don't have any .js components.

Is it possible to edit the webpack.extend.js to enable it to load js components in addition to tsx components? I've tried various ways, but can't get it to work.

s-KaiNet commented 2 years ago

It should be possible, but just curious, why do you need a JS-based component in a TypeScript solution?

frankmatull commented 2 years ago

Actually, I'm still not that proficient in typescript, and need to build the webpart quickly. I'm getting bogged down on the typescript end, and was hoping there was a way that I could load non-typescript react components until I can refactor them to use typescript. spfx-fast-serve has made things so much better, so I was hoping I might be able to add a loader to allow for js components in addition to tsx components.

s-KaiNet commented 2 years ago

TypeScript is a subset of JavaScript, meaning that you can name your file .tsx and put javascript code inside. But moving forward, I highly recommend proceeding with TypeScript, because it is extremely difficult to build any SharePoint webpart with SPFx and without using TypeScript.

frankmatull commented 2 years ago

Ok thanks, I agree that's a better way to go. Very appreciative of spfx-fast-serve, it has made the SPFx development experience so much better!

s-KaiNet commented 2 years ago

Thanks, then could we close the issue?

frankmatull commented 2 years ago

Yes, thanks