On March 4, 2018 2:56:53 PM GMT+05:30, Ben Finney <bign...@debian.org> wrote:
>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:
>

As far as I understand, you have to write code targeting nodejs, ie, use 
node-backbone installed in /usr/lib/nodejs (I don't know if that binary package 
already exist, else you need to create it).

import Backbone from backbone

Webpack will use nodejs dependency resolution and bundle everything into an 
output file which you can serve to browser.

But this is nothing specific to Debian and you might get a better answer 
searching for node+backbone. Or in general developing front end in JavaScript. 
You can also refer to gitlab package and see how it uses webpack.

http://kroltech.com/2013/12/29/boilerplate-web-app-using-backbone-js-expressjs-node-js-mongodb/

https://speckyboy.com/node-js-for-front-end-developers/

Since node version in Debian does not support es6 imports yet (it is planned 
for nodejs 10), you have to use node-babel-loader as well. Check node-d3-zoom 
for an example.

BTW rollup is also available in Debian now, so you have a choice of rollup or 
webpack.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

-- 
Pkg-javascript-devel mailing list
Pkg-javascript-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-javascript-devel

Reply via email to