From fa04a384bf3281ae6bf943490c15aeffc84f00f5 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Tue, 13 Sep 2022 15:45:07 -0700 Subject: [PATCH] [Doc][EventHubs,ServiceBus] Add information about bundling using Rollup (#23184) --- sdk/eventhub/event-hubs/README.md | 44 +++++++++++++++++++++++++++- sdk/servicebus/service-bus/README.md | 44 +++++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/sdk/eventhub/event-hubs/README.md b/sdk/eventhub/event-hubs/README.md index 7d4cc2196882..f8850fbeac26 100644 --- a/sdk/eventhub/event-hubs/README.md +++ b/sdk/eventhub/event-hubs/README.md @@ -61,7 +61,9 @@ In addition to what is described there, this library also needs additional polyf - `path` - `process` -For example, if you are using Webpack v5, you can install the following dev dependencies +#### Bundling with Webpack + +If you are using Webpack v5, you can install the following dev dependencies - `npm install --save-dev buffer os-browserify path-browserify process` @@ -95,6 +97,46 @@ then add the following into your webpack.config.js }, ``` +#### Bundling with Rollup + +If you are using Rollup bundler, install the following dev dependencies + +- `npm install --save-dev buffer process @rollup/plugin-commonjs @rollup/plugin-inject @rollup/plugin-node-resolve` + +Then include the following in your rollup.config.js + +```diff ++import nodeResolve from "@rollup/plugin-node-resolve"; ++import cjs from "@rollup/plugin-commonjs"; ++import shim from "rollup-plugin-shim"; ++import inject from "@rollup/plugin-inject"; + +export default { + // other configs + plugins: [ ++ shim({ ++ fs: `export default {}`, ++ net: `export default {}`, ++ tls: `export default {}`, ++ path: `export default {}`, ++ dns: `export function resolve() { }`, ++ }), ++ nodeResolve({ ++ mainFields: ["module", "browser"], ++ preferBuiltins: false, ++ }), ++ cjs(), ++ inject({ ++ modules: { ++ Buffer: ["buffer", "Buffer"], ++ process: "process", ++ }, ++ exclude: ["./**/package.json"], ++ }), + ] +}; +``` + Please consult the documentation of your favorite bundler for more information on using polyfills. ### Authenticate the client diff --git a/sdk/servicebus/service-bus/README.md b/sdk/servicebus/service-bus/README.md index be38e679932b..62216ba8c96f 100644 --- a/sdk/servicebus/service-bus/README.md +++ b/sdk/servicebus/service-bus/README.md @@ -58,7 +58,9 @@ In addition to what is described there, this library also needs additional polyf - `path` - `process` -For example, if you are using Webpack v5, you can install the following dev dependencies +#### Bundling with Webpack + +If you are using Webpack v5, you can install the following dev dependencies - `npm install --save-dev buffer os-browserify path-browserify process` @@ -92,6 +94,46 @@ then add the following into your webpack.config.js }, ``` +#### Bundling with Rollup + +If you are using Rollup bundler, install the following dev dependencies + +- `npm install --save-dev buffer process @rollup/plugin-commonjs @rollup/plugin-inject @rollup/plugin-node-resolve` + +Then include the following in your rollup.config.js + +```diff ++import nodeResolve from "@rollup/plugin-node-resolve"; ++import cjs from "@rollup/plugin-commonjs"; ++import shim from "rollup-plugin-shim"; ++import inject from "@rollup/plugin-inject"; + +export default { + // other configs + plugins: [ ++ shim({ ++ fs: `export default {}`, ++ net: `export default {}`, ++ tls: `export default {}`, ++ path: `export default {}`, ++ dns: `export function resolve() { }`, ++ }), ++ nodeResolve({ ++ mainFields: ["module", "browser"], ++ preferBuiltins: false, ++ }), ++ cjs(), ++ inject({ ++ modules: { ++ Buffer: ["buffer", "Buffer"], ++ process: "process", ++ }, ++ exclude: ["./**/package.json"], ++ }), + ] +}; +``` + Please consult the documentation of your favorite bundler for more information on using polyfills. ### Authenticate the client