Skip to content

Commit

Permalink
Add NodeJS support to Storage V8 (#5149)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Jul 14, 2021
1 parent fb3e359 commit b3caa51
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-shrimps-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
@firebase/storage: minor
---

Add NodeJS support to Cloud Storage for Firebase. This release changes the `main` field in package.json to point to a Node specific build. If you are building a bundle for borwser usage, please make sure that your bundler uses the `browser` field (the default).
10 changes: 5 additions & 5 deletions packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "0.5.6",
"description": "",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"browser": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"main": "dist/index.node.cjs.js",
"module": "dist/index.browser.esm.js",
"browser": "dist/index.browser.esm.js",
"esm2017": "dist/index.browser.esm2017.js",
"files": [
"dist",
"exp/dist"
Expand Down Expand Up @@ -66,4 +66,4 @@
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"typings": "dist/index.d.ts"
}
}
24 changes: 20 additions & 4 deletions packages/storage/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const { generateAliasConfig } = require('./rollup.shared');
const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

const nodeDeps = [...deps, 'util'];

/**
* ES5 Builds
*/
Expand All @@ -39,10 +42,7 @@ const es5BuildPlugins = [
const es5Builds = [
{
input: './index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
],
output: { file: pkg.module, format: 'es', sourcemap: true },
plugins: [alias(generateAliasConfig('browser')), ...es5BuildPlugins],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
treeshake: {
Expand All @@ -67,6 +67,22 @@ const es2017BuildPlugins = [
];

const es2017Builds = [
// Node
{
input: './index.ts',
output: {
file: pkg.main,
format: 'cjs',
sourcemap: true
},
plugins: [alias(generateAliasConfig('node')), ...es2017BuildPlugins],
external: id =>
nodeDeps.some(dep => id === dep || id.startsWith(`${dep}/`)),
treeshake: {
moduleSideEffects: false
}
},
// Browser
{
input: './index.ts',
output: {
Expand Down

0 comments on commit b3caa51

Please sign in to comment.