Skip to content

Commit

Permalink
Add fs null fallback (#45)
Browse files Browse the repository at this point in the history
* feat: add `fs` fallback

* Update readme.md

* Stop polyfilling `console`, 'domain', `process`, and internal `stream` modules by default; rename `includeAliases` to `additionalAliases`, and allow ignoring the defaults with `onlyAliases`

Fixes #40, fixes #52, fixes #18, fixes #44

Signed-off-by: Richie Bendall <richiebendall@gmail.com>

* Add as default

Signed-off-by: Richie Bendall <richiebendall@gmail.com>

* Update readme.md

---------

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
Co-authored-by: Richie Bendall <richiebendall@gmail.com>
  • Loading branch information
afonsojramos and Richienb authored May 24, 2024
1 parent 08f793b commit 010fc94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare namespace NodePolyfillPlugin {
| 'crypto'
| 'domain'
| 'events'
| 'fs'
| 'http'
| 'https'
| 'os'
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const defaultPolyfills = new Set([
'constants',
'crypto',
'events',
'fs',
'http',
'https',
'os',
Expand Down Expand Up @@ -107,6 +108,7 @@ module.exports = class NodePolyfillPlugin {
crypto: require.resolve('crypto-browserify'),
domain: require.resolve('domain-browser'),
events: require.resolve('events/'),
fs: false,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module.exports = {
};
```

The `fs` module resolves to nothing because its functionality cannot replicated in the browser.

## API

### new NodePolyfillPlugin(options?)
Expand Down

0 comments on commit 010fc94

Please sign in to comment.