mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 10:53:50 +02:00
Switch back to dynamic import, leave package.json unchanged though
This commit is contained in:
+1
-2
@@ -9,5 +9,4 @@
|
||||
// This file contains Node.js-specific code that does not run in a browser.
|
||||
|
||||
// Dynamic import so it can be included in the bundles and still work properly in the browser
|
||||
|
||||
export * as fs from 'node:fs/promises';
|
||||
export const getFs = () => import('node:fs/promises');
|
||||
|
||||
+2
-2
@@ -959,7 +959,7 @@ export class FilePathSource extends PathedSource {
|
||||
throw new TypeError('options.maxCacheSize, when provided, must be a non-negative number.');
|
||||
}
|
||||
|
||||
if (!node.fs) {
|
||||
if (!node.getFs) {
|
||||
throw new Error(
|
||||
'FilePathSource is only available in server-side environments (Node.js, Bun, Deno).',
|
||||
);
|
||||
@@ -970,7 +970,7 @@ export class FilePathSource extends PathedSource {
|
||||
// Let's back this source with a StreamSource, makes the implementation very simple
|
||||
this._streamSource = new StreamSource({
|
||||
getSize: async () => {
|
||||
this._fileHandle = await node.fs.open(filePath, 'r');
|
||||
this._fileHandle = await (await node.getFs()).open(filePath, 'r');
|
||||
|
||||
const stats = await this._fileHandle.stat();
|
||||
return stats.size;
|
||||
|
||||
+2
-2
@@ -692,7 +692,7 @@ export class FilePathTarget extends Target {
|
||||
throw new TypeError('options must be an object.');
|
||||
}
|
||||
|
||||
if (!node.fs) {
|
||||
if (!node.getFs) {
|
||||
throw new Error(
|
||||
'FilePathTarget is only available in server-side environments (Node.js, Bun, Deno).',
|
||||
);
|
||||
@@ -703,7 +703,7 @@ export class FilePathTarget extends Target {
|
||||
// Let's back this target with a StreamTarget, makes the implementation very simple
|
||||
const writable = new WritableStream<StreamTargetChunk>({
|
||||
start: async () => {
|
||||
this._fileHandle = await node.fs.open(filePath, 'w');
|
||||
this._fileHandle = await (await node.getFs()).open(filePath, 'w');
|
||||
},
|
||||
write: async (chunk) => {
|
||||
assert(this._fileHandle);
|
||||
|
||||
Reference in New Issue
Block a user