Skip to content

Add NodeJS support to Storage V8 #5149

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

Merged
merged 4 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]> (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