esbuild-plugins-node-modules-polyfill
Advanced tools
Comparing version 1.5.0-next.c02060d.0 to 1.5.0
@@ -5,2 +5,16 @@ # Changelog | ||
# [1.5.0](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/compare/v1.4.1...v1.5.0) - (2023-08-24) | ||
## 🐛 Bug Fixes | ||
- Use empty polyfill if browser field is false (#151) ([3946db8](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/commit/3946db8eca299559b708fdc1b0863b9d4582ef2c)) | ||
## 📝 Documentation | ||
- Update readme ([12bc0dd](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/commit/12bc0dd100b138910f91d80f569815cbbe59fa12)) | ||
## 🚀 Features | ||
- Allow modules to be marked as errors (#152) ([c02060d](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/commit/c02060d2c854b874fce98a2e4bada314f524faa6)) | ||
# [1.4.1](https://github.com/imranbarbhuiya/esbuild-plugins-node-modules-polyfill/compare/v1.4.0...v1.4.1) - (2023-08-23) | ||
@@ -7,0 +21,0 @@ |
{ | ||
"name": "esbuild-plugins-node-modules-polyfill", | ||
"version": "1.5.0-next.c02060d.0", | ||
"version": "1.5.0", | ||
"description": "Polyfills nodejs builtin modules and globals for the browser.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
127
README.md
@@ -43,3 +43,3 @@ <div align="center"> | ||
Optionally configure which modules to polyfill: | ||
### Inject globals when detected: | ||
@@ -50,9 +50,14 @@ ```ts | ||
build({ | ||
plugins: [nodeModulesPolyfillPlugin({ | ||
modules: ['crypto'], | ||
})], | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
globals: { | ||
process: true, | ||
Buffer: true, | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
Optionally provide empty polyfills: | ||
### Configure which modules to polyfill: | ||
@@ -63,13 +68,29 @@ ```ts | ||
build({ | ||
plugins: [nodeModulesPolyfillPlugin({ | ||
modules: { | ||
fs: 'empty', | ||
crypto: true, | ||
} | ||
})], | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
modules: ['crypto'], | ||
}), | ||
], | ||
}); | ||
``` | ||
Optionally provide empty fallbacks for any unpolyfilled or unconfigured modules: | ||
```ts | ||
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'; | ||
import { build } from 'esbuild'; | ||
build({ | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
modules: { | ||
crypto: true, | ||
fs: false, | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
### Provide empty polyfills: | ||
#### Provide empty polyfills for specific modules: | ||
```ts | ||
@@ -79,12 +100,14 @@ import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'; | ||
build({ | ||
plugins: [nodeModulesPolyfillPlugin({ | ||
fallback: 'empty', | ||
modules: { | ||
crypto: true, | ||
} | ||
})], | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
modules: { | ||
fs: 'empty', | ||
crypto: true, | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
Optionally inject globals when detected: | ||
#### Provide empty fallbacks for any unpolyfilled modules: | ||
@@ -95,12 +118,11 @@ ```ts | ||
build({ | ||
plugins: [nodeModulesPolyfillPlugin({ | ||
globals: { | ||
process: true, | ||
Buffer: true, | ||
} | ||
})], | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
fallback: 'empty', | ||
}), | ||
], | ||
}); | ||
``` | ||
Optionally fail the build when certain modules are used (note that the `write` build option must be `false` to support this): | ||
#### Provide empty fallbacks for any unconfigured modules: | ||
@@ -110,15 +132,40 @@ ```ts | ||
import { build } from 'esbuild'; | ||
build({ | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
fallback: 'empty', | ||
modules: { | ||
crypto: true, | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
### Fail the build when certain modules are used: | ||
> **Warn** | ||
> The `write` option in `esbuild` must be `false` to support this. | ||
```ts | ||
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'; | ||
import { build } from 'esbuild'; | ||
const buildResult = await build({ | ||
write: false, | ||
plugins: [nodeModulesPolyfillPlugin({ | ||
modules: { | ||
crypto: 'error', | ||
path: true, | ||
}, | ||
})], | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
modules: { | ||
crypto: 'error', | ||
path: true, | ||
}, | ||
}), | ||
], | ||
}); | ||
``` | ||
Optionally fail the build when a module is not polyfilled or configured (note that the `write` build option must be `false` to support this): | ||
### Fail the build when a module is not polyfilled or configured: | ||
> **Warn** | ||
> The `write` option in `esbuild` must be `false` to support this. | ||
```ts | ||
@@ -129,8 +176,10 @@ import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'; | ||
write: false, | ||
plugins: [nodeModulesPolyfillPlugin({ | ||
fallback: 'error', | ||
modules: { | ||
path: true, | ||
} | ||
})], | ||
plugins: [ | ||
nodeModulesPolyfillPlugin({ | ||
fallback: 'error', | ||
modules: { | ||
path: true, | ||
}, | ||
}), | ||
], | ||
}); | ||
@@ -137,0 +186,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
46906
0
0
195