florian-lefebvre / astro-loading-indicator

Display a progress bar between page navigations when using View Transitions
MIT License
66 stars 6 forks source link

failed [vite] Pre-transform error #3

Closed deluxefx closed 8 months ago

deluxefx commented 8 months ago

I could not install this.

Re-optimizing dependencies because lockfile has changed 11:42:20 AM [vite] Pre-transform error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension. [astro] Unable to load your Astro config

florian-lefebvre commented 8 months ago

Thanks for creating an issue! Can you create a minimal reproduction at https://astro.new? Hard to tell without it

deluxefx commented 8 months ago

No error when i installed on a minimal project from astro.new

Is it possible for you to test on https://github.com/onwidget/astrowind ?

florian-lefebvre commented 8 months ago

Would be even better if you had a repo using astrowind and my integration! If not, I'll do it! Can you just run astro info and give me the result?

deluxefx commented 8 months ago

`npx astro info 7:26:39 PM [vite] Pre-transform error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension. [astro] Unable to load your Astro config

Expression expected Stack trace: at error (file:///Users/iamtra/Next_JS/astrowind-maint/node_modules/rollup/dist/es/shared/parseAst.js:337:30) at convertNode (file:///Users/iamtra/Next_JS/astrowind-maint/node_modules/rollup/dist/es/shared/parseAst.js:2057:12) at parseAstAsync (file:///Users/iamtra/Next_JS/astrowind-maint/node_modules/rollup/dist/es/shared/parseAst.js:2108:12) at async loadAndTransform (file:///Users/iamtra/Next_JS/astrowind-maint/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:49789:11) iamtra@Umits-MacBook-Air astrowind-maint % `

florian-lefebvre commented 8 months ago

alright I'll give it a shot and get back to you

florian-lefebvre commented 8 months ago

I can reproduce 👍, https://github.com/florian-lefebvre/astro-loading-indicator-astrowind-debug

deluxefx commented 8 months ago

Oh thats good. What may cause this? "Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension."

florian-lefebvre commented 8 months ago

Tbh that's the first time I see this error, I've asked for help on Astro's Discord

martrapp commented 8 months ago

Hi @Florian, I, too, was not able to quickly spot the cause of this error, but it does not come from the integration part, but from the stand-alone component. If people just want to use the automatic integration and not the "loading indicator as an dedicated Astro component", deleting line 3 (export { default as LoadingIndicator } from "./LoadingIndicator.astro";) from index.ts might help. Alternatively, version 0.0.1 (which was before the loading indicator as component was added) also seems to work fine.

martrapp commented 8 months ago

Sorry ^^^^ wrong mention @florian-lefebvre ^^^

florian-lefebvre commented 8 months ago

@martrapp thank you! So what you suggest is that I have another export for the standalone component instead of a barrel file?

martrapp commented 8 months ago

The bag exports .astro files and that works well. When you import them you have to import form "xyz.astro" but that's fine.

Maybe you should give it a try and see what happens when you rename index.ts to index.tsx?

florian-lefebvre commented 8 months ago

I think I'll simplify this package to just export a component, makes more sense than an integration!

florian-lefebvre commented 8 months ago

@martrapp with the component I get Uncaught SyntaxError: The requested module '/node_modules/nprogress/nprogress.js?v=dc65122b' does not provide an export named 'configure', do you know why? Here is a repro https://stackblitz.com/edit/github-vssgk8?file=src%2Fpages%2Findex.astro

martrapp commented 8 months ago

Looks like nprogress doesn't want to be imported from a ECMAScript Module. Its export code looks a bit strange. Last nprogress release was May 2015?

florian-lefebvre commented 8 months ago

I consider this issue fixed although the code is not working yet. Resolution in #2