ncoughlin / scroll-to-hash-element

A React component that listens passively to React-Router location and scrolls the page to the identified element if it exists.
MIT License
56 stars 6 forks source link

TypeScript Loader error when used with Create React App #9

Open yodiyo opened 1 month ago

yodiyo commented 1 month ago

I'm getting an error when trying to use this with CRA, even with the TS compiler.

Failed to compile. Module parse failed: The keyword 'interface' is reserved (4:0) File was processed with these loaders:

It's similar to an issue explain here - https://github.com/facebook/create-react-app/issues/5623 - the final comment suggests that the package should be compiled before publishing.

Hope that helps.

ncoughlin commented 1 month ago

I can look into this, however if you are starting a new project, I recommend that you look into Vite or Next, as CRA is deprecated. They stopped updating it years ago.

CalamityAdam commented 3 weeks ago

I'm seeing the same error in a webpack typescript react app. NOT using cra.

ERROR in ./node_modules/@cascadia-code/scroll-to-hash-element/src/index.tsx 4:0
Module parse failed: The keyword 'interface' is reserved (4:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
|
> interface ScrollToHashElementProps {
|   behavior?: ScrollBehavior;
|   inline?: ScrollLogicalPosition;

I'm guessing the build was not ran before publishing, because looking at the installed package in my node_modules/ shows only a src/index.tsx and no dist/index.js as called out by the package.json: "main": "dist/index.js",

Screenshot 2024-10-01 at 10 43 52 AM

ncoughlin commented 2 weeks ago

I'll check this out.

ncoughlin commented 2 weeks ago

I've updated to version 2.0.3 which now should output a compiled index.js file into the dist folder. Please let me know if this resolves the issue for you.