Skip to content

Add fs null fallback #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 7 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
// Other rules...
plugins: [
new NodePolyfillPlugin(),
]
],
};
```

Expand All @@ -35,11 +35,13 @@ module.exports = {
plugins: [
new NodePolyfillPlugin({
additionalAliases: ['process', 'punycode'],
})
}),
]
};
```

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

## API

### new NodePolyfillPlugin(options?)
Expand All @@ -62,7 +64,7 @@ module.exports = {
plugins: [
new NodePolyfillPlugin({
excludeAliases: ['console'],
})
}),
]
};
```
Expand All @@ -79,7 +81,7 @@ module.exports = {
plugins: [
new NodePolyfillPlugin({
additionalAliases: ['console'],
})
}),
]
};
```
Expand All @@ -96,7 +98,7 @@ module.exports = {
plugins: [
new NodePolyfillPlugin({
onlyAliases: ['console'],
})
}),
]
};
```
Expand Down
Loading