Skip to content

Commit 3b785dc

Browse files
mpodwysockideyaaeldeenmaorlegerjeremymeng
authored
[core] Upgrade to ES-Modules for core (#26238)
### Packages impacted by this PR - @azure/abort-controller - @azure/core-auth - @azure/core-client - @azure-rest/core-client - @azure/core-http-compat - @azure/core-lro - @azure/core-paging - @azure/core-rest-pipeline - @azure/core-sse - @azure/core-tracing - @azure/core-util - @azure/core-xml - @azure/logger - @typespec/ts-http-runtime ### Issues associated with this PR ### Describe the problem that is addressed by this PR This migrates the core packages from a hybrid of CJS and ESM to an ESM solution using [`tshy`](https://github.com/isaacs/tshy). The core is now ESM, implemented as a module, and projects using `tshy` to CommonJS and ESM. The ESM build targets we will target include: - ESM (Node) - Browser - React-Native - Bun - Deno This will allow each system to pick up the correct output instead of picking the browser bundle which has happened in the past. Currently, our bun and deno support is strictly through npm compatibility and we are not forking logic at this point for those runtimes. In order to support ESM, `sinon` does not allow for ESM module mocking, so we looked for an alterative in `vitest`. This PR also migrates all core packages stated above from Mocha/Chai for Node and Mocha/Chai/Karma for the browser to using `vitest` for all tests. Currently, the system builds a test bundle which targets the correct files such as those targeted for the browser, eg `log-browser.mts` becomes `log.js` in the compiled output. ### 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? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] 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) --------- Co-authored-by: Deyaaeldeen Almahallawi <[email protected]> Co-authored-by: Maor Leger <[email protected]> Co-authored-by: Jeremy Meng <[email protected]>
1 parent 3c750ba commit 3b785dc

File tree

518 files changed

+5880
-4152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

518 files changed

+5880
-4152
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,6 @@ _recordings
183183
/artifacts
184184

185185
sdk/template/template-dpg/src/src
186+
187+
# tshy
188+
.tshy-build-tmp

0 commit comments

Comments
 (0)