Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.bugs.dist > #1010179 > unrolled thread

Bug#960901: webpack: Resolver falsely detects phantom ‘buffer’ import in ‘clone’ library

Started byBen Finney <bignose@debian.org>
First post2020-05-18 05:30 +0200
Last post2020-08-03 07:30 +0200
Articles 4 — 1 participant

Back to article view | Back to linux.debian.bugs.dist


Contents

  Bug#960901: webpack: Resolver falsely detects phantom ‘buffer’ import in ‘clone’ library Ben Finney <bignose@debian.org> - 2020-05-18 05:30 +0200
    Bug#960901: Buffer is a built-in node function Ben Finney <bignose@debian.org> - 2020-06-16 05:40 +0200
      Bug#960901: Buffer is a built-in node function Ben Finney <bignose@debian.org> - 2020-06-16 08:10 +0200
    Bug#960901: Buffer is a built-in node function Ben Finney <bignose@debian.org> - 2020-08-03 07:30 +0200

#1010179 — Bug#960901: webpack: Resolver falsely detects phantom ‘buffer’ import in ‘clone’ library

FromBen Finney <bignose@debian.org>
Date2020-05-18 05:30 +0200
SubjectBug#960901: webpack: Resolver falsely detects phantom ‘buffer’ import in ‘clone’ library
Message-ID<A7EDv-5I3-1@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

Package: webpack
Version: 4.43.0-1
Severity: normal

When I create a minimal project that imports the ‘clone’ library,
Webpack reports that it cannot resolve an import of ‘buffer’:

=====
ERROR in /usr/share/nodejs/clone/clone.js
Module not found: Error: Can't resolve './../../../../tmp/app-using-clone.AIFQnn/buffer' in '/usr/share/nodejs/clone'
 @ /usr/share/nodejs/clone/clone.js 1:0-58
 @ ./source/main.js
=====

There is no attempt in that library to import ‘buffer’. The path in
the error message should never be used and is not present in the
‘clone’ library.

The ‘clone’ library is the ‘/usr/share/nodejs/clone/clone.js’
installed from Debian.

Webpack is not reporting correctly where it is finding this import. So
it is not clear, from that error message, what is causing Webpack to
detect a ‘buffer’ name that it then cannot resolve.


Here is a demonstration of how I invoked the above error:

=====
$ dpkg-query --list node-clone | grep '^i'
ii  node-clone     2.1.2-2      all          deep cloning of objects and arrays

$ cd $(mktemp --tmpdir --directory 'app-using-clone.XXXXXX')

$ mkdir source/
$ cat > source/main.js
"use strict";
import clone from 'clone';

$ cat > webpack-config.js
"use strict";

const path = require('path');

const rootDir = path.resolve(__dirname);
const sourceDir = path.resolve(rootDir, 'source');
const buildDir = path.resolve(rootDir, 'build');

module.exports = {
    mode: 'development',
    entry: {
        app: path.resolve(sourceDir, 'main.js'),
    },
    output: {
        path: buildDir,
        filename: 'app.js',
    },
    resolve: {
        modules: [
            sourceDir,
            '/usr/share/javascript',
            '/usr/share/nodejs',
        ],
    },
};

$ webpack --config webpack-config.js
Hash: eceaa9ff3519c5b14efb
Version: webpack 4.43.0
Time: 111ms
Built at: 18/05/2020 1:09:24 pm
 Asset      Size  Chunks             Chunk Names
app.js  12.1 KiB     app  [emitted]  app
Entrypoint app = app.js
[../../usr/share/nodejs/clone/clone.js]
/usr/share/nodejs/clone/clone.js 7.12 KiB {app} [built]
[./source/main.js] 42 bytes {app} [built]

ERROR in /usr/share/nodejs/clone/clone.js
Module not found: Error: Can't resolve
'./../../../../tmp/app-using-clone.AIFQnn/buffer' in
'/usr/share/nodejs/clone'
 @ /usr/share/nodejs/clone/clone.js 1:0-58
 @ ./source/main.js

$
=====


