Skip to content

Commit

Permalink
Add CJS build for messaging/sw (#5884)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Jan 13, 2022
1 parent ff2f7d4 commit 88d43ec
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slow-bobcats-clap.md
@@ -0,0 +1,5 @@
---
'@firebase/messaging': patch
---

Add a CJS bundle for messaging/sw. This enables some SSR frameworks to run their Node.js pipelines without erroring.
7 changes: 6 additions & 1 deletion packages/messaging/package.json
Expand Up @@ -7,6 +7,7 @@
"browser": "dist/esm/index.esm2017.js",
"module": "dist/esm/index.esm2017.js",
"sw": "dist/index.sw.esm2017.js",
"sw-main": "dist/index.sw.cjs",
"esm5": "dist/esm/index.esm.js",
"exports": {
".": {
Expand All @@ -15,7 +16,11 @@
"esm5": "./dist/esm/index.esm.js",
"default": "./dist/index.cjs.js"
},
"./sw": "./dist/index.sw.esm2017.js",
"./sw": {
"require": "./dist/index.sw.cjs",
"import": "./dist/index.sw.esm2017.js",
"default": "./dist/index.sw.esm2017.js"
},
"./package.json": "./package.json"
},
"typings": "dist/src/index.d.ts",
Expand Down
14 changes: 14 additions & 0 deletions packages/messaging/rollup.config.js
Expand Up @@ -89,6 +89,20 @@ const cjsBuilds = [
replace(generateBuildTargetReplaceConfig('cjs', 5))
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
// sw build
// TODO: This may no longer be necessary when we can provide ESM Node
// builds (contingent on updating the `idb` dependency). When we add
// ESM Node builds, test with Nuxt and other SSR frameworks to see if
// this can then be removed.
{
input: 'src/index.sw.ts',
output: { file: pkg['sw-main'], format: 'cjs', sourcemap: true },
plugins: [
...es5BuildPlugins,
replace(generateBuildTargetReplaceConfig('cjs', 5))
],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}
];

Expand Down
1 change: 1 addition & 0 deletions packages/messaging/sw/package.json
Expand Up @@ -2,6 +2,7 @@
"name": "@firebase/messaging-sw",
"description": "",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"main": "../dist/index.sw.cjs",
"module": "../dist/index.sw.esm2017.js",
"typings": "../dist/src/index.sw.d.ts"
}

0 comments on commit 88d43ec

Please sign in to comment.