-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,031 additions
and
1,298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
import { resolve } from "path"; | ||
import { defineConfig } from "vite"; | ||
import generatePackageJson from "rollup-plugin-generate-package-json"; | ||
import packageJson from "./package.json"; | ||
import packageJson from "./package.json" assert { type: "json" }; | ||
import { builtinModules } from "node:module"; | ||
|
||
// NOTE: the @acme/shared package cannot be included into the deps casue it will attempt to be installed in | ||
// NOTE: the @acme/shared package cannot be included into the deps casue it will attempt to be installed in | ||
// the firebase function build step and fail, so as a work around we are using a bundler to move the code into the final bundle that we ship to firebase | ||
|
||
// NOTE: we are using vite for bundling but "native" support for nodejs is not yet available | ||
// for the tracking of that there is the following issue and if that is solved this implementation may change | ||
// https://github.com/vitejs/vite/issues/7821 | ||
|
||
const external = [...builtinModules, ...builtinModules.map((m) => `node:${m}`)]; | ||
|
||
export default defineConfig({ | ||
build: { | ||
lib: { | ||
entry: resolve(__dirname, "src/index.ts"), | ||
name: "firebase-functions-lib", | ||
fileName: "index", | ||
formats: ["es", "umd"], | ||
}, | ||
ssr: "./src/index.ts", | ||
outDir: "dist", | ||
rollupOptions: { | ||
external: Object.keys(packageJson.dependencies), | ||
// NOTE: Firebase requires a package.json to be present in the functions folder | ||
// this is a workaround to generate that file so firebase stays happy | ||
output: { | ||
inlineDynamicImports: true, | ||
}, | ||
preserveSymlinks: true, | ||
external, | ||
plugins: [ | ||
generatePackageJson({ | ||
// @ts-ignore | ||
baseContents: packageJson, | ||
}), | ||
], | ||
}, | ||
}, | ||
ssr: { | ||
external, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.