-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 5.6.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_AU.UTF-8), LANGUAGE=en_AU.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_AU.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages webpack depends on:
ii  node-ajv                           6.10.2-1
ii  node-ajv-keywords                  3.4.1-1
ii  node-anymatch                      3.1.1+~2.1.1-1
ii  node-debbundle-acorn [node-acorn]  6.2.1+ds+~cs11.24.3-3
ii  node-enhanced-resolve              4.1.0-4
ii  node-esrecurse                     4.2.1-1
ii  node-estraverse                    4.2.0-1
ii  node-findup-sync                   4.0.0-3
ii  node-interpret                     1.0.1-1
ii  node-json-parse-better-errors      1.0.2-2
ii  node-libs-browser                  2.2.1-3
ii  node-loader-runner                 2.3.0-2
ii  node-loader-utils                  1.2.3-1
ii  node-memory-fs                     0.4.1-2
ii  node-micromatch                    4.0.2+repack-3
ii  node-mkdirp                        0.5.1-2
ii  node-neo-async                     2.6.1-3
ii  node-resolve-cwd                   2.0.0-2
ii  node-schema-utils                  1.0.0-2
ii  node-supports-color                6.1.0-2
ii  node-tapable                       1.0.0-4
ii  node-uglifyjs-webpack-plugin       1.3.0-6
ii  node-watchpack                     1.6.0-2
ii  node-webassemblyjs                 1.9.0+dfsg-4
ii  node-webpack-sources               1.1.0-2
ii  node-yargs                         15.3.0-1
ii  nodejs                             10.20.1~dfsg-1

webpack recommends no packages.

webpack suggests no packages.

-- no debconf information

-- 
 \            “Politics is not the art of the possible. It consists in |
  `\       choosing between the disastrous and the unpalatable.” —John |
_o__)                                    Kenneth Galbraith, 1962-03-02 |
Ben Finney <bignose@debian.org>

[toc] | [next] | [standalone]


#1014058 — Bug#960901: Buffer is a built-in node function

FromBen Finney <bignose@debian.org>
Date2020-06-16 05:40 +0200
SubjectBug#960901: Buffer is a built-in node function
Message-ID<AiaC5-7Mg-5@gated-at.bofh.it>
In reply to#1010179

[Multipart message — attachments visible in raw view] — view raw

On 18-May-2020, Pirate Praveen wrote:
> https://salsa.debian.org/js-team/node-clone/-/blob/master/clone.js#L109
> I think we may need to embed older version of buffer module in node-libs-browser

Okay. I assume that is information for the ‘node-libs-browser’
maintainer, I think as a user I can't affect that.

> For this particular case you can try embedding buffer module version
> 4.x as browsers need an equivalent module to features present only
> in node.

This looks like advice for me to work around the problem. What do I
need to do? How do I (as a user of Webpack) “embed buffer module
version 4.x”?

-- 
 \       “It is forbidden to steal hotel towels. Please if you are not |
  `\          person to do such is please not to read notice.” —hotel, |
_o__)                                               Kowloon, Hong Kong |
Ben Finney <bignose@debian.org>

[toc] | [prev] | [next] | [standalone]


#1014072 — Bug#960901: Buffer is a built-in node function

FromBen Finney <bignose@debian.org>
Date2020-06-16 08:10 +0200
SubjectBug#960901: Buffer is a built-in node function
Message-ID<AicXg-TZ-1@gated-at.bofh.it>
In reply to#1014058

[Multipart message — attachments visible in raw view] — view raw

On 16-Jun-2020, Ben Finney wrote:
> On 18-May-2020, Pirate Praveen wrote:
> > For this particular case you can try embedding buffer module
> > version 4.x as browsers need an equivalent module to features
> > present only in node.
> 
> This looks like advice for me to work around the problem. What do I
> need to do? How do I (as a user of Webpack) “embed buffer module
> version 4.x”?

Is this upstream issue related, does it have a solution?
<URL:https://github.com/webpack/webpack/issues/6913>. From that issue:

> This is because the mode ESM is applied to the Buffer polyfill. You
> must use include or exclude to only set the type for your source.

That discusses how to alter the code which uses “buffer”. I don't see
how to apply this to code which merely uses Webpack to bundle
libraries together.

-- 
 \      “Compulsory unification of opinion achieves only the unanimity |
  `\        of the graveyard.” —Justice Roberts in 319 U.S. 624 (1943) |
_o__)                                                                  |
Ben Finney <bignose@debian.org>

[toc] | [prev] | [next] | [standalone]


#1020237 — Bug#960901: Buffer is a built-in node function

FromBen Finney <bignose@debian.org>
Date2020-08-03 07:30 +0200
SubjectBug#960901: Buffer is a built-in node function
Message-ID<AzBcS-7it-5@gated-at.bofh.it>
In reply to#1010179

[Multipart message — attachments visible in raw view] — view raw

Howdy Pirate,

On 18-May-2020, Pirate Praveen wrote:

> For this particular case you can try embedding buffer module version
> 4.x as browsers need an equivalent module to features present only
> in node.

This looks like advice for me to work around the problem. What do I
need to do? How do I (as a user of the Debian package of Webpack)
“embed buffer module version 4.x”?

-- 
 \       “Even if the voices in my head are not real, they have pretty |
  `\                                           good ideas.” —anonymous |
_o__)                                                                  |
Ben Finney <bignose@debian.org>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.bugs.dist


csiph-web