Skip to content

Commit

Permalink
[OpenAI] Bundle using rollup v3 (#27258)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR
@azure/openai

### Issues associated with this PR
Fixes #27227
Fixes #27226

### Describe the problem that is addressed by this PR
`@azure/openai` depends on v4 of `formdata-node` and v1.7.2 of
`form-data-encoder`. However, those are outdated versions and we should
depend on recent versions of those libraries instead but the recent
versions are ESM-only. I couldn't find a way to bundle ESM code into cjs
using rollup v2, our current rollup version. With rollup v3, you can
bundle ESM-only code if you import it with dynamic imports and this PR
does exactly that.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?
N/A

### Are there test cases added in this PR? _(If not, why?)_
N/A

### Provide a list of related PRs _(if any)_
N/A

### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [x] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
  • Loading branch information
deyaaeldeen authored Sep 27, 2023
1 parent ab4452c commit c1bad73
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 35 deletions.
121 changes: 113 additions & 8 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions sdk/openai/openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
"build:samples": "echo Obsolete",
"generate": "pwsh ../../../eng/common/scripts/TypeSpec-Project-Sync.ps1 . && pwsh ../../../eng/common/scripts/TypeSpec-Project-Generate.ps1 .",
"customize": "rimraf src && dev-tool customization apply -s sources/generated/src && npm run format",
"build": "npm run clean && tsc -p . && dev-tool run bundle && api-extractor run --local",
"build:test": "tsc -p . && dev-tool run bundle",
"bundle": "tsc -p . && rollup -c ./rollup.config.js",
"build": "npm run clean && npm run bundle && api-extractor run --local",
"build:test": "npm run bundle",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-* temp types *.tgz *.log",
"execute:samples": "dev-tool samples run samples-dev",
Expand Down Expand Up @@ -104,8 +105,13 @@
"@azure/test-utils": "^1.0.0",
"@azure/core-rest-pipeline": "^1.12.0",
"@microsoft/api-extractor": "^7.31.1",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-multi-entry": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.1",
"@types/mocha": "^10.0.0",
"@types/node": "^14.0.0",
"builtin-modules": "^3.3.0",
"cross-env": "^7.0.3",
"dotenv": "^16.0.0",
"eslint": "^8.16.0",
Expand All @@ -128,6 +134,7 @@
"prettier": "^2.5.1",
"puppeteer": "^19.2.2",
"rimraf": "^3.0.2",
"rollup": "^3.29.3",
"ts-node": "^10.0.0",
"typescript": "~5.0.0"
},
Expand All @@ -138,8 +145,8 @@
"@azure/core-lro": "^2.5.3",
"@azure/core-rest-pipeline": "^1.10.2",
"@azure/logger": "^1.0.3",
"formdata-node": "^4.0.0",
"form-data-encoder": "1.7.2",
"formdata-node": "^5.0.0",
"form-data-encoder": "^3.0.0",
"tslib": "^2.4.0"
},
"//sampleConfiguration": {
Expand Down
Loading

0 comments on commit c1bad73

Please sign in to comment.