Switch back to dynamic import, leave package.json unchanged though

This commit is contained in:
Vanilagy
2026-04-28 14:36:48 +02:00
parent bf9e360587
commit ff46a274b1
4 changed files with 6 additions and 6 deletions
+1 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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);