s-KaiNet / spfx-fast-serve

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

"The keyword 'import' is reserved" after upgrading from 1.12 to 1.18 #123

Closed RoelVB closed 4 months ago

RoelVB commented 4 months ago

First, thank you for your work on this.

Second. I'm currently experiencing an issue after upgrading from 1.12 to 1.18. When I initially run fast-serve everything is fine. When I resave a file (without changes) I get the error Parsing error: The keyword 'import' is reserved (related to the file I just saved)

Output:

i 「wdm」: Time: 9388ms
Entrypoint my-web-part = my-web-part.js
i 「wdm」: Compiled successfully.
Issues checking in progress...
No issues found.
i 「wdm」: Compiling...
× 「wdm」: Time: 1257ms
Entrypoint my-web-part = my-web-part.js

ERROR in 
C:\Users\<cut>\Details.tsx
  1:1  error  Parsing error: The keyword 'import' is reserved

✖ 1 problem (1 error, 0 warnings)

i 「wdm」: Failed to compile.
Issues checking in progress...
No issues found.

Any ideas on how to solve this? I've already reinstalled the node_modules.

s-KaiNet commented 4 months ago

For me it looks like it's eslint related error. Could you try running npx fast-serve --eslint=false and see if the error is still here?

RoelVB commented 4 months ago

Thank you for the very fast reply. That does indeed solve my issue.

s-KaiNet commented 4 months ago

You could just copy the .eslintrc.js from newly scaffolded SPFx 1.18 hello world web part, or just use this one from samples. Then linting should work for you, so you could remove --eslint=false

pathaw commented 4 months ago

Hey @s-KaiNet, thanks for your engagement in the community. I'm still running into the above issue after trying the recommended steps you've provided. I'm currently using spfx-fast-serve-helpers 1.18.0. My fast serve doesn't appear to working and I'm still having the initial error @RoelVB posted. I'm attempting to upgrade my SPFX webpart from 1.10 to 1.18. I've deleted my lock file and node_modules folder multiple times. I've updated my eslintrc.js, tsconfig.js, and package.json files from referencing your example here.

s-KaiNet commented 4 months ago

@pathaw have you tried to disable eslint for fast-serve? Also, if you stil have the the problem, could you create a new issue, because it's just easier to track?

pathaw commented 4 months ago

@s-KaiNet yes I've tried that as well with no success. I'll create a new issue. Thanks for the quick reply.

lucmoco commented 1 month ago

I had this error and I was able to fix it by renaming the wrongly named file "eslint.js" as "eslintrc.js".