Revert back to static import of fs, don't like to CJS bundles in package.json

This commit is contained in:
Vanilagy
2026-04-28 14:24:58 +02:00
parent 1fd99b5015
commit bf9e360587
5 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -7,13 +7,13 @@
"workspaces": [
"packages/*"
],
"main": "./dist/bundles/mediabunny.cjs",
"main": "./dist/modules/src/index.js",
"module": "./dist/modules/src/index.js",
"types": "./dist/modules/src/index.d.ts",
"exports": {
"types": "./dist/modules/src/index.d.ts",
"import": "./dist/modules/src/index.js",
"require": "./dist/bundles/mediabunny.cjs"
"require": "./dist/modules/src/index.js"
},
"files": [
"README.md",
-1
View File
@@ -30,7 +30,6 @@ const createVariants = async (
*/`,
},
legalComments: 'none',
platform: 'node',
};
const umdConfig: esbuild.BuildOptions = {
+2 -1
View File
@@ -9,4 +9,5 @@
// 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 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.');
}
if (!node.getFs) {
if (!node.fs) {
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 (await node.getFs()).open(filePath, 'r');
this._fileHandle = await node.fs.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.getFs) {
if (!node.fs) {
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 (await node.getFs()).open(filePath, 'w');
this._fileHandle = await node.fs.open(filePath, 'w');
},
write: async (chunk) => {
assert(this._fileHandle);