Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility for packing with webpack #17

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BlobBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
};

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = BlobBuffer(require('fs'));
module.exports = BlobBuffer;
} else {
window.BlobBuffer = BlobBuffer(null);
Copy link

@Cobertos Cobertos Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a little odd to me to have one platform exporting a function and the other exporting the return of the function. Maybe change main.js to call the function like browser.js does?

As a future feature, or maybe as part of this, I've also seen a pattern in other libraries to pass in fs as an external. It'd be nice if the user could just pass in whatever implementation of fs for whatever their needs are, meaning you could use anything from BrowserFS

}
Expand Down
2 changes: 1 addition & 1 deletion src/WebMWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@
};

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = WebMWriter(require("./ArrayBufferDataStream"), require("./BlobBuffer"));
module.exports = WebMWriter;
} else {
window.WebMWriter = WebMWriter(window.ArrayBufferDataStream, window.BlobBuffer);
}
Expand Down
1 change: 1 addition & 0 deletions src/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("./WebMWriter")(require("./ArrayBufferDataStream"), require("./BlobBuffer")(null));
1 change: 1 addition & 0 deletions src/main.js

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

3 changes: 2 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "webm-writer",
"version": "0.3.0",
"description": "Render WebM videos from Canvas frames",
"main": "WebMWriter.js",
"main": "main.js",
"browser": "browser.js",
"scripts": {
"test": "electron-mocha --renderer"
},
Expand Down
2 changes: 1 addition & 1 deletion src/test/BlobBuffer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const
BlobBuffer = require("../BlobBuffer");
BlobBuffer = require("../BlobBuffer")(require('fs'));

function assert(test, message) {
if (!test) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/empty-video.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const
WebMWriter = require("../WebMWriter");
WebMWriter = require("../main");

describe("WebMWriter", function() {
it("Doesn't crash when rendering a video with zero frames", function() {
Expand Down