Skip to content

Commit

Permalink
fix: process is undefined error in browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeocodes committed Apr 30, 2024
1 parent 7a76f75 commit aaec494
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/browser-prerecorded/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<script src="../../dist/umd/deepgram.js"></script>
<script>
const { createClient } = deepgram;
const _deepgram = createClient("deepgram-api-key", {
global: {
fetch: {
options: {
url: "https://api.mock.deepgram.com",
},
},
},
});

console.log("Deepgram Instance: ", _deepgram);

(async () => {
const { result, error } = await _deepgram.manage.getProjects();

console.log(result, error);
})();

// ...
</script>
</head>
<body>
Running test... check the developer console.
</body>
</html>
6 changes: 6 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require("path");
const webpack = require("webpack");

module.exports = {
entry: "./src/index.ts",
Expand All @@ -24,4 +25,9 @@ module.exports = {
resolve: {
extensions: [".ts", ".js", ".json"],
},
plugins: [
new webpack.DefinePlugin({
"process.versions.node": JSON.stringify(process.versions.node),
}),
],
};

0 comments on commit aaec494

Please sign in to comment.