question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building for browser as webpack library

See original GitHub issue

I’m looking for guidance please on my issue building module, azure/storage-blob, for the browser environment.

My index.js is: const { BlobServiceClient, AnonymousCredential, ContainerClient, BlobClient, BlockBlobClient } = require("@azure/storage-blob"); export { BlobServiceClient, AnonymousCredential, ContainerClient, BlobClient, BlockBlobClient };

My webpack.config.js is: const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'azure-storage.js', library: 'azurestorage' } };

The build completes and in my html I can import the library and use: blobBlockClient = azurestorage.BlobClient("BlobEndpoint=...",<containerName>,<blobName>)

However, the following errors occurs. Clients.js:120 Uncaught TypeError: _this.getBlobAndContainerNamesFromUrl is not a function I’m not sure what is causing this and whether it is the way I am bundling?

I saw that is just to set the containerName and blobName so I manually edited the code to define them and move beyond this error. Then I discovered that the uploadBrowserData() method is not available under blobBlockClient.blobContext. I don’t see any upload methods available? Please see the attached image.

blockBlobClient

What am I doing wrong with building this as a library that can be imported? Thank you.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jeremymengcommented, Sep 23, 2020

Also updateBrowserData() is a function in BlockBlobClient so you should use new azurestorage.BlockBlobClient() instead.

blobBlockClient.blobContext is our internal construct that we use to make service calls.

1reaction
jeremymengcommented, Sep 23, 2020

@jis260 you should use new with the constructor call. Could you please give it a try?

blobBlockClient = new azurestorage.BlobClient("BlobEndpoint=...",<containerName>,<blobName>)`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Authoring Libraries | webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
How to bundle js library for use in browser with webpack?
The library consists of one main function with prototypes that is exported and of several other functions it depends on that are imported...
Read more >
Recipes on how to create a library that supports both browser ...
About. Introduces how to build a library that supports both browser and Node.js using webpack4 and ES6, and how to use the created...
Read more >
How to bundle your library for both NodeJS and Browser with ...
How to build JavaScript libraries for multiple targets. ... How to bundle your library for both NodeJS and Browser with Webpack.
Read more >
riversun/making-library-with-webpack: How to build a ... - GitHub
Introduces how to build a library that supports both browser and Node.js using webpack4 and ES6, and how to use the created library....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found