[Pkg-javascript-devel] ES6 ‘import’ of Debian-installed module
Ben Finney
bignose at debian.org
Tue Mar 6 10:15:50 UTC 2018
Pirate Praveen <praveen at onenetbeyond.org> writes:
> On ചൊവ്വ 06 മാർച്ച് 2018 08:29 രാവിലെ, Ben Finney wrote:
> > 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.
>
> I had linked to an exact line of the sample configuration which you
> seem to have missed.
>
> resolve: {
> modules: ['/usr/lib/nodejs', '.'],
> },
> resolveLoader: {
> modules: ['/usr/lib/nodejs'],
> },
Thank you. I add that to the Webpack configuration, which makes it look
like:
=====
$ 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',
},
resolve: {
modules: ['/usr/lib/nodejs', '.'],
},
resolveLoader: {
modules: ['/usr/lib/nodejs'],
},
};
=====
With that configuration, Webpack finds Backbone, but then fails to find
jQuery (as needed by the Debian-installed Backbone package).
=====
$ webpack --config webpack.config.js
Hash: a9597112585b9ca5fb40
Version: webpack 3.5.6
Time: 248ms
Asset Size Chunks Chunk Names
app.js 129 kB 0 [emitted] main
[0] ./source/foo.js 34 bytes {0} [built]
[1] /usr/share/javascript/backbone/backbone.js 72.2 kB {0} [built]
[2] (webpack)/buildin/global.js 488 bytes {0} [built]
[3] /usr/share/javascript/underscore/underscore.js 52.9 kB {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
=====
Is that a bug in the Debian Webpack, or a bug in the Debian Backbone, or
a bug in the Debian jQuery? Or a bug in the Webpack configuration I've
shown above?
> webpack, like other node tools (grunt, gulp) does not recognize global
> modules. So we need to provide this path manually. But we could make
> this path default with a patch in debian like we did for grunt and
> gulp, patches welcome.
I don't understand the problem well enough to patch it. This is by way
of diagnosis so far; but yes, I would assume that the Debian-installed
packages should be found by the Debian-installed Webpack module
resolver.
--
\ Fry: “Take that, poor people!” Leela: “But Fry, you’re not |
`\ rich.” Fry: “No, but I will be someday, and then people like |
_o__) me better watch out!” —Futurama |
Ben Finney
More information about the Pkg-javascript-devel
mailing list