Skip to content

Use writeBinaryToPath instead of require('fs').writeFileSync#13

Merged
willwade merged 1 commit into
AACTools:mainfrom
sonicbaume:remove-require-fs
Jan 17, 2026
Merged

Use writeBinaryToPath instead of require('fs').writeFileSync#13
willwade merged 1 commit into
AACTools:mainfrom
sonicbaume:remove-require-fs

Conversation

@chrisbaume

Copy link
Copy Markdown
Contributor

👋 Hello! I tried to import the browser package into a React Native project, but got the following error:

The package at "node_modules/@willwade/aac-processors/dist/browser/processors/gridsetProcessor.js" attempted to import the Node standard library module "fs".
It failed because the native React runtime does not include the Node standard library.
Learn more
  1617 |             const zipBuffer = await zip.generateAsync({ type: 'uint8array' });
  1618 |             // eslint-disable-next-line @typescript-eslint/no-var-requires
> 1619 |             require('fs').writeFileSync(outputPath, zipBuffer);
       |                      ^
  1620 |             return;
  1621 |         }
  1622 |         // Collect all unique styles from pages and buttons

Import stack:

 node_modules/@willwade/aac-processors/dist/browser/processors/gridsetProcessor.js
 | import "fs"

 node_modules/@willwade/aac-processors/dist/browser/index.browser.js
 | import "./processors/gridsetProcessor"

 app/index.tsx
 | import "@willwade/aac-processors/browser"

I'm not familiar with the codebase, but I can see that src/index.browser.ts imports src/processors/gridsetProcessor, which includes require('fs'). I wonder whether that should be using writeBinaryToPath from src/utils/io instead, as is used elsewhere?

@willwade

Copy link
Copy Markdown
Collaborator

Yeah for sure - I recently did a huge refactor to deal with dual publishing (node and cjs). This is clearly something I lost...

@willwade willwade merged commit 6a1bad5 into AACTools:main Jan 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants