Open loynoir opened 2 years ago
package.json
"exports": { ... "./node-buffer": { "default": { "import": "./node-buffer.mjs" } }, ... },
So, every bundler and browser may able to use this awesome repo. 🥺🥺🥺
There is node:buffer pattern. So, fs/promises import id is rollup-plugin-polyfill-node/node-fs-promises
node:buffer
fs/promises
rollup-plugin-polyfill-node/node-fs-promises
<script type="importmap"> { "imports": { "node:buffer": "https://esm.sh/rollup-plugin-polyfill-node@0.11.0/node-buffer", } } </script> <script type="module"> import {Buffer} from "node:buffer" console.log(Buffer) </script>
// global console.log(Buffer)
or
import {Buffer} from "node:buffer" console.log(Buffer)
output
import {Buffer} from "rollup-plugin-polyfill-node/node-buffer" console.log(Buffer)
Feat
package.json
So, every bundler and browser may able to use this awesome repo. 🥺🥺🥺
Thoughts
There is
node:buffer
pattern. So,fs/promises
import id isrollup-plugin-polyfill-node/node-fs-promises
Usage: Browser
Usage: Node
or
output