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

2019-06-18 Thread Pirate Praveen




On Tue, 11 Jun, 2019 at 12:18 PM, Paolo Greppi  
wrote:

On 11/06/19 08:03, Pirate Praveen wrote:
I think rollup-plugin-commonjs will also work without extra options, 
see node-d3-fetch.




rollup-plugin-commonjs is already there in the upstream rollup config:
https://salsa.debian.org/js-team/vue-router.js/blob/master/build/configs.js#L4

P.


Ah I think I got what is going on. If the package is using require, we 
need commonjs plugin and if it is using imports, we need node-resolve 
and the package should install the ES modules. Just figured this us 
when trying to build d3, the d3-* sub modules did not install src 
direcotry and was showing Unresolved dependencies even after adding 
node-resolve. It worked after install src directory in dependencies 
(see last commits in node-d3-array).




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

2019-06-11 Thread Paolo Greppi

On 10/06/19 20:03, Paolo Greppi wrote:

...
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



I tested with the non-minified file generated using the patched build/config.js 
and this command:
NODE_PATH=debian/node_modules/ rollup -m -c debian/rollup-umd.js
but when opening the laminar dashboard I get a new error:

vue-router.min.js:1195 Uncaught TypeError: Cannot read property 'forEach' of 
undefined
at compileRouteRegex (vue-router.min.js:1195)
at addRouteRecord (vue-router.min.js:1112)
at vue-router.min.js:1061
at Array.forEach ()
at createRouteMap (vue-router.min.js:1060)
at createMatcher (vue-router.min.js:1274)
at new VueRouter (vue-router.min.js:2374)
at app.js:796

Not sure if this is due to some path-to-regexp API change.

Anyway that code is skipped for the minified version:
https://salsa.debian.org/js-team/vue-router.js/blob/master/src/create-route-map.js#L156

so I tested the file generated with:
NODE_PATH=debian/node_modules/ rollup -m -c debian/rollup-umd-min.js

and the JavaScript now works apart from some missing CSS and vue is in dev mode 
(see attached screenshot)

So I confirm that the way to go to fix the issue with libjs-vue-router minified 
UMD build is to enable rollup-plugin-node-resolve.
The proposed config change should be moved from build/config.js to 
debian/rollup-umd*.js so that it does not impact the other builds.

But the dev mode, minified UMD build would be affected by the exception above, 
generated in compileRouteRegex function.

Paolo


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

2019-06-11 Thread Paolo Greppi

On 11/06/19 08:03, Pirate Praveen wrote:

I think rollup-plugin-commonjs will also work without extra options, see 
node-d3-fetch.



rollup-plugin-commonjs is already there in the upstream rollup config:
https://salsa.debian.org/js-team/vue-router.js/blob/master/build/configs.js#L4

P.



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

2019-06-11 Thread Pirate Praveen



On 2019, ജൂൺ 10 11:33:29 PM IST, Paolo Greppi  wrote:
>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..
>

I think rollup-plugin-commonjs will also work without extra options, see 
node-d3-fetch.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.