'/@fs/home/dev/repo/node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js?v=0b1a4bd8' does not provide an export named 'Buffer' (at index.js?v=0b1a4bd8:1:10)
9,10,etc worked before.
I create a module which uses buffer, build it and use it in a vite app. Everything is built with vite, including other packages in turbo repo.
In v0.11.0 the resulting library has this:
import { Buffer as BufferPolyfill } from '/home/dev/repo/node_modules/.pnpm/vite-plugin-node-polyfills@0.11.0_vite@4.4.9/node_modules/vite-plugin-node-polyfills/shims/dist/index.js'
window.Buffer = BufferPolyfill
import { global as globalPolyfill } from '/home/dev/repo/node_modules/.pnpm/vite-plugin-node-polyfills@0.11.0_vite@4.4.9/node_modules/vite-plugin-node-polyfills/shims/dist/index.js'
window.global = globalPolyfill
import { process as processPolyfill } from '/home/dev/repo/node_modules/.pnpm/vite-plugin-node-polyfills@0.11.0_vite@4.4.9/node_modules/vite-plugin-node-polyfills/shims/dist/index.js'
window.process = processPolyfill
In v0.10.0 the resulting library has this:
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
(function(e) {
const a = Ca, t = ar, n = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
e.Buffer = i, e.SlowBuffer = P, e.INSPECT_MAX_BYTES = 50;
const l = 2147483647;
e.kMaxLength = l, i.TYPED_ARRAY_SUPPORT = d(), !i.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
);
function d() {
try {
const s = new Uint8Array(1), r = { foo: function() {
return 42;
} };
return Object.setPrototypeOf(r, Uint8Array.prototype), Object.setPrototypeOf(s, r), s.foo() === 42;
} catch {
return !1;
}
}
Uncaught SyntaxError: The requested module
'/@fs/home/dev/repo/node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js?v=0b1a4bd8' does not provide an export named 'Buffer' (at index.js?v=0b1a4bd8:1:10)
9,10,etc worked before.
I create a module which uses buffer, build it and use it in a vite app. Everything is built with vite, including other packages in turbo repo.
In v0.11.0 the resulting library has this:
In v0.10.0 the resulting library has this:
My vite config;