New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase v9 and Nuxt 2.15.8 - SyntaxError: Cannot use import statement outside a module #5854
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Could be related to #5839 (comment) |
Can you check something for me really quick, can you go into your project and open |
Hi @hsubox76 that didn't work. I got the same error. |
One more guess, what if you change the extension of Also I don't think this is the cause of your problem, but If changing the extension doesn't work, can you provide a minimal reproduction of the issue and upload it to github, and I can try to work with it? |
@hsubox76 Strange that it's async and hasn't given me an issue. Inserting that check was actually a patch for iOS safari about a year ago and it worked so I didn't think twice about it. I'll still fix it though, thanks! To this issue at hand, should I leave |
@hsubox76 I've tried both ways and both yielded the below error:
|
Hi @hsubox76 I've created the minimal reproduction repo https://github.com/simeon9696/firebasev9-nuxt The repo was created using the following steps:
You can replicate the error by running |
Thanks, it seems like nuxt generate insists on using the Node cjs version of messaging-compat, which is unable to load messaging/sw, which is only available as ESM. I think I can create a cjs version of messaging/sw although it's a little odd because cjs implies a Node environment, which a service worker shouldn't and can't be running in. I guess Nuxt is trying to use Node to generate static pages which will actually eventually be viewed in a browser so it's okay? I'll do a bit of double checking and then probably create a CJS version of messaging/sw and will update here. |
I'm not totally certain how Nuxt's module resolution order works but I think that if we offer a Node ESM entry point for messaging-compat, which I'm planning to do as part of resolving #5839, Nuxt should use that entry point and thus be able to use the messaging/sw ESM build. I'll try that first, after the IDB version is updated, and then see if it works on the repro you provided. |
@hsubox76 Thanks for the update! |
Not able to create an ESM Node build for messaging for now but 9.6.3 has been published and contains a CJS build for messaging/sw and seems to fix the problem in the test repo you provided. Let me know if it works. |
@hsubox76 Thank you so much! It's working now |
I'm migrating my codebase to use the firebase version 9 SDK and started to get this error once I started using v9 firestore. I've already migrated the auth part of my project and that works perfectly.
I should note, this only happens when I'm statically generating my website (
npm run generate
) but not when building the site for SSR (npm run build
). During development (npm run dev
) I get no errors. The error turns up for every page that has to be generated. It seems to be referencing the messaging module but I'm not using messaging on every page. I've tried using"type": "module"
in my package.json but that hasn't helped. See an example of the error below:plugins/firebase.js
I know this may/ may not be a firebase specific issue but I'd appreciate any assistance in getting it resolved.
Node version: 16.13.1
Nuxt version: 2.15.8
Firebase version: 9.6.1
The text was updated successfully, but these errors were encountered: