Skip to content

[v9] Can't import from firebase/messaging/sw with Webpack 5 build #5314

Closed
@jhuleatt

Description

@jhuleatt

[REQUIRED] Describe your environment

  • Operating System version: Mac OS 11.5.1
  • Browser version: Chrome
  • Firebase SDK version: 9.0.0-beta.8
  • Firebase Product: messaging

[REQUIRED] Describe the problem

When I try to import the service worker version of getMessaging:

import { getMessaging } from 'firebase/messaging/sw'; 

Webpack gives me the following error:

ERROR in ./node_modules/firebase/messaging/sw/dist/index.esm.js 1:0-75
Module not found: Error: Can't resolve '@firebase/messaging/sw' in '/Users/jhuleatt/git/fcm-v9-repro/node_modules/firebase/messaging/sw/dist'
Did you mean 'index.sw.esm2017.js'?

Steps to reproduce:

  1. Clone https://github.com/jhuleatt/fcm-v9-repro
  2. Run npm install
  3. Run npm run build
  4. You'll see that src/index.js compiles without error, but src/firebase-messaging-sw.js gives the above error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions