Skip to content
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

Fix @google/generative-ai/files paths #156

Merged
merged 4 commits into from
May 28, 2024
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/calm-otters-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google/generative-ai": patch
---

Fix paths to @google/generative-ai/files.
2 changes: 1 addition & 1 deletion packages/main/api-extractor.files.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../../config/api-extractor.json",
"mainEntryPointFilePath": "<projectFolder>/dist/files/src/files/index.d.ts",
"mainEntryPointFilePath": "<projectFolder>/dist/src/files/index.d.ts",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/files/files.d.ts"
Expand Down
10 changes: 5 additions & 5 deletions packages/main/files/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@google/generative-ai/files",
"name": "@google/generative-ai-files",
"description": "GoogleAI file upload manager",
"main": "./dist/files/index.js",
"browser": "./dist/files/index.mjs",
"module": "./dist/files/index.mjs",
"typings": "./dist/files/files.d.ts"
"main": "../dist/files/index.js",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this break the module imports?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module imports? I realized it might affect the rollup config as it gets paths from here, so I changed that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this with tsconfig set to module:commonjs, module:node16 and in a vite bundler proejct and it seems to work in all cases.

"browser": "../dist/files/index.mjs",
"module": "../dist/files/index.mjs",
"typings": "../dist/files/files.d.ts"
}
9 changes: 6 additions & 3 deletions packages/main/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import typescriptPlugin from "rollup-plugin-typescript2";
import typescript from "typescript";
import json from "@rollup/plugin-json";
import pkg from "./package.json" assert { type: "json" };
import filePkg from "./files/package.json" assert { type: "json" };

const es2017BuildPlugins = [
typescriptPlugin({
Expand Down Expand Up @@ -65,13 +64,17 @@ const cjsBuilds = [
const filesBuilds = [
{
input: "src/files/index.ts",
output: [{ file: filePkg.module, format: "es", sourcemap: true }],
output: [
{ file: pkg.exports["./files"].import, format: "es", sourcemap: true },
],
external: ["fs"],
plugins: [...es2017BuildPlugins],
},
{
input: "src/files/index.ts",
output: [{ file: filePkg.main, format: "cjs", sourcemap: true }],
output: [
{ file: pkg.exports["./files"].require, format: "cjs", sourcemap: true },
],
external: ["fs"],
plugins: [...es2017BuildPlugins],
},
Expand Down
Loading