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
View File
@@ -30,6 +30,7 @@ const createVariants = async (
*/`, */`,
}, },
legalComments: 'none', legalComments: 'none',
platform: 'node',
}; };
const umdConfig: esbuild.BuildOptions = { const umdConfig: esbuild.BuildOptions = {
+1 -2
View File
@@ -9,5 +9,4 @@
// This file contains Node.js-specific code that does not run in a browser. // 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 // Dynamic import so it can be included in the bundles and still work properly in the browser
export const getFs = () => import('node:fs/promises');
export * as fs from '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.'); throw new TypeError('options.maxCacheSize, when provided, must be a non-negative number.');
} }
if (!node.fs) { if (!node.getFs) {
throw new Error( throw new Error(
'FilePathSource is only available in server-side environments (Node.js, Bun, Deno).', '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 // Let's back this source with a StreamSource, makes the implementation very simple
this._streamSource = new StreamSource({ this._streamSource = new StreamSource({
getSize: async () => { 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(); const stats = await this._fileHandle.stat();
return stats.size; return stats.size;
+2 -2
View File
@@ -692,7 +692,7 @@ export class FilePathTarget extends Target {
throw new TypeError('options must be an object.'); throw new TypeError('options must be an object.');
} }
if (!node.fs) { if (!node.getFs) {
throw new Error( throw new Error(
'FilePathTarget is only available in server-side environments (Node.js, Bun, Deno).', '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 // Let's back this target with a StreamTarget, makes the implementation very simple
const writable = new WritableStream<StreamTargetChunk>({ const writable = new WritableStream<StreamTargetChunk>({
start: async () => { start: async () => {
this._fileHandle = await node.fs.open(filePath, 'w'); this._fileHandle = await (await node.getFs()).open(filePath, 'w');
}, },
write: async (chunk) => { write: async (chunk) => {
assert(this._fileHandle); assert(this._fileHandle);