[Pkg-javascript-devel] Bug#927254: possible solution

Paolo Greppi paolo.greppi at libpf.com
Mon Jun 10 19:03:29 BST 2019


If I build manually the UMD version using the same command as in debian/rules:

NODE_PATH=debian/node_modules/ rollup -m -c debian/rollup-umd.js

I get this:

/home/paolog/Sviluppo/debian/vue-router.js/src/index.js → dist/vue-router.js...
(!) Unresolved dependencies
https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency
path-to-regexp (imported by src/util/params.js, src/create-route-map.js)
(!) Missing global variable name
Use options.globals to specify browser global variable names corresponding to external modules
path-to-regexp (guessing 'Regexp')
created dist/vue-router.js in 761ms

so it is not bundling path-to-regexp, assuming it is available to the browser as Regexp which clearly is not the case.

Following the advice from the rollup and rollup-plugin-node-resolve docs, I modified the rollup config like this:

diff --git a/build/configs.js b/build/configs.js
index f81ec3a..378437b 100644
--- a/build/configs.js
+++ b/build/configs.js
@@ -36,11 +36,19 @@ module.exports = [
    }
  ].map(genConfig)
  
+const resolve1 = require('rollup-plugin-node-resolve')
+
  function genConfig (opts) {
    const config = {
      input: {
        input: resolve('src/index.js'),
        plugins: [
+      require('rollup-plugin-node-resolve')({
+        customResolveOptions: {
+            moduleDirectory: ['/usr/lib/nodejs'],
+            preferBuiltins: false
+          }
+        }),
          flow(),
          node(),
          cjs(),

Now the same command bundles path-to-regexp, so that the differences between the file generated in dist/vue-router.js
and the one from  wget https://unpkg.com/vue-router@3.0.2/dist/vue-router.js are much less (mainly the differences between path-to-regexp 1.7.0 bundled by upstream and 3.0.0 bundled by us).

Tomorrow I'll test the generated file inside laminar. If that works this is an acceptable solution.
The last bit is to move this config change to debian/rollup-umd.js so that it does not impact all builds..

Paolo



More information about the Pkg-javascript-devel mailing list