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

Ben Finney bignose at debian.org
Sun Mar 4 09:26:53 UTC 2018


Howdy all,

How should I write JavaScript ‘import’ statements to import a module
installed by a Debian package?

Now that ‘webpack’ is available in Unstable, I have installed it (into a
Buster host, if that matters) and am trying to write ES6 ‘import’
statements to import library modules.

I have the ‘libjs-backbone’ package installed, and want to use it in
some JavaScript code via an ES6 ‘import’ statement.

The following code::

    import Backbone from '/usr/share/javascript/backbone/backbone.js';

causes the following error from Webpack:

=====
Hash: b5452b7c115f59d18ceb
Version: webpack 3.5.6
Time: 130ms
 Asset     Size  Chunks             Chunk Names
app.js  76.4 kB       0  [emitted]  main
   [0] ./source/foo.js 82 bytes {0} [built]
   [1] /usr/share/javascript/backbone/backbone.js 72.2 kB {0} [built]
   [2] (webpack)/buildin/global.js 488 bytes {0} [built]

ERROR in /usr/share/javascript/backbone/backbone.js
Module not found: Error: Can't resolve 'jquery' in '/usr/share/javascript/backbone'
 @ /usr/share/javascript/backbone/backbone.js 17:4-21:6
 @ ./source/foo.js

ERROR in /usr/share/javascript/backbone/backbone.js
Module not found: Error: Can't resolve 'underscore' in '/usr/share/javascript/backbone'
 @ /usr/share/javascript/backbone/backbone.js 17:4-21:6
 @ ./source/foo.js
=====

Evidently the Debian-installed Backbone library is in turn attempting to
find dependency modules. These are installed (as dependencies of the
Debian ‘libjs-backbone’ package) but are not found when the Backbone
library is imported.


How is this meant to work, with the Debian packages, using ES6 ‘import’
and compiling with Webpack?

-- 
 \      “I put instant coffee in a microwave oven and almost went back |
  `\                                          in time.” —Steven Wright |
_o__)                                                                  |
Ben Finney




More information about the Pkg-javascript-devel mailing list