Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Webpack Polyfill Buffer #19

Open
ericpassmore opened this issue Oct 9, 2022 · 0 comments
Open

Webpack Polyfill Buffer #19

ericpassmore opened this issue Oct 9, 2022 · 0 comments

Comments

@ericpassmore
Copy link
Contributor

ericpassmore commented Oct 9, 2022

Option 1 Recode Buffer to user our own

Option 2 Webpack Buffer into Distribution

  • Install a decent buffer npm install -D buffer
  • set resolve fallback
const webpackConfig = {
    ...
    resolve: {
        ...
        fallback: {
            buffer: require.resolve('buffer/'),
        },
    },
};
  • Configure Webpack ProvidePlugin
const webpackConfig = {
    ...
    plugins: [
        new webpack.ProvidePlugin({
            Buffer: ['buffer', 'Buffer'],
        }),
    ]
};
  • fix import maybe
const Buffer = require('buffer/').Buffer;
@ericpassmore ericpassmore self-assigned this Oct 9, 2022
@ericpassmore ericpassmore added this to the Halloween milestone Oct 9, 2022
@ericpassmore ericpassmore removed their assignment Dec 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant