Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer removed, it cause some trouble #10

Open
ryuran opened this issue Oct 16, 2019 · 6 comments
Open

Buffer removed, it cause some trouble #10

ryuran opened this issue Oct 16, 2019 · 6 comments

Comments

@ryuran
Copy link

ryuran commented Oct 16, 2019

Hello.

I use twing-loader based on twing but this lib is based on Buffer and it is incompatible with webpack 5.

Ironically in my case we don’t need Buffer in the front bundle beacause Twing-loader is only a template loader chained with html-loader and htmlWebpackPlugin, so Buffer is not used in the browser (only for dev mode).

You recommand to use browser entry in package.json https://github.com/defunctzombie/package-browser-field-spec#spec

And you mention a way to add a polyfill manualy:

It's possible to manually add a polyfill for a node.js core module. An error message will give a hint on how to achieve that.

I try to run my webpack mut I have an error ReferenceError: Buffer is not defined without message to explain how to manually add a polyfill.

So:

  • How to manually add a polyfill ?
  • Add a browser entry in twing package.json with a Buffer polyfill is the best way to fix it ?
@DanielRuf
Copy link

https://github.com/feross/buffer is for example a solution for the browser but it depends on the library that you use. This is not a really a problem with webpack itself imo.

@DanielRuf
Copy link

Buffer in general is not part of the browser APIs and only a NodeJS API.

@DanielRuf
Copy link

Regarding the browser field, see https://webpack.js.org/configuration/resolve/#resolvealiasfields and webpack/webpack#151

If this does not work try importing directly https://unpkg.com/browse/[email protected]/dist/es/browser.js

@chaitanyapotti
Copy link

@DanielRuf
I'm building a library which creates a umd, cjs builds. I use some packages which require Buffer polyfill.
What configuration should i use so that Buffer module gets polyfilled in my outputs.?

I tried resolve alias field and it didn't work for Buffer. ( it worked for others like crypto, process etc)

@sebinsua
Copy link

sebinsua commented Apr 18, 2020

@chaitanyapotti

You will also need this, to auto-import Buffer from your buffer alias wherever it finds it:

new webpack.ProvidePlugin({
  Buffer: ['buffer', 'Buffer'],
})

See: duplotech/create-react-app@d0be703

@chaitanyapotti
Copy link

Thanks @sebinsua
That seems to have resolved that issue. However, when i try to use libraryTarget: "module",
i get the following error:
Module external type is not implemented yet

Is the feature not yet built?

benma added a commit to benma/adalite that referenced this issue Nov 8, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
benma added a commit to benma/adalite that referenced this issue Nov 8, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
benma added a commit to benma/adalite that referenced this issue Nov 8, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
benma added a commit to benma/adalite that referenced this issue Nov 8, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
refi93 pushed a commit to vacuumlabs/adalite that referenced this issue Nov 16, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
refi93 pushed a commit to vacuumlabs/adalite that referenced this issue Nov 19, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
refi93 pushed a commit to vacuumlabs/adalite that referenced this issue Nov 22, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
refi93 pushed a commit to vacuumlabs/adalite that referenced this issue Nov 22, 2021
We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined
refi93 pushed a commit to vacuumlabs/adalite that referenced this issue Nov 23, 2021
BYRON keypaths are automatically added with the first account to
discover BYRON addresses.

This works for all current CryptoProviders (Software, Ledger,
Trezor). The BitBox02 does not support receiving on legacy Byron
addresses and exporting m/44'/... xpubs, so we need a feature flag to
indicate that Byron should be turned off when a BitBox02 is used as
the CryptoProvider.

add BitBox02 hardware wallet support

Co-authored-by: thisconnect <[email protected]>

bitbox02: display pairing code

bitbox02: add types for the bitbox02-api dependency

They will eventually be upstreamed.

Excluded from eslint because eslint expects Javascript, not pure
Typescript (e.g. it can't parse the constructor type without a body).

bitbox02: close an existing connection before opening a new one

Same as with getLedgerTransport in the Ledger crypto provider. This
ensures logout followed by another login works.

upgrade from webpack 4 to webpack 5

We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined

bitbox02: lazily load bitbox02-api and split code out of main bundle

Since the bitbox02-api package is quite heavy, we only want to load it
when actually unlocking a BitBox02.

We follow the third approach described in
https://webpack.js.org/guides/code-splitting: using `await
import(...)` to load the package on demand, which also automatically
splits the code into a new file. The `webpackChunkName: "bitbox02-api"` describes the
name of the new file in dist/js/.

The tsconfig change was needed for code splitting to kick in,
according to:
- webpack/webpack#5703 (comment)
- webpack/webpack#5703 (comment)

poolOwner: restrict to Trezor/Ledger
refi93 pushed a commit to vacuumlabs/adalite that referenced this issue Nov 26, 2021
CryptoProviderFeature: add BYRON so new wallets can disable support

BYRON keypaths are automatically added with the first account to
discover BYRON addresses.

This works for all current CryptoProviders (Software, Ledger,
Trezor). The BitBox02 does not support receiving on legacy Byron
addresses and exporting m/44'/... xpubs, so we need a feature flag to
indicate that Byron should be turned off when a BitBox02 is used as
the CryptoProvider.

add BitBox02 hardware wallet support

Co-authored-by: thisconnect <[email protected]>

bitbox02: display pairing code

bitbox02: add types for the bitbox02-api dependency

They will eventually be upstreamed.

Excluded from eslint because eslint expects Javascript, not pure
Typescript (e.g. it can't parse the constructor type without a body).

bitbox02: close an existing connection before opening a new one

Same as with getLedgerTransport in the Ledger crypto provider. This
ensures logout followed by another login works.

upgrade from webpack 4 to webpack 5

We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined

bitbox02: lazily load bitbox02-api and split code out of main bundle

Since the bitbox02-api package is quite heavy, we only want to load it
when actually unlocking a BitBox02.

We follow the third approach described in
https://webpack.js.org/guides/code-splitting: using `await
import(...)` to load the package on demand, which also automatically
splits the code into a new file. The `webpackChunkName: "bitbox02-api"` describes the
name of the new file in dist/js/.

The tsconfig change was needed for code splitting to kick in,
according to:
- webpack/webpack#5703 (comment)
- webpack/webpack#5703 (comment)

poolOwner: restrict to Trezor/Ledger
refi93 pushed a commit to vacuumlabs/adalite that referenced this issue Nov 29, 2021
CryptoProviderFeature: add BYRON so new wallets can disable support

BYRON keypaths are automatically added with the first account to
discover BYRON addresses.

This works for all current CryptoProviders (Software, Ledger,
Trezor). The BitBox02 does not support receiving on legacy Byron
addresses and exporting m/44'/... xpubs, so we need a feature flag to
indicate that Byron should be turned off when a BitBox02 is used as
the CryptoProvider.

add BitBox02 hardware wallet support

Co-authored-by: thisconnect <[email protected]>

bitbox02: display pairing code

bitbox02: add types for the bitbox02-api dependency

They will eventually be upstreamed.

Excluded from eslint because eslint expects Javascript, not pure
Typescript (e.g. it can't parse the constructor type without a body).

bitbox02: close an existing connection before opening a new one

Same as with getLedgerTransport in the Ledger crypto provider. This
ensures logout followed by another login works.

upgrade from webpack 4 to webpack 5

We want to dynamically import the bitbox02-api package and split it
out of the main bundle. After many different attempts we only found
that it works when upgrading to webpack 5, hence this commit.

The upgrade was performed by following
https://webpack.js.org/migrate/5/.

The `require.resolve('...`) additions were upgrade fixes suggested by
webpack itself on the command line.

Other references used:

webpack/changelog-v5#10 (comment)
https://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined

bitbox02: lazily load bitbox02-api and split code out of main bundle

Since the bitbox02-api package is quite heavy, we only want to load it
when actually unlocking a BitBox02.

We follow the third approach described in
https://webpack.js.org/guides/code-splitting: using `await
import(...)` to load the package on demand, which also automatically
splits the code into a new file. The `webpackChunkName: "bitbox02-api"` describes the
name of the new file in dist/js/.

The tsconfig change was needed for code splitting to kick in,
according to:
- webpack/webpack#5703 (comment)
- webpack/webpack#5703 (comment)

poolOwner: restrict to Trezor/Ledger
pomek added a commit to ckeditor/ckeditor5-dev that referenced this issue Mar 24, 2023
Fix (tests): Fixed the reference error `Buffer is not defined`. Read more: webpack/changelog-v5#10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants