esbuild-plugins icon indicating copy to clipboard operation
esbuild-plugins copied to clipboard

Please enable Crypto

Open muratkeremozcan opened this issue 2 years ago • 4 comments

https://github.com/remorses/esbuild-plugins/blob/d9f6601a24dc4e0470046eda8c772e6523c52b96/node-modules-polyfill/src/polyfills.ts#L142

muratkeremozcan avatar Feb 17 '23 12:02 muratkeremozcan

Is there any alternative to this? Currently stuck on it as well.

CojocaruDr avatar Mar 02 '23 01:03 CojocaruDr

@CojocaruDr try using esbuild-plugin-polyfill-node

piotr-layerzero avatar Jun 21 '23 08:06 piotr-layerzero

@CojocaruDr try using esbuild-plugin-polyfill-node

Bad docs. Assuming this is the usage, it is not helping.

import { polyfillNode } from 'esbuild-plugin-polyfill-node'
...
    build: {
      sourcemap: true,
      bundle: true,
      entryPoints: ['./src/main.tsx'],
      outfile: 'dist/bundle.js',
      plugins: [
        polyfillNode({
          polyfills: {
            crypto: true,
          },
        }),
      ],

Is that the right usage?

muratkeremozcan avatar Jun 22 '23 14:06 muratkeremozcan

@CojocaruDr try using esbuild-plugin-polyfill-node

Bad docs. Assuming this is the usage, it is not helping.

import { polyfillNode } from 'esbuild-plugin-polyfill-node'
...
    build: {
      sourcemap: true,
      bundle: true,
      entryPoints: ['./src/main.tsx'],
      outfile: 'dist/bundle.js',
      plugins: [
        polyfillNode({
          polyfills: {
            crypto: true,
          },
        }),
      ],

Is that the right usage?

this works for me for Cloudflare workers

try setting:

build: {
...
    platform: 'browser',
    conditions: ['worker', 'browser'],
...
}

edit:

build worked, but still encounter different error when running miniflare

shortpoet avatar Dec 17 '23 20:12 shortpoet