[Pkg-javascript-devel] ES6 ‘import’ of Debian-installed module

Ben Finney bignose at debian.org
Tue Mar 6 02:59:28 UTC 2018


Pirate Praveen <praveen at onenetbeyond.org> writes:

> I think it is still better to require/import just 'backbone'

Okay:

=====
$ cat ./source/foo.js
"use strict";
import 'backbone';
=====

> and let nodejs and webpack handle the path resolution.

I believe this configuration just relies on Webpack and NodeJS to figure
out the path resolution:

=====
$ cat webpack.config.js
"use strict";
const path = require('path');
module.exports = {
    entry: './source/foo.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'app.js',
    },
};
=====

Webpack simply fails to find ‘backbone’:

=====
$ dpkg --list node-backbone | grep '^i'
ii  node-backbone  1.3.3~dfsg-3 all          some Backbone for JavaScript applications - Node module

$ webpack --config webpack.config.js
Hash: ff84e9ffdf4f296d9c1d
Version: webpack 3.5.6
Time: 48ms
 Asset     Size  Chunks             Chunk Names
app.js  2.65 kB       0  [emitted]  main
   [0] ./source/foo.js 34 bytes {0} [built]

ERROR in ./source/foo.js
Module not found: Error: Can't resolve 'backbone' in '[…]/source'
 @ ./source/foo.js 3:0-18
=====

So, either the defaults as installed by Debian are not sufficient for
Webpack to resolve the path of an installed NodeJS library; or I have
misunderstood what you say.

-- 
 \        “… no testimony can be admitted which is contrary to reason; |
  `\   reason is founded on the evidence of our senses.” —Percy Bysshe |
_o__)                        Shelley, _The Necessity of Atheism_, 1811 |
Ben Finney




More information about the Pkg-javascript-devel mailing list